Skip to content

Commit 9113c93

Browse files
authored
Enhance Packager to make the MAP more secure, easier to use, and based on new version of PyTorch image for newer CUDA versions. (#381)
* Update the default base image to 22.08 version Signed-off-by: M Q <mingmelvinq@nvidia.com> * Remove unused file path contain "/tmp/" which caused security warning Signed-off-by: M Q <mingmelvinq@nvidia.com> * Add env var and remove /tmp is packager, update dependent package min version Signed-off-by: M Q <mingmelvinq@nvidia.com> * Update the Gaussian due to new param introduced in sciki-image 0.19 Signed-off-by: M Q <mingmelvinq@nvidia.com> * Formatting fix Signed-off-by: M Q <mingmelvinq@nvidia.com> * Fix simple_app Jupyter notebook imshow failure with the new scikit-image Signed-off-by: M Q <mingmelvinq@nvidia.com> * Keep Numpy at 1.21.6 for Python 3.7 support Signed-off-by: M Q <mingmelvinq@nvidia.com> * Fix Flake8 error Signed-off-by: M Q <mingmelvinq@nvidia.com> * For Python 3.7 compatibility Signed-off-by: M Q <mingmelvinq@nvidia.com> Signed-off-by: M Q <mingmelvinq@nvidia.com>
1 parent 3fdf163 commit 9113c93

File tree

16 files changed

+92
-118
lines changed

16 files changed

+92
-118
lines changed

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Sphinx==4.1.2
22
sphinx-autobuild==2021.3.14
33
myst-parser==0.15.2
4-
numpy>=1.21.2 # CVE-2021-33430
4+
numpy>=1.21.6
55
matplotlib==3.3.4
66
ipywidgets==7.6.4
77
pandas==1.1.5
@@ -23,7 +23,7 @@ scikit-image>=0.17.2
2323
plotly
2424
nibabel>=3.2.1
2525
monai>=1.0.0
26-
torch>=1.10.0
26+
torch>=1.12.0
2727
numpy-stl>=2.12.0
2828
trimesh>=3.8.11
2929
pydicom

docs/source/developing_with_sdk/packaging_app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ However, the user can choose to override these values by invoking these optional
4646
* `--requirements, -r <FILE_PATH>`: Optional path to requirements.txt containing package dependencies of the application
4747
* `--log-level, -l <LEVEL>`: Set the logging level (`"DEBUG"`, `"INFO"`, `"WARN"`, `"ERROR"`, or `"CRITICAL"`).
4848

49-
* `--base <BASE_IMAGE>`: Base Docker Image (overrides default `"nvcr.io/nvidia/pytorch:21.07-py3"`).
49+
* `--base <BASE_IMAGE>`: Base Docker Image (overrides default `"nvcr.io/nvidia/pytorch:22.08-py3"`).
5050
* `--input-dir, -i <INPUT_DIR>`: Directory mounted in container for Application Input (overrides default `"input"`).
5151
* `--models-dir <MODELS_DIR>`: Directory mounted in container for Models Path (overrides default `"/opt/monai/models"`).
5252
* `--output-dir, -o <OUTPUT_DIR>`: Directory mounted in container for Application Output (overrides default `"output"`).

docs/source/getting_started/installing_app_sdk.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ For packaging your application, [MONAI Application Packager](/developing_with_sd
1919

2020
<https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker>
2121

22-
Currently, `nvcr.io/nvidia/pytorch:21.07-py3` base Docker image is used by [MONAI Application Packager](/developing_with_sdk/packaging_app) by default.
22+
Currently, `nvcr.io/nvidia/pytorch:22.08-py3` base Docker image is used by [MONAI Application Packager](/developing_with_sdk/packaging_app) by default.
2323

2424
The image size is large so please pull the image in advance to save time.
2525

2626
```bash
27-
docker pull nvcr.io/nvidia/pytorch:21.07-py3
27+
docker pull nvcr.io/nvidia/pytorch:22.08-py3
2828
```
2929

3030
:::
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from app import AISpleenSegApp
1+
from app import AIPancreasSegApp
22

33
if __name__ == "__main__":
4-
AISpleenSegApp(do_run=True)
4+
AIPancreasSegApp(do_run=True)

examples/apps/simple_imaging_app/gaussian_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def compute(self, op_input: InputContext, op_output: OutputContext, context: Exe
2929
from skimage.io import imsave
3030

3131
data_in = op_input.get().asnumpy()
32-
data_out = gaussian(data_in, sigma=0.2)
32+
data_out = gaussian(data_in, sigma=0.2, channel_axis=2) # Add the param introduced in 0.19.
3333

3434
output_folder = op_output.get().path
3535
output_path = output_folder / "final_output.png"

monai/deploy/packager/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DefaultValues:
1616
"""
1717

1818
DOCKER_FILE_NAME = "dockerfile"
19-
BASE_IMAGE = "nvcr.io/nvidia/pytorch:21.07-py3"
19+
BASE_IMAGE = "nvcr.io/nvidia/pytorch:22.08-py3"
2020
DOCKERFILE_TYPE = "pytorch"
2121
WORK_DIR = "/var/monai/"
2222
INPUT_DIR = "input"

monai/deploy/packager/templates.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 MONAI Consortium
1+
# Copyright 2021-2022 MONAI Consortium
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -12,7 +12,7 @@
1212
COMMON_FOOTPRINT = """
1313
USER root
1414
15-
RUN pip install --no-cache-dir --upgrade setuptools==57.4.0 pip==21.3.1 wheel==0.37.0 numpy>=1.21
15+
RUN pip install --no-cache-dir --upgrade setuptools==59.5.0 pip==22.3 wheel==0.37.1 numpy>=1.21.6
1616
1717
RUN mkdir -p /etc/monai/ \\
1818
&& mkdir -p /opt/monai/ \\
@@ -72,6 +72,7 @@
7272
ENV MONAI_WORKDIR={working_dir}
7373
ENV MONAI_APPLICATION={app_dir}
7474
ENV MONAI_TIMEOUT={timeout}
75+
ENV MONAI_MODELPATH={models_dir}
7576
7677
RUN apt update \\
7778
&& apt upgrade -y --no-install-recommends \\
@@ -106,6 +107,7 @@
106107
ENV MONAI_WORKDIR={working_dir}
107108
ENV MONAI_APPLICATION={app_dir}
108109
ENV MONAI_TIMEOUT={timeout}
110+
ENV MONAI_MODELPATH={models_dir}
109111
110112
RUN apt update \\
111113
&& apt upgrade -y --no-install-recommends \\

monai/deploy/packager/util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import sys
1818
import tempfile
1919
from argparse import Namespace
20+
from pathlib import Path
2021
from typing import Dict
2122

2223
from monai.deploy.exceptions import WrongValueError
@@ -177,7 +178,9 @@ def build_image(args: dict, temp_dir: str):
177178
requirements_file.write(line)
178179
else:
179180
requirements_file.writelines("\n".join(pip_packages))
180-
map_requirements_path = "/tmp/requirements.txt"
181+
182+
# Parameter for the Dockerfile for copying content to internal path
183+
map_requirements_path = str(Path(app_dir) / "requirements.txt")
181184

182185
# Copy model files to temp directory (under 'model' folder)
183186
target_models_path = os.path.join(temp_dir, "models")

notebooks/tutorials/01_simple_app.ipynb

Lines changed: 68 additions & 99 deletions
Large diffs are not rendered by default.

notebooks/tutorials/03_segmentation_app.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@
16461646
}
16471647
],
16481648
"source": [
1649-
"!monai-deploy package -b nvcr.io/nvidia/pytorch:21.11-py3 my_app --tag my_app:latest -m model.ts"
1649+
"!monai-deploy package -b nvcr.io/nvidia/pytorch:22.08-py3 my_app --tag my_app:latest -m model.ts"
16501650
]
16511651
},
16521652
{

notebooks/tutorials/06_monai_bundle_app.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@
13371337
}
13381338
],
13391339
"source": [
1340-
"!monai-deploy package -b nvcr.io/nvidia/pytorch:21.11-py3 my_app --tag my_app:latest -m model.ts"
1340+
"!monai-deploy package -b nvcr.io/nvidia/pytorch:22.08-py3 my_app --tag my_app:latest -m model.ts"
13411341
]
13421342
},
13431343
{

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ scikit-image>=0.17.2
3535
nibabel>=3.2.1
3636
numpy-stl>=2.12.0
3737
trimesh>=3.8.11
38-
torch>=1.10.0
38+
torch>=1.12.0

requirements-examples.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ trimesh>=3.8.11
99
nibabel>=3.2.1
1010
numpy-stl>=2.12.0
1111
trimesh>=3.8.11
12-
torch>=1.10.0
12+
torch>=1.12.0
1313
monai>=1.0.0

requirements-min.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Requirements for minimal tests
22
-r requirements.txt
3-
setuptools>=50.3.0
3+
setuptools>=59.5.0
44
coverage>=5.5
55
parameterized

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
numpy>=1.21.2
1+
numpy>=1.21.6
22
networkx>=2.4
33
colorama>=0.4.1
44
typeguard>=2.12.1

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ python_requires = >= 3.7
2323
# setup_requires =
2424
# cucim
2525
install_requires =
26-
numpy>=1.21.2 # CVE-2021-33430
26+
numpy>=1.21.6
2727
networkx>=2.4
2828
colorama>=0.4.1
2929
typeguard>=2.12.1

0 commit comments

Comments
 (0)