Skip to content

Commit d664f3d

Browse files
authored
Merge branch 'Project-MONAI:dev' into inferer_modification
2 parents e5aa008 + 44add8d commit d664f3d

File tree

869 files changed

+1552
-1919
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

869 files changed

+1552
-1919
lines changed

.github/workflows/cron.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@ jobs:
1313
strategy:
1414
matrix:
1515
environment:
16-
- "PT110+CUDA113"
1716
- "PT113+CUDA118"
1817
- "PT210+CUDA121"
1918
- "PT240+CUDA126"
2019
- "PTLATEST+CUDA126"
2120
include:
2221
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes
23-
- environment: PT110+CUDA113
24-
pytorch: "torch==1.10.2 torchvision==0.11.3 --extra-index-url https://download.pytorch.org/whl/cu113"
25-
base: "nvcr.io/nvidia/pytorch:21.06-py3" # CUDA 11.3
2622
- environment: PT113+CUDA118
2723
pytorch: "torch==1.13.1 torchvision==0.14.1 --extra-index-url https://download.pytorch.org/whl/cu121"
2824
base: "nvcr.io/nvidia/pytorch:22.10-py3" # CUDA 11.8

.github/workflows/pythonapp-gpu.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,10 @@ jobs:
2222
strategy:
2323
matrix:
2424
environment:
25-
- "PT19+CUDA114DOCKER"
26-
- "PT110+CUDA111"
27-
- "PT112+CUDA118DOCKER"
2825
- "PT113+CUDA116"
2926
- "PT210+CUDA121DOCKER"
3027
include:
3128
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes
32-
- environment: PT110+CUDA111
33-
pytorch: "torch==1.10.2 torchvision==0.11.3 --extra-index-url https://download.pytorch.org/whl/cu111"
34-
base: "nvcr.io/nvidia/cuda:11.1.1-devel-ubuntu18.04"
35-
- environment: PT112+CUDA118DOCKER
36-
# 22.09: 1.13.0a0+d0d6b1f
37-
pytorch: "-h" # we explicitly set pytorch to -h to avoid pip install error
38-
base: "nvcr.io/nvidia/pytorch:22.09-py3"
3929
- environment: PT113+CUDA116
4030
pytorch: "torch==1.13.1 torchvision==0.14.1"
4131
base: "nvcr.io/nvidia/cuda:11.6.1-devel-ubuntu18.04"
@@ -59,8 +49,7 @@ jobs:
5949
apt-get update
6050
apt-get install -y wget
6151
62-
if [ ${{ matrix.environment }} = "PT110+CUDA111" ] || \
63-
[ ${{ matrix.environment }} = "PT113+CUDA116" ]
52+
if [ ${{ matrix.environment }} = "PT113+CUDA116" ]
6453
then
6554
PYVER=3.9 PYSFX=3 DISTUTILS=python3-distutils && \
6655
apt-get update && apt-get install -y --no-install-recommends \
@@ -94,9 +83,6 @@ jobs:
9483
python get-pip.py && \
9584
rm get-pip.py;
9685
fi
97-
- if: matrix.environment == 'PT19+CUDA114DOCKER'
98-
name: Optional Cupy dependency (cuda114)
99-
run: echo "cupy-cuda114" >> requirements-dev.txt
10086
- name: Install dependencies
10187
if: github.event.pull_request.merged != true
10288
run: |

.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: ['1.10.2', '1.11.0', '1.12.1', '1.13', '2.0.1', 'latest']
127+
pytorch-version: ['1.13.1', '2.0.1', '2.2.2', '2.3.1', '2.4.1', 'latest']
128128
timeout-minutes: 40
129129
steps:
130130
- uses: actions/checkout@v4

.github/workflows/pythonapp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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>=1.9 torchvision
158+
python -m pip install torch>=1.13.1 torchvision
159159
- name: Check packages
160160
run: |
161161
pip uninstall monai

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ repos:
6666
)$
6767
6868
- repo: https://github.com/hadialqattan/pycln
69-
rev: v2.4.0
69+
rev: v2.5.0
7070
hooks:
7171
- id: pycln
7272
args: [--config=pyproject.toml]

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-1.12.1%2Bcpu-cp37-cp37m-linux_x86_64.whl
2-
torch>=1.9
1+
-f https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp39-cp39-linux_x86_64.whl
2+
torch>=1.13.1
33
pytorch-ignite==0.4.11
44
numpy>=1.20
55
itk>=5.2

environment-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ channels:
66
- conda-forge
77
dependencies:
88
- numpy>=1.24,<2.0
9-
- pytorch>=1.9
9+
- pytorch>=1.13.1
1010
- torchio
1111
- torchvision
1212
- pytorch-cuda>=11.6

monai/apps/auto3dseg/transforms.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import torch
1919

2020
from monai.config import KeysCollection
21-
from monai.networks.utils import pytorch_after
2221
from monai.transforms import MapTransform
2322
from monai.utils.misc import ImageMetaKey
2423

@@ -74,9 +73,7 @@ def __call__(self, data: Mapping[Hashable, torch.Tensor]) -> dict[Hashable, torc
7473
f", the metadata was not updated {filename}."
7574
)
7675
d[key] = torch.nn.functional.interpolate(
77-
input=d[key].unsqueeze(0),
78-
size=image_shape,
79-
mode="nearest-exact" if pytorch_after(1, 11) else "nearest",
76+
input=d[key].unsqueeze(0), size=image_shape, mode="nearest-exact"
8077
).squeeze(0)
8178
else:
8279
raise ValueError(

monai/data/meta_tensor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,3 +607,8 @@ def print_verbose(self) -> None:
607607
print(self)
608608
if self.meta is not None:
609609
print(self.meta.__repr__())
610+
611+
612+
# needed in later versions of Pytorch to indicate the class is safe for serialisation
613+
if hasattr(torch.serialization, "add_safe_globals"):
614+
torch.serialization.add_safe_globals([MetaTensor])

monai/data/utils.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
issequenceiterable,
5151
look_up_option,
5252
optional_import,
53-
pytorch_after,
5453
)
5554

5655
pd, _ = optional_import("pandas")
@@ -450,12 +449,9 @@ def collate_meta_tensor_fn(batch, *, collate_fn_map=None):
450449
Collate a sequence of meta tensor into a single batched metatensor. This is called by `collage_meta_tensor`
451450
and so should not be used as a collate function directly in dataloaders.
452451
"""
453-
if pytorch_after(1, 13):
454-
from torch.utils.data._utils.collate import collate_tensor_fn # imported here for pylint/mypy issues
452+
from torch.utils.data._utils.collate import collate_tensor_fn # imported here for pylint/mypy issues
455453

456-
collated = collate_tensor_fn(batch)
457-
else:
458-
collated = default_collate(batch)
454+
collated = collate_tensor_fn(batch)
459455

460456
meta_dicts = [i.meta or TraceKeys.NONE for i in batch]
461457
common_ = set.intersection(*[set(d.keys()) for d in meta_dicts if isinstance(d, dict)])
@@ -494,18 +490,15 @@ def list_data_collate(batch: Sequence):
494490
Need to use this collate if apply some transforms that can generate batch data.
495491
496492
"""
493+
from torch.utils.data._utils.collate import default_collate_fn_map
497494

498-
if pytorch_after(1, 13):
499-
# needs to go here to avoid circular import
500-
from torch.utils.data._utils.collate import default_collate_fn_map
501-
502-
from monai.data.meta_tensor import MetaTensor
495+
from monai.data.meta_tensor import MetaTensor
503496

504-
default_collate_fn_map.update({MetaTensor: collate_meta_tensor_fn})
497+
default_collate_fn_map.update({MetaTensor: collate_meta_tensor_fn})
505498
elem = batch[0]
506499
data = [i for k in batch for i in k] if isinstance(elem, list) else batch
507500
key = None
508-
collate_fn = default_collate if pytorch_after(1, 13) else collate_meta_tensor
501+
collate_fn = default_collate
509502
try:
510503
if config.USE_META_DICT:
511504
data = pickle_operations(data) # bc 0.9.0

0 commit comments

Comments
 (0)