Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Packager to make the MAP more secure, easier to use, and based on new version of PyTorch image for newer CUDA versions. #381

Merged
merged 9 commits into from Nov 3, 2022
4 changes: 2 additions & 2 deletions docs/requirements.txt
@@ -1,7 +1,7 @@
Sphinx==4.1.2
sphinx-autobuild==2021.3.14
myst-parser==0.15.2
numpy>=1.21.2 # CVE-2021-33430
numpy>=1.21.6
matplotlib==3.3.4
ipywidgets==7.6.4
pandas==1.1.5
Expand All @@ -23,7 +23,7 @@ scikit-image>=0.17.2
plotly
nibabel>=3.2.1
monai>=1.0.0
torch>=1.10.0
torch>=1.12.0
numpy-stl>=2.12.0
trimesh>=3.8.11
pydicom
Expand Down
2 changes: 1 addition & 1 deletion docs/source/developing_with_sdk/packaging_app.md
Expand Up @@ -46,7 +46,7 @@ However, the user can choose to override these values by invoking these optional
* `--requirements, -r <FILE_PATH>`: Optional path to requirements.txt containing package dependencies of the application
* `--log-level, -l <LEVEL>`: Set the logging level (`"DEBUG"`, `"INFO"`, `"WARN"`, `"ERROR"`, or `"CRITICAL"`).

* `--base <BASE_IMAGE>`: Base Docker Image (overrides default `"nvcr.io/nvidia/pytorch:21.07-py3"`).
* `--base <BASE_IMAGE>`: Base Docker Image (overrides default `"nvcr.io/nvidia/pytorch:22.08-py3"`).
* `--input-dir, -i <INPUT_DIR>`: Directory mounted in container for Application Input (overrides default `"input"`).
* `--models-dir <MODELS_DIR>`: Directory mounted in container for Models Path (overrides default `"/opt/monai/models"`).
* `--output-dir, -o <OUTPUT_DIR>`: Directory mounted in container for Application Output (overrides default `"output"`).
Expand Down
4 changes: 2 additions & 2 deletions docs/source/getting_started/installing_app_sdk.md
Expand Up @@ -19,12 +19,12 @@ For packaging your application, [MONAI Application Packager](/developing_with_sd

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

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

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

```bash
docker pull nvcr.io/nvidia/pytorch:21.07-py3
docker pull nvcr.io/nvidia/pytorch:22.08-py3
```

:::
Expand Down
4 changes: 2 additions & 2 deletions examples/apps/ai_pancrea_seg_app/__main__.py
@@ -1,4 +1,4 @@
from app import AISpleenSegApp
from app import AIPancreasSegApp

if __name__ == "__main__":
AISpleenSegApp(do_run=True)
AIPancreasSegApp(do_run=True)
2 changes: 1 addition & 1 deletion examples/apps/simple_imaging_app/gaussian_operator.py
Expand Up @@ -29,7 +29,7 @@ def compute(self, op_input: InputContext, op_output: OutputContext, context: Exe
from skimage.io import imsave

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

output_folder = op_output.get().path
output_path = output_folder / "final_output.png"
Expand Down
2 changes: 1 addition & 1 deletion monai/deploy/packager/constants.py
Expand Up @@ -16,7 +16,7 @@ class DefaultValues:
"""

DOCKER_FILE_NAME = "dockerfile"
BASE_IMAGE = "nvcr.io/nvidia/pytorch:21.07-py3"
BASE_IMAGE = "nvcr.io/nvidia/pytorch:22.08-py3"
DOCKERFILE_TYPE = "pytorch"
WORK_DIR = "/var/monai/"
INPUT_DIR = "input"
Expand Down
6 changes: 4 additions & 2 deletions monai/deploy/packager/templates.py
@@ -1,4 +1,4 @@
# Copyright 2021 MONAI Consortium
# Copyright 2021-2022 MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -12,7 +12,7 @@
COMMON_FOOTPRINT = """
USER root

RUN pip install --no-cache-dir --upgrade setuptools==57.4.0 pip==21.3.1 wheel==0.37.0 numpy>=1.21
RUN pip install --no-cache-dir --upgrade setuptools==59.5.0 pip==22.3 wheel==0.37.1 numpy>=1.21.6

RUN mkdir -p /etc/monai/ \\
&& mkdir -p /opt/monai/ \\
Expand Down Expand Up @@ -72,6 +72,7 @@
ENV MONAI_WORKDIR={working_dir}
ENV MONAI_APPLICATION={app_dir}
ENV MONAI_TIMEOUT={timeout}
ENV MONAI_MODELPATH={models_dir}

RUN apt update \\
&& apt upgrade -y --no-install-recommends \\
Expand Down Expand Up @@ -106,6 +107,7 @@
ENV MONAI_WORKDIR={working_dir}
ENV MONAI_APPLICATION={app_dir}
ENV MONAI_TIMEOUT={timeout}
ENV MONAI_MODELPATH={models_dir}

RUN apt update \\
&& apt upgrade -y --no-install-recommends \\
Expand Down
5 changes: 4 additions & 1 deletion monai/deploy/packager/util.py
Expand Up @@ -17,6 +17,7 @@
import sys
import tempfile
from argparse import Namespace
from pathlib import Path
from typing import Dict

from monai.deploy.exceptions import WrongValueError
Expand Down Expand Up @@ -177,7 +178,9 @@ def build_image(args: dict, temp_dir: str):
requirements_file.write(line)
else:
requirements_file.writelines("\n".join(pip_packages))
map_requirements_path = "/tmp/requirements.txt"

# Parameter for the Dockerfile for copying content to internal path
map_requirements_path = str(Path(app_dir) / "requirements.txt")

# Copy model files to temp directory (under 'model' folder)
target_models_path = os.path.join(temp_dir, "models")
Expand Down
167 changes: 68 additions & 99 deletions notebooks/tutorials/01_simple_app.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion notebooks/tutorials/03_segmentation_app.ipynb
Expand Up @@ -1646,7 +1646,7 @@
}
],
"source": [
"!monai-deploy package -b nvcr.io/nvidia/pytorch:21.11-py3 my_app --tag my_app:latest -m model.ts"
"!monai-deploy package -b nvcr.io/nvidia/pytorch:22.08-py3 my_app --tag my_app:latest -m model.ts"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/tutorials/06_monai_bundle_app.ipynb
Expand Up @@ -1337,7 +1337,7 @@
}
],
"source": [
"!monai-deploy package -b nvcr.io/nvidia/pytorch:21.11-py3 my_app --tag my_app:latest -m model.ts"
"!monai-deploy package -b nvcr.io/nvidia/pytorch:22.08-py3 my_app --tag my_app:latest -m model.ts"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Expand Up @@ -35,4 +35,4 @@ scikit-image>=0.17.2
nibabel>=3.2.1
numpy-stl>=2.12.0
trimesh>=3.8.11
torch>=1.10.0
torch>=1.12.0
2 changes: 1 addition & 1 deletion requirements-examples.txt
Expand Up @@ -9,5 +9,5 @@ trimesh>=3.8.11
nibabel>=3.2.1
numpy-stl>=2.12.0
trimesh>=3.8.11
torch>=1.10.0
torch>=1.12.0
monai>=1.0.0
2 changes: 1 addition & 1 deletion requirements-min.txt
@@ -1,5 +1,5 @@
# Requirements for minimal tests
-r requirements.txt
setuptools>=50.3.0
setuptools>=59.5.0
coverage>=5.5
parameterized
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,4 +1,4 @@
numpy>=1.21.2
numpy>=1.21.6
networkx>=2.4
colorama>=0.4.1
typeguard>=2.12.1
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -23,7 +23,7 @@ python_requires = >= 3.7
# setup_requires =
# cucim
install_requires =
numpy>=1.21.2 # CVE-2021-33430
numpy>=1.21.6
networkx>=2.4
colorama>=0.4.1
typeguard>=2.12.1
Expand Down