Skip to content

Commit 35aca33

Browse files
authored
Merge branch 'dev' into 8085-average-precision
2 parents a9f19c1 + 0a85eed commit 35aca33

33 files changed

+204
-564
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

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/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

monai/inferers/inferer.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,15 +1202,16 @@ def sample( # type: ignore[override]
12021202

12031203
if self.autoencoder_latent_shape is not None:
12041204
latent = torch.stack([self.autoencoder_resizer(i) for i in decollate_batch(latent)], 0)
1205-
latent_intermediates = [
1206-
torch.stack([self.autoencoder_resizer(i) for i in decollate_batch(l)], 0) for l in latent_intermediates
1207-
]
1205+
if save_intermediates:
1206+
latent_intermediates = [
1207+
torch.stack([self.autoencoder_resizer(i) for i in decollate_batch(l)], 0)
1208+
for l in latent_intermediates
1209+
]
12081210

12091211
decode = autoencoder_model.decode_stage_2_outputs
12101212
if isinstance(autoencoder_model, SPADEAutoencoderKL):
12111213
decode = partial(autoencoder_model.decode_stage_2_outputs, seg=seg)
12121214
image = decode(latent / self.scale_factor)
1213-
12141215
if save_intermediates:
12151216
intermediates = []
12161217
for latent_intermediate in latent_intermediates:
@@ -1727,9 +1728,11 @@ def sample( # type: ignore[override]
17271728

17281729
if self.autoencoder_latent_shape is not None:
17291730
latent = torch.stack([self.autoencoder_resizer(i) for i in decollate_batch(latent)], 0)
1730-
latent_intermediates = [
1731-
torch.stack([self.autoencoder_resizer(i) for i in decollate_batch(l)], 0) for l in latent_intermediates
1732-
]
1731+
if save_intermediates:
1732+
latent_intermediates = [
1733+
torch.stack([self.autoencoder_resizer(i) for i in decollate_batch(l)], 0)
1734+
for l in latent_intermediates
1735+
]
17331736

17341737
decode = autoencoder_model.decode_stage_2_outputs
17351738
if isinstance(autoencoder_model, SPADEAutoencoderKL):

monai/inferers/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
fall_back_tuple,
3232
look_up_option,
3333
optional_import,
34-
pytorch_after,
3534
)
3635

3736
tqdm, _ = optional_import("tqdm", name="tqdm")
38-
_nearest_mode = "nearest-exact" if pytorch_after(1, 11) else "nearest"
37+
_nearest_mode = "nearest-exact"
3938

4039
__all__ = ["sliding_window_inference"]
4140

0 commit comments

Comments
 (0)