Skip to content

Commit d640012

Browse files
committed
Updates
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
1 parent bb0e429 commit d640012

4 files changed

Lines changed: 50 additions & 32 deletions

File tree

.github/workflows/cicd_tests.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,13 @@ jobs:
275275
- name: Install dependencies + nvsubquadratic (no-deps)
276276
run: |
277277
python -m pip install --upgrade pip wheel tomli pytest
278-
python monai/config/print_dependencies.py build-system | xargs pip install --no-build-isolation
279-
python -m pip install torch==${PYTORCH_VER1} torchvision==${TORCHVISION_VER1}
278+
# need a specific version of torch for nvsubquadratic
279+
python monai/config/print_dependencies.py build-system | \
280+
xargs -d '\n' pip install --no-build-isolation torch==2.10.0 torchvision==0.25.0
280281
# # nvsubquadratic runtime imports need only torch + einops + omegaconf; install
281282
# # the package itself without its core dependency tree (see job comment above).
282-
# python -m pip install omegaconf
283-
# python -m pip install --no-deps 'nvsubquadratic>=0.1.1'
283+
python -m pip install --no-build-isolation omegaconf
284+
python -m pip install --no-build-isolation --no-deps 'nvsubquadratic>=0.1.1'
284285
python -m pip install --no-build-isolation .[hyena,testing]
285286
python -m pip list
286287
shell: bash
@@ -298,6 +299,7 @@ jobs:
298299
runs-on: ubuntu-latest
299300
env:
300301
QUICKTEST: True
302+
INDEX_URL: "https://download.pytorch.org/whl/cpu"
301303
steps:
302304
- name: Clean unused tools
303305
run: |
@@ -318,11 +320,8 @@ jobs:
318320
run: |
319321
python -m pip install --user --upgrade pip setuptools wheel twine packaging tomli
320322
# install the latest pytorch for testing
321-
# however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated
322-
# fresh torch installation according to pyproject.toml
323-
python -m pip install torch==${PYTORCH_VER1} torchvision --extra-index-url https://download.pytorch.org/whl/cpu
324-
python monai/config/print_dependencies.py build-system all testing > requirements.txt
325-
pip install --no-build-isolation -r requirements.txt
323+
python monai/config/print_dependencies.py build-system all testing | \
324+
xargs -d '\n' pip install --no-build-isolation torch==${PYTORCH_VER1} --extra-index-url $INDEX_URL
326325
- name: Check packages
327326
run: |
328327
python -m pip uninstall -y monai
@@ -351,7 +350,7 @@ jobs:
351350
working-directory: ${{ steps.mktemp.outputs.tmp_dir }}
352351
run: |
353352
# install from wheel
354-
python -m pip install monai*.whl --extra-index-url https://download.pytorch.org/whl/cpu
353+
python -m pip install --no-build-isolation monai*.whl --extra-index-url $INDEX_URL
355354
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
356355
python -c 'import monai; print(monai.__file__)'
357356
python -m pip uninstall -y monai
@@ -361,6 +360,14 @@ jobs:
361360
run: |
362361
for name in *.tar.gz; do break; done
363362
echo $name
364-
python -m pip install ${name}[all] --extra-index-url https://download.pytorch.org/whl/cpu
363+
python -m pip install --no-build-isolation ${name}[all] --extra-index-url $INDEX_URL
364+
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
365+
python -c 'import monai; print(monai.__file__)'
366+
python -m pip uninstall -y monai
367+
- name: Install using uv
368+
working-directory: ${{ steps.mktemp.outputs.tmp_dir }}
369+
run: |
370+
pip install uv
371+
uv pip install --no-build-isolation .[all] --extra-index-url $INDEX_URL
365372
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
366373
python -c 'import monai; print(monai.__file__)'

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md versionee
4949
COPY tests ./tests
5050
COPY monai ./monai
5151

52-
# Need to install build requirements explicitly so that no-build-isolation can be used. This needed to make pip build
53-
# against the included version of PyTorch, rather than install a new version in the isolated environment.
52+
# Need to install build requirements explicitly so that no-build-isolation can be used. This is needed to make pip build
53+
# against the included version of PyTorch, rather than install a new version in the isolated environment. Constraint
54+
# files will not work for this image which installed things like PyTorch through files which are no longer present.
5455
RUN python monai/config/print_dependencies.py build-system | xargs -d '\n' pip install --no-cache-dir --no-build-isolation \
5556
&& FORCE_CUDA=1 pip install --no-cache-dir --no-build-isolation -e .[all,testing]

docs/source/installation.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,33 +130,39 @@ or, to build with MONAI C++/CUDA extensions:
130130
BUILD_MONAI=1 pip install git+https://github.com/Project-MONAI/MONAI
131131
```
132132

133-
To build the extensions, if the system environment already has a version of PyTorch installed,
134-
`--no-build-isolation` might be preferred:
135-
136-
```bash
137-
BUILD_MONAI=1 pip install --no-build-isolation git+https://github.com/Project-MONAI/MONAI
138-
```
139-
140-
When using build isolation (pip's default behaviour), a version of PyTorch must be installed which may not be the same as an existing install. This can cause the compiled libraries to be built against an ABI-incompatible PyTorch and thus not function at runtime. Building without isolation requires the current environment to have the necessary building libraries already installed. See the `build-system` section of `pyproject.toml` for these libraries, or use the following to install them:
141-
142-
```bash
143-
python monai/config/print_dependencies.py build-system | xargs -d '\n' pip install --no-build-isolation
144-
```
145-
146133
On Windows the inline `BUILD_MONAI=1 pip install ...` form is not supported by
147134
`cmd.exe` or PowerShell. Set the environment variable first, then run either
148135
install command shown above:
149136

150137
```bat
151138
:: cmd.exe
152139
set BUILD_MONAI=1
153-
pip install --no-build-isolation git+https://github.com/Project-MONAI/MONAI
140+
pip install git+https://github.com/Project-MONAI/MONAI
154141
```
155142

156143
```powershell
157144
# PowerShell
158145
$env:BUILD_MONAI="1"
159-
pip install --no-build-isolation git+https://github.com/Project-MONAI/MONAI
146+
pip install git+https://github.com/Project-MONAI/MONAI
147+
```
148+
149+
To build the extensions, if the system environment already has a version of PyTorch installed, `--no-build-isolation` might be preferred:
150+
151+
```bash
152+
BUILD_MONAI=1 pip install --no-build-isolation git+https://github.com/Project-MONAI/MONAI
153+
```
154+
155+
When using build isolation (pip's default behaviour), a version of PyTorch must be installed which may not be the same as an existing install. This can cause the compiled libraries to be built against an ABI-incompatible PyTorch and thus not function at runtime. Building without isolation requires the current environment to have the necessary building libraries already installed. See the `build-system` section of `pyproject.toml` for these libraries, or use the following to install them in a bash environment:
156+
157+
```bash
158+
python monai/config/print_dependencies.py build-system | xargs -d '\n' pip install --no-build-isolation
159+
```
160+
161+
An alternative solution is to use built constraints during installation:
162+
163+
```bash
164+
pip freeze | grep torch > constraints.txt
165+
pip install --build-constraint constraints.txt git+https://github.com/Project-MONAI/MONAI
160166
```
161167

162168
this command will download and install the current `dev` branch of [MONAI from
@@ -178,6 +184,7 @@ You can install it by running:
178184
```bash
179185
cd MONAI/
180186
pip install -e .
187+
# or pip install -e .[all,testing] to include most of the dependencies
181188
```
182189

183190
or, to build with MONAI C++/CUDA extensions and install:
@@ -205,6 +212,8 @@ $env:BUILD_MONAI="1"
205212
pip install -e .
206213
```
207214

215+
If the compiled extensions were built by pip against a different version of PyTorch than the one in your environment, you may need to run the above with the `--no-build-isoloation` flag to force the use of that version, or use the `--build-constraint` method.
216+
208217
To uninstall the package please run:
209218

210219
```bash

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[build-system]
33
requires = [
4-
"setuptools<71.0.0", # pkg_resources removed in setuptools>=71; needed by MetricsReloaded setup.py
4+
"setuptools",
55
"wheel",
66
"versioneer[toml]",
77
"more-itertools>=8.0",
@@ -41,8 +41,7 @@ classifiers = [
4141
]
4242
dependencies = [
4343
"torch>=2.8.0",
44-
"numpy>=1.24,<3.0",
45-
"setuptools<71.0.0" # used here to match requirement in build-system and prevent different PyTorch installations
44+
"numpy>=1.24,<3.0"
4645
]
4746
dynamic = ["version"]
4847

@@ -276,6 +275,8 @@ exclude = '''
276275
| \.hg
277276
| \.tox
278277
| \.venv
278+
| \.mypy_cache
279+
| \.pytype
279280
| venv
280281
| _build
281282
| buck-out
@@ -382,7 +383,7 @@ project-excludes = [
382383
]
383384

384385
# Match CI environment
385-
python-version = "3.9"
386+
python-version = "3.10"
386387
python-platform = "linux"
387388

388389
# "legacy" preset provides a smooth migration from previous type checkers

0 commit comments

Comments
 (0)