Skip to content

Commit

Permalink
Merge branch 'Project-MONAI:dev' into add-tf32-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
qingpeng9802 authored Jul 25, 2023
2 parents 1516ff6 + 2800a76 commit 7ada18b
Show file tree
Hide file tree
Showing 23 changed files with 1,472 additions and 34 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
environment:
- "PT191+CUDA113"
- "PT110+CUDA113"
- "PT112+CUDA113"
- "PTLATEST+CUDA118"
- "PT113+CUDA113"
- "PTLATEST+CUDA121"
include:
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes
- environment: PT191+CUDA113
Expand All @@ -25,12 +25,12 @@ jobs:
- environment: PT110+CUDA113
pytorch: "torch==1.10.2 torchvision==0.11.3 --extra-index-url https://download.pytorch.org/whl/cu113"
base: "nvcr.io/nvidia/pytorch:21.06-py3" # CUDA 11.3
- environment: PT112+CUDA113
pytorch: "torch==1.12.1 torchvision==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu113"
- environment: PT113+CUDA113
pytorch: "torch==1.13.1 torchvision==0.14.1 --extra-index-url https://download.pytorch.org/whl/cu113"
base: "nvcr.io/nvidia/pytorch:21.06-py3" # CUDA 11.3
- environment: PTLATEST+CUDA118
- environment: PTLATEST+CUDA121
pytorch: "-U torch torchvision --extra-index-url https://download.pytorch.org/whl/cu118"
base: "nvcr.io/nvidia/pytorch:23.03-py3" # CUDA 11.8
base: "nvcr.io/nvidia/pytorch:23.06-py3" # CUDA 12.1
container:
image: ${{ matrix.base }}
options: "--gpus all"
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
if: github.repository == 'Project-MONAI/MONAI'
strategy:
matrix:
container: ["pytorch:22.09", "pytorch:22.11", "pytorch:23.03"]
container: ["pytorch:22.10", "pytorch:23.06"]
container:
image: nvcr.io/nvidia/${{ matrix.container }}-py3 # testing with the latest pytorch base image
options: "--gpus all"
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
if: github.repository == 'Project-MONAI/MONAI'
strategy:
matrix:
container: ["pytorch:22.09", "pytorch:22.11", "pytorch:23.03"]
container: ["pytorch:23.06"]
container:
image: nvcr.io/nvidia/${{ matrix.container }}-py3 # testing with the latest pytorch base image
options: "--gpus all"
Expand Down Expand Up @@ -221,7 +221,7 @@ jobs:
if: github.repository == 'Project-MONAI/MONAI'
needs: cron-gpu # so that monai itself is verified first
container:
image: nvcr.io/nvidia/pytorch:23.03-py3 # testing with the latest pytorch base image
image: nvcr.io/nvidia/pytorch:23.06-py3 # testing with the latest pytorch base image
options: "--gpus all --ipc=host"
runs-on: [self-hosted, linux, x64, integration]
steps:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,11 @@ jobs:
container:
image: docker://projectmonai/monai:latest
options: "--shm-size=4g --ipc=host"
runs-on: ubuntu-latest
runs-on: [self-hosted, linux, X64, docker]
steps:
- name: Import
run: |
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils | tail -n 1)
echo $CUDA_VISIBLE_DEVICES
export CUDA_VISIBLE_DEVICES= # cpu-only
python -c 'import monai; monai.config.print_debug_info()'
cd /opt/monai
ls -al
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pythonapp-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- "PT110+CUDA111"
- "PT112+CUDA118DOCKER"
- "PT113+CUDA116"
- "PT114+CUDA120DOCKER"
- "PT210+CUDA121DOCKER"
include:
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes
- environment: PT19+CUDA114DOCKER
Expand All @@ -42,10 +42,10 @@ jobs:
- environment: PT113+CUDA116
pytorch: "torch==1.13.1 torchvision==0.14.1"
base: "nvcr.io/nvidia/cuda:11.6.1-devel-ubuntu18.04"
- environment: PT114+CUDA120DOCKER
# 23.03: 2.0.0a0+1767026
- environment: PT210+CUDA121DOCKER
# 23.06: 2.1.0a0+4136153
pytorch: "-h" # we explicitly set pytorch to -h to avoid pip install error
base: "nvcr.io/nvidia/pytorch:23.03-py3"
base: "nvcr.io/nvidia/pytorch:23.06-py3"
container:
image: ${{ matrix.base }}
options: --gpus all --env NVIDIA_DISABLE_REQUIRE=true # workaround for unsatisfied condition: cuda>=11.6
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# To build with a different base image
# please run `docker build` using the `--build-arg PYTORCH_IMAGE=...` flag.
ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:23.03-py3
ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:23.06-py3
FROM ${PYTORCH_IMAGE}

LABEL maintainer="[email protected]"
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ itk>=5.2
nibabel
parameterized
scikit-image>=0.19.0
scipy>=1.7.1
tensorboard
commonmark==0.9.1
recommonmark==0.6.0
Expand Down
8 changes: 4 additions & 4 deletions docs/source/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
- [Uninstall the packages](#uninstall-the-packages)
- [From conda-forge](#from-conda-forge)
- [From GitHub](#from-github)
- [Option 1 (as a part of your system-wide module)](#option-1-as-a-part-of-your-system-wide-module)
- [Option 2 (editable installation)](#option-2-editable-installation)
- [Option 1 (as a part of your system-wide module):](#option-1-as-a-part-of-your-system-wide-module)
- [Option 2 (editable installation):](#option-2-editable-installation)
- [Validating the install](#validating-the-install)
- [MONAI version string](#monai-version-string)
- [From DockerHub](#from-dockerhub)
Expand Down Expand Up @@ -254,10 +254,10 @@ Since MONAI v0.2.0, the extras syntax such as `pip install 'monai[nibabel]'` is
- The options are

```
[nibabel, skimage, pillow, tensorboard, gdown, ignite, torchvision, itk, tqdm, lmdb, psutil, cucim, openslide, pandas, einops, transformers, mlflow, clearml, matplotlib, tensorboardX, tifffile, imagecodecs, pyyaml, fire, jsonschema, ninja, pynrrd, pydicom, h5py, nni, optuna, onnx, onnxruntime, zarr]
[nibabel, skimage, scipy, pillow, tensorboard, gdown, ignite, torchvision, itk, tqdm, lmdb, psutil, cucim, openslide, pandas, einops, transformers, mlflow, clearml, matplotlib, tensorboardX, tifffile, imagecodecs, pyyaml, fire, jsonschema, ninja, pynrrd, pydicom, h5py, nni, optuna, onnx, onnxruntime, zarr]
```

which correspond to `nibabel`, `scikit-image`, `pillow`, `tensorboard`,
which correspond to `nibabel`, `scikit-image`, `scipy`, `pillow`, `tensorboard`,
`gdown`, `pytorch-ignite`, `torchvision`, `itk`, `tqdm`, `lmdb`, `psutil`, `cucim`, `openslide-python`, `pandas`, `einops`, `transformers`, `mlflow`, `clearml`, `matplotlib`, `tensorboardX`, `tifffile`, `imagecodecs`, `pyyaml`, `fire`, `jsonschema`, `ninja`, `pynrrd`, `pydicom`, `h5py`, `nni`, `optuna`, `onnx`, `onnxruntime`, and `zarr` respectively.

- `pip install 'monai[all]'` installs all the optional dependencies.
14 changes: 8 additions & 6 deletions monai/apps/auto3dseg/data_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DataAnalyzer:
the DataAnalyzer will skip looking for labels and all label-related operations.
hist_bins: bins to compute histogram for each image channel.
hist_range: ranges to compute histogram for each image channel.
fmt: format used to save the analysis results. Defaults to "yaml".
fmt: format used to save the analysis results. Currently support ``"json"`` and ``"yaml"``, defaults to "yaml".
histogram_only: whether to only compute histograms. Defaults to False.
extra_params: other optional arguments. Currently supported arguments are :
'allowed_shape_difference' (default 5) can be used to change the default tolerance of
Expand Down Expand Up @@ -164,6 +164,7 @@ def _check_data_uniformity(keys: list[str], result: dict) -> bool:
constant_props = [result[DataStatsKeys.SUMMARY][DataStatsKeys.IMAGE_STATS][key] for key in keys]
for prop in constant_props:
if "stdev" in prop and np.any(prop["stdev"]):
logger.debug(f"summary image_stats {prop} has non-zero stdev {prop['stdev']}.")
return False

return True
Expand Down Expand Up @@ -242,15 +243,16 @@ def get_all_case_stats(self, key="training", transform_list=None):
if not self._check_data_uniformity([ImageStatsKeys.SPACING], result):
logger.info("Data spacing is not completely uniform. MONAI transforms may provide unexpected result")
if self.output_path:
logger.info(f"Writing data stats to {self.output_path}.")
ConfigParser.export_config_file(
result, self.output_path, fmt=self.fmt, default_flow_style=None, sort_keys=False
)
by_case_path = self.output_path.replace(f".{self.fmt}", f"_by_case.{self.fmt}")
if by_case_path == self.output_path: # self.output_path not ended with self.fmt?
by_case_path += f".by_case.{self.fmt}"
logger.info(f"Writing by-case data stats to {by_case_path}, this may take a while.")
ConfigParser.export_config_file(
result_bycase,
self.output_path.replace(".yaml", "_by_case.yaml"),
fmt=self.fmt,
default_flow_style=None,
sort_keys=False,
result_bycase, by_case_path, fmt=self.fmt, default_flow_style=None, sort_keys=False
)
# release memory
if self.device.type == "cuda":
Expand Down
4 changes: 2 additions & 2 deletions monai/apps/deepgrow/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ def __call__(self, data):

if np.all(np.less(current_size, self.spatial_size)):
cropper = SpatialCrop(roi_center=center, roi_size=self.spatial_size)
box_start = np.array([s.start for s in cropper.slices]) # type: ignore
box_end = np.array([s.stop for s in cropper.slices]) # type: ignore
box_start = np.array([s.start for s in cropper.slices])
box_end = np.array([s.stop for s in cropper.slices])
else:
cropper = SpatialCrop(roi_start=box_start, roi_end=box_end)

Expand Down
4 changes: 2 additions & 2 deletions monai/bundle/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,12 @@ def export_config_file(cls, config: dict, filepath: PathLike, fmt: str = "json",
"""
_filepath: str = str(Path(filepath))
writer = look_up_option(fmt.lower(), {"json", "yaml"})
writer = look_up_option(fmt.lower(), {"json", "yaml", "yml"})
with open(_filepath, "w") as f:
if writer == "json":
json.dump(config, f, **kwargs)
return
if writer == "yaml":
if writer == "yaml" or writer == "yml":
return yaml.safe_dump(config, f, **kwargs)
raise ValueError(f"only support JSON or YAML config file so far, got {writer}.")

Expand Down
1 change: 1 addition & 0 deletions monai/config/deviceconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def get_optional_config_values():
output["ITK"] = get_package_version("itk")
output["Nibabel"] = get_package_version("nibabel")
output["scikit-image"] = get_package_version("skimage")
output["scipy"] = get_package_version("scipy")
output["Pillow"] = get_package_version("PIL")
output["Tensorboard"] = get_package_version("tensorboard")
output["gdown"] = get_package_version("gdown")
Expand Down
2 changes: 2 additions & 0 deletions monai/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,5 @@ def reduce_meta_tensor(meta_tensor):
return _rebuild_meta, (type(meta_tensor), storage, dtype, metadata)

ForkingPickler.register(MetaTensor, reduce_meta_tensor)

from .ultrasound_confidence_map import UltrasoundConfidenceMap
Loading

0 comments on commit 7ada18b

Please sign in to comment.