Skip to content

Commit edc76b8

Browse files
committed
Document ONNX prerequisites and add [onnx] extras_require
torch>=2.6 changed its ONNX exporter to require onnxscript, so users hitting the export scripts on a fresh install were getting ModuleNotFoundError. This adds: - setup.py: extras_require={'onnx': [onnx, onnxruntime, onnxscript, onnx-simplifier]} so users can pip install nnunetv2_distillation[onnx]. - docs/Distillation.md: a Prerequisites callout before the ONNX export section listing both the extras install and the manual pip command.
1 parent c5d1b2d commit edc76b8

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

distillation/setup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
"torch>=1.6.0",
88
"nnunetv2>=2.5,<3.0",
99
],
10+
extras_require={
11+
# ONNX export deps. torch>=2.6 needs onnxscript for the new exporter;
12+
# onnx-simplifier is only used when the user passes --simplify / -sim.
13+
"onnx": [
14+
"onnx",
15+
"onnxruntime",
16+
"onnxscript",
17+
"onnx-simplifier",
18+
],
19+
},
1020
entry_points={
1121
'console_scripts': [
1222
'nnUNetv2_distillation_train=fast_nnunet_distillation_train:main',

docs/Distillation.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,23 @@ Parameter description:
222222

223223
### 3. 📤 Export ONNX Model
224224

225-
Export the trained student model to ONNX format for fast inference:
225+
Export the trained student model to ONNX format for fast inference.
226+
227+
> **Prerequisites:** ONNX export depends on a few extra packages that are
228+
> not part of the core install. The easiest way is the `[onnx]` extra:
229+
>
230+
> ```bash
231+
> pip install -e '.[onnx]' # quotes needed for zsh
232+
> ```
233+
>
234+
> Or install them manually:
235+
>
236+
> ```bash
237+
> pip install onnx onnxruntime onnxscript onnx-simplifier
238+
> ```
239+
>
240+
> `onnxscript` is required by PyTorch 2.6+ for the new ONNX exporter,
241+
> and `onnx-simplifier` is only needed when you pass `--simplify` / `-sim`.
226242
227243
#### Standard Distillation Model Export
228244

0 commit comments

Comments
 (0)