Skip to content

Commit f4def86

Browse files
committed
Bump torch version enabling numpy 2 compatibility
PyTorch added support for numpy 2 starting with PyTorch 2.3.0. This allows for numpy 1 or numpy 2 to be used with torch>=2.3.0. A special case is being handled on Windows as PyTorch Windows binaries had compatibilities issues with numpy 2 that were fixed in torch 2.4.1 (see pytorch/pytorch#131668 (comment)). Signed-off-by: James Butler <[email protected]>
1 parent ce66899 commit f4def86

File tree

10 files changed

+18
-20
lines changed

10 files changed

+18
-20
lines changed

.github/workflows/cron.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,11 @@ jobs:
1313
strategy:
1414
matrix:
1515
environment:
16-
- "PT220+CUDA118"
1716
- "PT230+CUDA121"
1817
- "PT240+CUDA126"
1918
- "PTLATEST+CUDA126"
2019
include:
2120
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes
22-
- environment: PT220+CUDA118
23-
pytorch: "torch==2.2.0 torchvision==0.17.0 --extra-index-url https://download.pytorch.org/whl/cu121"
24-
base: "nvcr.io/nvidia/pytorch:22.10-py3" # CUDA 11.8
2521
- environment: PT230+CUDA121
2622
pytorch: "pytorch==2.3.0 torchvision==0.18.0 --extra-index-url https://download.pytorch.org/whl/cu121"
2723
base: "nvcr.io/nvidia/pytorch:23.08-py3" # CUDA 12.1

.github/workflows/pythonapp-min.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
strategy:
125125
fail-fast: false
126126
matrix:
127-
pytorch-version: ['2.2.2', '2.3.1', '2.4.1', 'latest']
127+
pytorch-version: ['2.3.1', '2.4.1', '2.5.1', 'latest']
128128
timeout-minutes: 40
129129
steps:
130130
- uses: actions/checkout@v4

.github/workflows/pythonapp.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
- if: runner.os == 'windows'
9595
name: Install torch cpu from pytorch.org (Windows only)
9696
run: |
97-
python -m pip install torch==2.2.0+cpu torchvision==0.17.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
97+
python -m pip install torch==2.4.1 torchvision==0.19.1+cpu --index-url https://download.pytorch.org/whl/cpu
9898
- if: runner.os == 'Linux'
9999
name: Install itk pre-release (Linux only)
100100
run: |
@@ -103,7 +103,7 @@ jobs:
103103
- name: Install the dependencies
104104
run: |
105105
python -m pip install --user --upgrade pip wheel
106-
python -m pip install torch==2.2.0 torchvision==0.17.0
106+
python -m pip install torch==2.4.1 torchvision==0.19.1
107107
cat "requirements-dev.txt"
108108
python -m pip install -r requirements-dev.txt
109109
python -m pip list
@@ -155,7 +155,7 @@ jobs:
155155
# install the latest pytorch for testing
156156
# however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated
157157
# fresh torch installation according to pyproject.toml
158-
python -m pip install torch>=2.2.0 torchvision
158+
python -m pip install torch>=2.3.0 torchvision
159159
- name: Check packages
160160
run: |
161161
pip uninstall monai

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-f https://download.pytorch.org/whl/cpu/torch-2.2.0%2Bcpu-cp39-cp39-linux_x86_64.whl
2-
torch>=2.2.0
1+
-f https://download.pytorch.org/whl/cpu/torch-2.3.0%2Bcpu-cp39-cp39-linux_x86_64.whl
2+
torch>=2.3.0
33
pytorch-ignite==0.4.11
44
numpy>=1.20
55
itk>=5.2

environment-dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ channels:
55
- nvidia
66
- conda-forge
77
dependencies:
8-
- numpy>=1.24,<2.0
9-
- pytorch>=2.2.0
8+
- numpy>=1.24,<3.0
9+
- pytorch>=2.3.0
1010
- torchio
1111
- torchvision
1212
- pytorch-cuda>=11.6

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
requires = [
33
"wheel",
44
"setuptools",
5-
"torch>=2.2.0",
5+
"torch>=2.3.0",
66
"ninja",
77
"packaging"
88
]

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
torch>=2.2.0,<2.6
2-
numpy>=1.24,<2.0
1+
torch>=2.3.0,<2.6; sys_platform != 'win32'
2+
torch>=2.4.1,<2.6; sys_platform == 'win32'
3+
numpy>=1.24,<3.0

setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ setup_requires =
4242
ninja
4343
packaging
4444
install_requires =
45-
torch>=2.2.0
46-
numpy>=1.24,<2.0
45+
torch>=2.3.0; sys_platform != 'win32'
46+
torch>=2.4.1; sys_platform == 'win32'
47+
numpy>=1.24,<3.0
4748

4849
[options.extras_require]
4950
all =

tests/integration/test_integration_bundle_run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_tiny(self):
7676
)
7777
with open(meta_file, "w") as f:
7878
json.dump(
79-
{"version": "0.1.0", "monai_version": "1.1.0", "pytorch_version": "2.2.0", "numpy_version": "1.22.2"}, f
79+
{"version": "0.1.0", "monai_version": "1.1.0", "pytorch_version": "2.3.0", "numpy_version": "1.22.2"}, f
8080
)
8181
cmd = ["coverage", "run", "-m", "monai.bundle"]
8282
# test both CLI entry "run" and "run_workflow"
@@ -113,7 +113,7 @@ def test_scripts_fold(self):
113113
)
114114
with open(meta_file, "w") as f:
115115
json.dump(
116-
{"version": "0.1.0", "monai_version": "1.1.0", "pytorch_version": "2.2.0", "numpy_version": "1.22.2"}, f
116+
{"version": "0.1.0", "monai_version": "1.1.0", "pytorch_version": "2.3.0", "numpy_version": "1.22.2"}, f
117117
)
118118

119119
os.mkdir(scripts_dir)

tests/nonconfig_workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def initialize(self):
6565
self._monai_version = "1.1.0"
6666

6767
if self._pytorch_version is None:
68-
self._pytorch_version = "2.2.0"
68+
self._pytorch_version = "2.3.0"
6969

7070
if self._numpy_version is None:
7171
self._numpy_version = "1.22.2"

0 commit comments

Comments
 (0)