Skip to content

Commit f040ec0

Browse files
Nic-Mamonai-botwyli
committed
5269 5291 Update PyTorch base docker to 22.09 (#5293)
Fixes #5269 #5291 . ### Description This PR updated the PyTorch base docker to 22.09. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: Nic Ma <[email protected]> Signed-off-by: monai-bot <[email protected]> Signed-off-by: Wenqi Li <[email protected]> Co-authored-by: monai-bot <[email protected]> Co-authored-by: Wenqi Li <[email protected]>
1 parent 9fa35cc commit f040ec0

File tree

10 files changed

+78
-20
lines changed

10 files changed

+78
-20
lines changed

.github/workflows/cron.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
if: github.repository == 'Project-MONAI/MONAI'
6363
strategy:
6464
matrix:
65-
container: ["pytorch:21.02", "pytorch:21.10", "pytorch:22.08"] # 21.02, 21.10 for backward comp.
65+
container: ["pytorch:21.02", "pytorch:21.10", "pytorch:22.09"] # 21.02, 21.10 for backward comp.
6666
container:
6767
image: nvcr.io/nvidia/${{ matrix.container }}-py3 # testing with the latest pytorch base image
6868
options: "--gpus all"
@@ -106,7 +106,7 @@ jobs:
106106
if: github.repository == 'Project-MONAI/MONAI'
107107
strategy:
108108
matrix:
109-
container: ["pytorch:21.02", "pytorch:21.10", "pytorch:22.08"] # 21.02, 21.10 for backward comp.
109+
container: ["pytorch:21.02", "pytorch:21.10", "pytorch:22.09"] # 21.02, 21.10 for backward comp.
110110
container:
111111
image: nvcr.io/nvidia/${{ matrix.container }}-py3 # testing with the latest pytorch base image
112112
options: "--gpus all"
@@ -204,7 +204,7 @@ jobs:
204204
if: github.repository == 'Project-MONAI/MONAI'
205205
needs: cron-gpu # so that monai itself is verified first
206206
container:
207-
image: nvcr.io/nvidia/pytorch:22.08-py3 # testing with the latest pytorch base image
207+
image: nvcr.io/nvidia/pytorch:22.09-py3 # testing with the latest pytorch base image
208208
options: "--gpus all --ipc=host"
209209
runs-on: [self-hosted, linux, x64, common]
210210
steps:

.github/workflows/pythonapp-gpu.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ jobs:
4545
# 21.10: 1.10.0a0+0aef44c
4646
pytorch: "-h"
4747
base: "nvcr.io/nvidia/pytorch:21.10-py3"
48-
- environment: PT112+CUDA117
48+
- environment: PT112+CUDA118
4949
# we explicitly set pytorch to -h to avoid pip install error
50-
# 22.08: 1.13.0a0+d321be6
50+
# 22.09: 1.13.0a0+d0d6b1f
5151
pytorch: "-h"
52-
base: "nvcr.io/nvidia/pytorch:22.08-py3"
52+
base: "nvcr.io/nvidia/pytorch:22.09-py3"
5353
- environment: PT110+CUDA102
5454
pytorch: "torch==1.10.2 torchvision==0.11.3"
5555
base: "nvcr.io/nvidia/cuda:10.2-devel-ubuntu18.04"
@@ -64,7 +64,7 @@ jobs:
6464
- uses: actions/checkout@v3
6565
- name: apt install
6666
run: |
67-
# workaround for https://github.com/Project-MONAI/MONAI/issues/4200
67+
# FIXME: workaround for https://github.com/Project-MONAI/MONAI/issues/4200
6868
apt-key del 7fa2af80 && rm -rf /etc/apt/sources.list.d/nvidia-ml.list /etc/apt/sources.list.d/cuda.list
6969
apt-get update
7070
apt-get install -y wget

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# To build with a different base image
1313
# please run `docker build` using the `--build-arg PYTORCH_IMAGE=...` flag.
14-
ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:22.08-py3
14+
ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:22.09-py3
1515
FROM ${PYTORCH_IMAGE}
1616

1717
LABEL maintainer="[email protected]"

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ pydicom
3333
h5py
3434
nni
3535
optuna
36+
opencv-python-headless

docs/source/apps.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ Applications
191191
`Reconstruction`
192192
----------------
193193

194+
FastMRIReader
195+
~~~~~~~~~~~~~
196+
.. autoclass:: monai.apps.reconstruction.fastmri_reader.FastMRIReader
197+
:members:
198+
194199
`ConvertToTensorComplex`
195200
~~~~~~~~~~~~~~~~~~~~~~~~
196201
.. autofunction:: monai.apps.reconstruction.complex_utils.convert_to_tensor_complex

docs/source/data.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,6 @@ PILReader
153153
:members:
154154

155155

156-
FastMRIReader
157-
~~~~~~~~~~~~~
158-
.. autoclass:: monai.apps.reconstruction.fastmri_reader.FastMRIReader
159-
:members:
160-
161-
162156
Image writer
163157
------------
164158

@@ -352,12 +346,12 @@ Video datasets
352346

353347
VideoDataset
354348
~~~~~~~~~~~~
355-
.. autoclass:: monai.data.VideoDataset
349+
.. autoclass:: monai.data.video_dataset.VideoDataset
356350

357351
VideoFileDataset
358352
~~~~~~~~~~~~~~~~
359-
.. autoclass:: monai.data.VideoFileDataset
353+
.. autoclass:: monai.data.video_dataset.VideoFileDataset
360354

361355
CameraDataset
362356
~~~~~~~~~~~~~
363-
.. autoclass:: monai.data.CameraDataset
357+
.. autoclass:: monai.data.video_dataset.CameraDataset

monai/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,17 @@
3939

4040
# handlers_* have some external decorators the users may not have installed
4141
# *.so files and folder "_C" may not exist when the cpp extensions are not compiled
42-
excludes = "(^(monai.handlers))|(^(monai.bundle))|(^(monai.fl))|((\\.so)$)|(^(monai._C))|(.*(__main__)$)"
42+
excludes = "|".join(
43+
[
44+
"(^(monai.handlers))",
45+
"(^(monai.bundle))",
46+
"(^(monai.fl))",
47+
"((\\.so)$)",
48+
"(^(monai._C))",
49+
"(.*(__main__)$)",
50+
"(.*(video_dataset)$)",
51+
]
52+
)
4353

4454
# load directory modules only, skip loading individual files
4555
load_submodules(sys.modules[__name__], False, exclude_pattern=excludes)

monai/data/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@
106106
worker_init_fn,
107107
zoom_affine,
108108
)
109-
from .video_dataset import CameraDataset, VideoDataset, VideoFileDataset
109+
110+
# FIXME: workaround for https://github.com/Project-MONAI/MONAI/issues/5291
111+
# from .video_dataset import CameraDataset, VideoDataset, VideoFileDataset
110112
from .wsi_datasets import MaskedPatchWSIDataset, PatchWSIDataset, SlidingPatchWSIDataset
111113
from .wsi_reader import BaseWSIReader, CuCIMWSIReader, OpenSlideWSIReader, TiffFileWSIReader, WSIReader
112114

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _enter_pr_4800(self):
2929
return self
3030

3131

32-
# workaround for https://bugs.python.org/issue29620
32+
# FIXME: workaround for https://bugs.python.org/issue29620
3333
try:
3434
# Suppression for issue #494: tests/__init__.py:34: error: Cannot assign to a method
3535
unittest.case._AssertWarnsContext.__enter__ = _enter_pr_4800 # type: ignore

tests/test_cv2_dist.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (c) MONAI Consortium
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
12+
import unittest
13+
14+
import torch
15+
import torch.distributed as dist
16+
from torch.cuda.amp import autocast
17+
18+
# FIXME: test for the workaround of https://github.com/Project-MONAI/MONAI/issues/5291
19+
from monai.config.deviceconfig import print_config
20+
from tests.utils import skip_if_no_cuda
21+
22+
23+
def main_worker(rank, ngpus_per_node):
24+
dist.init_process_group(backend="nccl", init_method="tcp://127.0.0.1:12345", world_size=ngpus_per_node, rank=rank)
25+
# `benchmark = True` is not compatible with openCV in PyTorch 22.09 docker for multi-gpu training
26+
torch.backends.cudnn.benchmark = True
27+
28+
model = torch.nn.Conv3d(in_channels=1, out_channels=32, kernel_size=3, bias=True).to(rank)
29+
model = torch.nn.parallel.DistributedDataParallel(
30+
model, device_ids=[rank], output_device=rank, find_unused_parameters=False
31+
)
32+
x = torch.ones(1, 1, 192, 192, 192).to(rank)
33+
with autocast(enabled=True):
34+
model(x)
35+
36+
37+
@skip_if_no_cuda
38+
class TestCV2Dist(unittest.TestCase):
39+
def test_cv2_cuda_ops(self):
40+
print_config()
41+
ngpus_per_node = torch.cuda.device_count()
42+
torch.multiprocessing.spawn(main_worker, nprocs=ngpus_per_node, args=(ngpus_per_node,))
43+
44+
45+
if __name__ == "__main__":
46+
unittest.main()

0 commit comments

Comments
 (0)