From fdb5436304b0a68b6b7f541c3effc568cda6755f Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 21 Sep 2026 16:48:03 +0100 Subject: [PATCH 1/9] Add Explicit hash_type Arguments Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- 2d_classification/mednist_tutorial.ipynb | 4 ++-- 3d_classification/densenet_training_array.ipynb | 4 ++-- 3d_regression/densenet_training_array.ipynb | 2 +- 3d_segmentation/spleen_segmentation_3d.ipynb | 4 ++-- 3d_segmentation/spleen_segmentation_3d_lightning.ipynb | 4 ++-- .../spleen_segmentation_3d_visualization_basic.ipynb | 2 +- acceleration/TensorRT_inference_acceleration.ipynb | 4 ++-- acceleration/automatic_mixed_precision.ipynb | 2 +- acceleration/dataset_type_performance.ipynb | 4 ++-- acceleration/fast_training_tutorial.ipynb | 2 +- bundle/05_spleen_segmentation_lightning.ipynb | 8 ++++---- bundle/further_features.md | 2 +- .../pythonic_usage_guidance/pythonic_bundle_access.ipynb | 4 ++-- .../endoscopic_inbody_classification.ipynb | 5 +++-- deployment/bentoml/mednist_classifier_bentoml.ipynb | 4 ++-- experiment_management/bundle_integrate_mlflow.ipynb | 4 ++-- experiment_management/spleen_segmentation_aim.ipynb | 2 +- experiment_management/spleen_segmentation_mlflow.ipynb | 2 +- .../client/non_ensemble/client.ipynb | 4 ++-- generation/maisi/maisi_train_vae_tutorial.ipynb | 6 +++--- .../finetune_vista3d_for_hugging_face_pipeline.ipynb | 4 ++-- hugging_face/hugging_face_pipeline_for_monai.ipynb | 4 ++-- modules/3d_image_transforms.ipynb | 4 ++-- modules/autoencoder_mednist.ipynb | 4 ++-- modules/csv_datasets.ipynb | 4 ++-- modules/engines/gan_training.py | 2 +- modules/integrate_3rd_party_transforms.ipynb | 4 ++-- modules/interpretability/cats_and_dogs.ipynb | 2 +- modules/interpretability/covid_classification.ipynb | 2 +- modules/lazy_resampling_benchmark.ipynb | 4 ++-- modules/mednist_GAN_tutorial.ipynb | 4 ++-- modules/mednist_GAN_workflow_array.ipynb | 4 ++-- modules/mednist_GAN_workflow_dict.ipynb | 4 ++-- modules/postprocessing_transforms.ipynb | 4 ++-- modules/public_datasets.ipynb | 4 ++-- modules/transform_visualization.ipynb | 4 ++-- modules/transforms_demo_2d.ipynb | 4 ++-- modules/varautoencoder_mednist.ipynb | 4 ++-- performance_profiling/radiology/train_base_nvtx.py | 2 +- performance_profiling/radiology/train_fast_nvtx.py | 2 +- vista_3d/vista3d_spleen_finetune.ipynb | 4 ++-- 41 files changed, 74 insertions(+), 73 deletions(-) diff --git a/2d_classification/mednist_tutorial.ipynb b/2d_classification/mednist_tutorial.ipynb index 43b854e085..a375063d34 100644 --- a/2d_classification/mednist_tutorial.ipynb +++ b/2d_classification/mednist_tutorial.ipynb @@ -182,7 +182,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": { "tags": [] }, @@ -194,7 +194,7 @@ "compressed_file = os.path.join(root_dir, \"MedNIST.tar.gz\")\n", "data_dir = os.path.join(root_dir, \"MedNIST\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/3d_classification/densenet_training_array.ipynb b/3d_classification/densenet_training_array.ipynb index 2863cd92a0..019ac063e8 100644 --- a/3d_classification/densenet_training_array.ipynb +++ b/3d_classification/densenet_training_array.ipynb @@ -178,7 +178,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -206,7 +206,7 @@ " dataset_dir = os.path.join(root_dir, \"ixi\")\n", " tarfile_name = f\"{dataset_dir}.tar\"\n", "\n", - " download_and_extract(resource, tarfile_name, dataset_dir, md5)" + " download_and_extract(resource, tarfile_name, dataset_dir, md5, \"md5\")" ] }, { diff --git a/3d_regression/densenet_training_array.ipynb b/3d_regression/densenet_training_array.ipynb index b9bc311060..26194d9227 100644 --- a/3d_regression/densenet_training_array.ipynb +++ b/3d_regression/densenet_training_array.ipynb @@ -211,7 +211,7 @@ " dataset_dir = os.path.join(root_dir, \"ixi\")\n", " tarfile_name = f\"{dataset_dir}.tar\"\n", "\n", - " download_and_extract(resource, tarfile_name, dataset_dir, md5)" + " download_and_extract(resource, tarfile_name, dataset_dir, md5, \"md5\")" ] }, { diff --git a/3d_segmentation/spleen_segmentation_3d.ipynb b/3d_segmentation/spleen_segmentation_3d.ipynb index c931724682..a6f0ef2199 100644 --- a/3d_segmentation/spleen_segmentation_3d.ipynb +++ b/3d_segmentation/spleen_segmentation_3d.ipynb @@ -198,7 +198,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { "tags": [] }, @@ -210,7 +210,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/3d_segmentation/spleen_segmentation_3d_lightning.ipynb b/3d_segmentation/spleen_segmentation_3d_lightning.ipynb index d6459cfbbc..c53332504f 100644 --- a/3d_segmentation/spleen_segmentation_3d_lightning.ipynb +++ b/3d_segmentation/spleen_segmentation_3d_lightning.ipynb @@ -194,7 +194,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": { "tags": [] }, @@ -206,7 +206,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/3d_segmentation/spleen_segmentation_3d_visualization_basic.ipynb b/3d_segmentation/spleen_segmentation_3d_visualization_basic.ipynb index f7ec118cb3..9fb74c0616 100644 --- a/3d_segmentation/spleen_segmentation_3d_visualization_basic.ipynb +++ b/3d_segmentation/spleen_segmentation_3d_visualization_basic.ipynb @@ -230,7 +230,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/acceleration/TensorRT_inference_acceleration.ipynb b/acceleration/TensorRT_inference_acceleration.ipynb index 35439faafa..bffadbf4e4 100644 --- a/acceleration/TensorRT_inference_acceleration.ipynb +++ b/acceleration/TensorRT_inference_acceleration.ipynb @@ -129,7 +129,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -169,7 +169,7 @@ "compressed_file = os.path.join(root_dir, \"endoscopic_tool_dataset.zip\")\n", "data_root = os.path.join(root_dir, \"endoscopic_tool_dataset\")\n", "if not os.path.exists(data_root):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/acceleration/automatic_mixed_precision.ipynb b/acceleration/automatic_mixed_precision.ipynb index dbeddcc7a8..b3b8f34c97 100644 --- a/acceleration/automatic_mixed_precision.ipynb +++ b/acceleration/automatic_mixed_precision.ipynb @@ -145,7 +145,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_root = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_root):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/acceleration/dataset_type_performance.ipynb b/acceleration/dataset_type_performance.ipynb index f8c2911c59..5982a3f6df 100644 --- a/acceleration/dataset_type_performance.ipynb +++ b/acceleration/dataset_type_performance.ipynb @@ -299,7 +299,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "tags": [] }, @@ -311,7 +311,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/acceleration/fast_training_tutorial.ipynb b/acceleration/fast_training_tutorial.ipynb index 85b197231b..4719ac61e0 100644 --- a/acceleration/fast_training_tutorial.ipynb +++ b/acceleration/fast_training_tutorial.ipynb @@ -252,7 +252,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_root = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_root):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/bundle/05_spleen_segmentation_lightning.ipynb b/bundle/05_spleen_segmentation_lightning.ipynb index 43cc966f82..0ea16ac29a 100644 --- a/bundle/05_spleen_segmentation_lightning.ipynb +++ b/bundle/05_spleen_segmentation_lightning.ipynb @@ -158,7 +158,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "672f0168-950a-440e-b77c-f785a92c0f74", "metadata": { "ExecuteTime": { @@ -218,7 +218,7 @@ "os.environ[\"DATA_DIR\"] = data_dir\n", "\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { @@ -1124,7 +1124,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "monai", "language": "python", "name": "python3" }, @@ -1138,7 +1138,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.10.20" } }, "nbformat": 4, diff --git a/bundle/further_features.md b/bundle/further_features.md index 65c3f0e431..95d21653f9 100644 --- a/bundle/further_features.md +++ b/bundle/further_features.md @@ -47,7 +47,7 @@ root_dir = tempfile.mkdtemp() if directory is None else directory compressed_file = os.path.join(root_dir, "Task09_Spleen.tar") data_dir = os.path.join(root_dir, "Task09_Spleen") if not os.path.exists(data_dir): - download_and_extract(resource, compressed_file, root_dir, md5) + download_and_extract(resource, compressed_file, root_dir, md5, "md5") ``` ## Define train config - Set imports and input / output environments diff --git a/bundle/pythonic_usage_guidance/pythonic_bundle_access.ipynb b/bundle/pythonic_usage_guidance/pythonic_bundle_access.ipynb index 84535100c7..5bff4d19b5 100644 --- a/bundle/pythonic_usage_guidance/pythonic_bundle_access.ipynb +++ b/bundle/pythonic_usage_guidance/pythonic_bundle_access.ipynb @@ -124,7 +124,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -134,7 +134,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/computer_assisted_intervention/endoscopic_inbody_classification.ipynb b/computer_assisted_intervention/endoscopic_inbody_classification.ipynb index fb97c7f474..9726edff86 100644 --- a/computer_assisted_intervention/endoscopic_inbody_classification.ipynb +++ b/computer_assisted_intervention/endoscopic_inbody_classification.ipynb @@ -36,6 +36,7 @@ "execution_count": 1, "id": "5f9e4066", "metadata": {}, + "outputs": [], "source": [ "!python -c \"import monai\" || pip install -q \"monai-weekly[pillow, ignite, tqdm]\"\n", "!python -c \"import matplotlib\" || pip install -q matplotlib\n", @@ -141,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "495b1db7", "metadata": {}, "outputs": [ @@ -159,7 +160,7 @@ "set_url = r\"https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/inbody_outbody_samples.zip\"\n", "md5_hash = r\"cce8f3beb1fb2e8fc2429e073c927489\"\n", "compress_filename = r\"inbody_outbody_samples.zip\"\n", - "download_and_extract(set_url, compress_filename, endo_dir, md5_hash)" + "download_and_extract(set_url, compress_filename, endo_dir, md5_hash, \"md5\")" ] }, { diff --git a/deployment/bentoml/mednist_classifier_bentoml.ipynb b/deployment/bentoml/mednist_classifier_bentoml.ipynb index 14f0b271a2..256a8f5fb4 100644 --- a/deployment/bentoml/mednist_classifier_bentoml.ipynb +++ b/deployment/bentoml/mednist_classifier_bentoml.ipynb @@ -174,7 +174,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": { "tags": [] }, @@ -186,7 +186,7 @@ "compressed_file = os.path.join(root_dir, \"MedNIST.tar.gz\")\n", "data_dir = os.path.join(root_dir, \"MedNIST\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/experiment_management/bundle_integrate_mlflow.ipynb b/experiment_management/bundle_integrate_mlflow.ipynb index c3cc2d4b92..74095e21a0 100644 --- a/experiment_management/bundle_integrate_mlflow.ipynb +++ b/experiment_management/bundle_integrate_mlflow.ipynb @@ -107,7 +107,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -126,7 +126,7 @@ "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "print(data_dir)\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/experiment_management/spleen_segmentation_aim.ipynb b/experiment_management/spleen_segmentation_aim.ipynb index f5da6a9e93..38a1dce859 100644 --- a/experiment_management/spleen_segmentation_aim.ipynb +++ b/experiment_management/spleen_segmentation_aim.ipynb @@ -146,7 +146,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource_link, compressed_file, root_dir, md5)" + " download_and_extract(resource_link, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/experiment_management/spleen_segmentation_mlflow.ipynb b/experiment_management/spleen_segmentation_mlflow.ipynb index 0f11b2a004..a948185c0b 100644 --- a/experiment_management/spleen_segmentation_mlflow.ipynb +++ b/experiment_management/spleen_segmentation_mlflow.ipynb @@ -146,7 +146,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/full_gpu_inference_pipeline/client/non_ensemble/client.ipynb b/full_gpu_inference_pipeline/client/non_ensemble/client.ipynb index 65a93c6675..38c65c6b01 100644 --- a/full_gpu_inference_pipeline/client/non_ensemble/client.ipynb +++ b/full_gpu_inference_pipeline/client/non_ensemble/client.ipynb @@ -119,7 +119,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -159,7 +159,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/generation/maisi/maisi_train_vae_tutorial.ipynb b/generation/maisi/maisi_train_vae_tutorial.ipynb index 58358d9f8e..23f8108323 100644 --- a/generation/maisi/maisi_train_vae_tutorial.ipynb +++ b/generation/maisi/maisi_train_vae_tutorial.ipynb @@ -179,7 +179,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "ec6f0c29-1989-45c6-bd64-35682533794b", "metadata": {}, "outputs": [], @@ -191,7 +191,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_path_1 = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_path_1):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)\n", + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")\n", "\n", "# Only include 20 of the images for quick demo purpose\n", "train_images_1 = sorted(glob.glob(os.path.join(data_path_1, \"imagesTr\", \"*.nii.gz\")))[:20]\n", @@ -206,7 +206,7 @@ "compressed_file = os.path.join(root_dir, \"Task01_BrainTumour.tar\")\n", "data_path_2 = os.path.join(root_dir, \"Task01_BrainTumour\")\n", "if not os.path.exists(data_path_2):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)\n", + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")\n", "\n", "# Only include 30 of the images for quick demo purpose\n", "train_images_2 = sorted(glob.glob(os.path.join(data_path_2, \"imagesTr\", \"*.nii.gz\")))[:30]\n", diff --git a/hugging_face/finetune_vista3d_for_hugging_face_pipeline.ipynb b/hugging_face/finetune_vista3d_for_hugging_face_pipeline.ipynb index 908d7985b8..b75c8a3161 100644 --- a/hugging_face/finetune_vista3d_for_hugging_face_pipeline.ipynb +++ b/hugging_face/finetune_vista3d_for_hugging_face_pipeline.ipynb @@ -164,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { "tags": [] }, @@ -176,7 +176,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/hugging_face/hugging_face_pipeline_for_monai.ipynb b/hugging_face/hugging_face_pipeline_for_monai.ipynb index 36d09e8a99..f1a2c59bf1 100644 --- a/hugging_face/hugging_face_pipeline_for_monai.ipynb +++ b/hugging_face/hugging_face_pipeline_for_monai.ipynb @@ -176,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -186,7 +186,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/modules/3d_image_transforms.ipynb b/modules/3d_image_transforms.ipynb index 9d55f995c1..a8ae5ce1ba 100644 --- a/modules/3d_image_transforms.ipynb +++ b/modules/3d_image_transforms.ipynb @@ -118,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "tags": [] }, @@ -130,7 +130,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/modules/autoencoder_mednist.ipynb b/modules/autoencoder_mednist.ipynb index 7b32779f60..39065929b7 100644 --- a/modules/autoencoder_mednist.ipynb +++ b/modules/autoencoder_mednist.ipynb @@ -163,7 +163,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "tags": [] }, @@ -175,7 +175,7 @@ "compressed_file = os.path.join(root_dir, \"MedNIST.tar.gz\")\n", "data_dir = os.path.join(root_dir, \"MedNIST\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/modules/csv_datasets.ipynb b/modules/csv_datasets.ipynb index 3e4b46e5b5..7eb99050e5 100644 --- a/modules/csv_datasets.ipynb +++ b/modules/csv_datasets.ipynb @@ -128,7 +128,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": { "tags": [] }, @@ -140,7 +140,7 @@ "compressed_file = os.path.join(root_dir, \"MedNIST.tar.gz\")\n", "data_dir = os.path.join(root_dir, \"MedNIST\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/modules/engines/gan_training.py b/modules/engines/gan_training.py index c0d941b90f..a8917c60bc 100644 --- a/modules/engines/gan_training.py +++ b/modules/engines/gan_training.py @@ -61,7 +61,7 @@ def main(): md5_value = "0bc7306e7427e00ad1c5526a6677552d" extract_dir = "data" tar_save_path = os.path.join(extract_dir, "MedNIST.tar.gz") - download_and_extract(mednist_url, tar_save_path, extract_dir, md5_value) + download_and_extract(mednist_url, tar_save_path, extract_dir, md5_value, "md5") hand_dir = os.path.join(extract_dir, "MedNIST", "Hand") real_data = [{"hand": os.path.join(hand_dir, filename)} for filename in os.listdir(hand_dir)] diff --git a/modules/integrate_3rd_party_transforms.ipynb b/modules/integrate_3rd_party_transforms.ipynb index 191efb283a..6819271d9d 100644 --- a/modules/integrate_3rd_party_transforms.ipynb +++ b/modules/integrate_3rd_party_transforms.ipynb @@ -142,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { "tags": [] }, @@ -154,7 +154,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/modules/interpretability/cats_and_dogs.ipynb b/modules/interpretability/cats_and_dogs.ipynb index 53b625b9b8..af210540d2 100644 --- a/modules/interpretability/cats_and_dogs.ipynb +++ b/modules/interpretability/cats_and_dogs.ipynb @@ -147,7 +147,7 @@ " + \"3E1C3F21-ECDB-4869-8368-6DEBA77B919F/kagglecatsanddogs_5340.zip\"\n", " )\n", " md5 = \"e137a4507370d942469b6d267a24ea04\"\n", - " download_and_extract(url, output_dir=data_path, hash_val=md5)" + " download_and_extract(url, output_dir=data_path, hash_val=md5, hash_type=\"md5\")" ] }, { diff --git a/modules/interpretability/covid_classification.ipynb b/modules/interpretability/covid_classification.ipynb index 17586b8926..655c5e1256 100644 --- a/modules/interpretability/covid_classification.ipynb +++ b/modules/interpretability/covid_classification.ipynb @@ -139,7 +139,7 @@ "train_md5 = \"3e8d3e6ca43903ead0666eb6ec8849d8\"\n", "train_zip = os.path.join(root_dir, \"covid_train.zip\")\n", "train_dir = os.path.join(root_dir, \"covid\")\n", - "download_and_extract(train_url, train_zip, train_dir, train_md5)" + "download_and_extract(train_url, train_zip, train_dir, train_md5, \"md5\")" ] }, { diff --git a/modules/lazy_resampling_benchmark.ipynb b/modules/lazy_resampling_benchmark.ipynb index 4c677945a0..c59199ac04 100644 --- a/modules/lazy_resampling_benchmark.ipynb +++ b/modules/lazy_resampling_benchmark.ipynb @@ -131,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "4255c4b0", "metadata": {}, "outputs": [], @@ -151,7 +151,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/modules/mednist_GAN_tutorial.ipynb b/modules/mednist_GAN_tutorial.ipynb index 50a108b440..01bb2b7ed5 100644 --- a/modules/mednist_GAN_tutorial.ipynb +++ b/modules/mednist_GAN_tutorial.ipynb @@ -189,7 +189,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -199,7 +199,7 @@ "compressed_file = os.path.join(root_dir, \"MedNIST.tar.gz\")\n", "data_dir = os.path.join(root_dir, \"MedNIST\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)\n", + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")\n", "\n", "hands = [os.path.join(data_dir, \"Hand\", x) for x in os.listdir(os.path.join(data_dir, \"Hand\"))]" ] diff --git a/modules/mednist_GAN_workflow_array.ipynb b/modules/mednist_GAN_workflow_array.ipynb index c3db4d8cea..1fc2ace1fe 100644 --- a/modules/mednist_GAN_workflow_array.ipynb +++ b/modules/mednist_GAN_workflow_array.ipynb @@ -162,7 +162,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": { "tags": [] }, @@ -174,7 +174,7 @@ "compressed_file = os.path.join(root_dir, \"MedNIST.tar.gz\")\n", "data_dir = os.path.join(root_dir, \"MedNIST\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)\n", + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")\n", "\n", "hands = [os.path.join(data_dir, \"Hand\", x) for x in os.listdir(os.path.join(data_dir, \"Hand\"))]" ] diff --git a/modules/mednist_GAN_workflow_dict.ipynb b/modules/mednist_GAN_workflow_dict.ipynb index 1842617580..c2c121f409 100644 --- a/modules/mednist_GAN_workflow_dict.ipynb +++ b/modules/mednist_GAN_workflow_dict.ipynb @@ -161,7 +161,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": { "tags": [] }, @@ -173,7 +173,7 @@ "compressed_file = os.path.join(root_dir, \"MedNIST.tar.gz\")\n", "data_dir = os.path.join(root_dir, \"MedNIST\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/modules/postprocessing_transforms.ipynb b/modules/postprocessing_transforms.ipynb index f3db627edc..633f3c22bb 100644 --- a/modules/postprocessing_transforms.ipynb +++ b/modules/postprocessing_transforms.ipynb @@ -189,7 +189,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "tags": [] }, @@ -201,7 +201,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/modules/public_datasets.ipynb b/modules/public_datasets.ipynb index 25ecf5f59d..d1cfbc93b0 100644 --- a/modules/public_datasets.ipynb +++ b/modules/public_datasets.ipynb @@ -590,7 +590,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -620,7 +620,7 @@ " dataset_dir = os.path.join(root_dir, \"ixi\")\n", " tarfile_name = f\"{dataset_dir}.tar\"\n", " if download:\n", - " download_and_extract(self.resource, tarfile_name, dataset_dir, self.md5)\n", + " download_and_extract(self.resource, tarfile_name, dataset_dir, self.md5, \"md5\")\n", " # as a quick demo, we just use 10 images to show\n", "\n", " self.datalist = [\n", diff --git a/modules/transform_visualization.ipynb b/modules/transform_visualization.ipynb index 90e0632494..9b6cc8fcda 100644 --- a/modules/transform_visualization.ipynb +++ b/modules/transform_visualization.ipynb @@ -138,7 +138,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { "tags": [] }, @@ -150,7 +150,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/modules/transforms_demo_2d.ipynb b/modules/transforms_demo_2d.ipynb index d7a408d243..59fe93f3b2 100644 --- a/modules/transforms_demo_2d.ipynb +++ b/modules/transforms_demo_2d.ipynb @@ -166,7 +166,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "tags": [] }, @@ -203,7 +203,7 @@ "compressed_file = os.path.join(root_dir, \"warwick_qu_dataset_released_2016_07_08.zip\")\n", "data_dir = os.path.join(root_dir, \"Warwick QU Dataset (Released 2016_07_08)\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/modules/varautoencoder_mednist.ipynb b/modules/varautoencoder_mednist.ipynb index e2454cea32..fa2a6a9ba4 100644 --- a/modules/varautoencoder_mednist.ipynb +++ b/modules/varautoencoder_mednist.ipynb @@ -212,7 +212,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "tags": [] }, @@ -224,7 +224,7 @@ "\n", " compressed_file = os.path.join(root_dir, \"MedNIST.tar.gz\")\n", " if not os.path.exists(mednist_folder):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { diff --git a/performance_profiling/radiology/train_base_nvtx.py b/performance_profiling/radiology/train_base_nvtx.py index ff54fbb7ff..b5e5b43eb0 100644 --- a/performance_profiling/radiology/train_base_nvtx.py +++ b/performance_profiling/radiology/train_base_nvtx.py @@ -59,7 +59,7 @@ compressed_file = os.path.join(root_dir, "Task09_Spleen.tar") data_root = os.path.join(root_dir, "Task09_Spleen") if not os.path.exists(data_root): - download_and_extract(resource, compressed_file, root_dir, md5) + download_and_extract(resource, compressed_file, root_dir, md5, "md5") out_dir = "./outputs_base" diff --git a/performance_profiling/radiology/train_fast_nvtx.py b/performance_profiling/radiology/train_fast_nvtx.py index 029e192c56..aad4aef225 100644 --- a/performance_profiling/radiology/train_fast_nvtx.py +++ b/performance_profiling/radiology/train_fast_nvtx.py @@ -63,7 +63,7 @@ compressed_file = os.path.join(root_dir, "Task09_Spleen.tar") data_root = os.path.join(root_dir, "Task09_Spleen") if not os.path.exists(data_root): - download_and_extract(resource, compressed_file, root_dir, md5) + download_and_extract(resource, compressed_file, root_dir, md5, "md5") out_dir = "./outputs_fast" diff --git a/vista_3d/vista3d_spleen_finetune.ipynb b/vista_3d/vista3d_spleen_finetune.ipynb index a8564ce16a..f6617ea30e 100644 --- a/vista_3d/vista3d_spleen_finetune.ipynb +++ b/vista_3d/vista3d_spleen_finetune.ipynb @@ -155,7 +155,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": { "tags": [] }, @@ -167,7 +167,7 @@ "compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n", "data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n", "if not os.path.exists(data_dir):\n", - " download_and_extract(resource, compressed_file, root_dir, md5)" + " download_and_extract(resource, compressed_file, root_dir, md5, \"md5\")" ] }, { From 6f0f3dce55406a21368a43a364a316e4108e6b31 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 21 Sep 2026 18:11:48 +0100 Subject: [PATCH 2/9] Adjusting device selection to account for no CUDA Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- 2d_classification/monai_201.ipynb | 17 +++++++++-------- 2d_registration/registration_mednist.ipynb | 2 +- .../learn2reg_nlst_paired_lung_ct.ipynb | 6 +++--- 3d_segmentation/brats_segmentation_3d.ipynb | 4 ++-- 3d_segmentation/spleen_segmentation_3d.ipynb | 4 ++-- .../spleen_segmentation_3d_lightning.ipynb | 4 ++-- .../unet_segmentation_3d_ignite.ipynb | 4 ++-- acceleration/automatic_mixed_precision.ipynb | 2 +- acceleration/dataset_type_performance.ipynb | 4 ++-- acceleration/threadbuffer_performance.ipynb | 2 +- acceleration/transform_speed.ipynb | 14 ++++++++------ deep_atlas/deep_atlas_tutorial.ipynb | 4 ++-- .../bentoml/mednist_classifier_bentoml.ipynb | 4 ++-- .../spleen_segmentation_aim.ipynb | 2 +- .../spleen_segmentation_mlflow.ipynb | 2 +- .../unet_segmentation_3d_ignite_clearml.ipynb | 2 +- .../2d_sd_super_resolution_lightning.ipynb | 8 ++++---- .../hugging_face_pipeline_for_monai.ipynb | 5 +++-- ...multichannel_microscopy_classification.ipynb | 4 ++-- modules/cross_validation_models_ensemble.ipynb | 4 ++-- modules/decollate_batch.ipynb | 2 +- modules/jupyter_utils.ipynb | 4 ++-- modules/mednist_GAN_tutorial.ipynb | 4 ++-- modules/mednist_GAN_workflow_array.ipynb | 4 ++-- modules/mednist_GAN_workflow_dict.ipynb | 4 ++-- modules/postprocessing_transforms.ipynb | 4 ++-- modules/public_datasets.ipynb | 8 ++++---- modules/tcia_dataset.ipynb | 2 +- modules/workflow_profiling.ipynb | 8 ++++---- pathology/hovernet/hovernet_torch.ipynb | 4 ++-- .../vit_unetr_ssl/ssl_train.ipynb | 2 +- vista_3d/vista3d_spleen_finetune.ipynb | 4 ++-- 32 files changed, 76 insertions(+), 72 deletions(-) diff --git a/2d_classification/monai_201.ipynb b/2d_classification/monai_201.ipynb index 832ba7d486..42630f8601 100644 --- a/2d_classification/monai_201.ipynb +++ b/2d_classification/monai_201.ipynb @@ -188,19 +188,20 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "max_epochs = 5\n", "save_interval = 2\n", "out_dir = \"./eval\"\n", - "model = densenet121(spatial_dims=2, in_channels=1, out_channels=6).to(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", + "model = densenet121(spatial_dims=2, in_channels=1, out_channels=6).to(device)\n", "\n", "logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n", "\n", "evaluator = SupervisedEvaluator(\n", - " device=torch.device(\"cuda:0\"),\n", + " device=device,\n", " val_data_loader=DataLoader(valdata, batch_size=512, shuffle=False, num_workers=4),\n", " network=model,\n", " inferer=SimpleInferer(),\n", @@ -209,7 +210,7 @@ ")\n", "\n", "trainer = SupervisedTrainer(\n", - " device=torch.device(\"cuda:0\"),\n", + " device=device,\n", " max_epochs=max_epochs,\n", " train_data_loader=DataLoader(dataset, batch_size=512, shuffle=True, num_workers=4),\n", " network=model,\n", @@ -297,7 +298,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -313,7 +314,7 @@ ], "source": [ "evaluator = SupervisedEvaluator(\n", - " device=torch.device(\"cuda:0\"),\n", + " device=device,\n", " val_data_loader=DataLoader(testdata, batch_size=1, num_workers=0),\n", " network=model,\n", " inferer=SimpleInferer(),\n", @@ -371,7 +372,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "monai", "language": "python", "name": "python3" }, @@ -385,7 +386,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.10.20" } }, "nbformat": 4, diff --git a/2d_registration/registration_mednist.ipynb b/2d_registration/registration_mednist.ipynb index 18f3dedf93..6fa7adcc17 100644 --- a/2d_registration/registration_mednist.ipynb +++ b/2d_registration/registration_mednist.ipynb @@ -376,7 +376,7 @@ } ], "source": [ - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "model = GlobalNet(\n", " image_size=(64, 64), spatial_dims=2, in_channels=2, num_channel_initial=16, depth=3 # moving and fixed\n", ").to(device)\n", diff --git a/3d_registration/learn2reg_nlst_paired_lung_ct.ipynb b/3d_registration/learn2reg_nlst_paired_lung_ct.ipynb index 69d49a9894..d72671034c 100644 --- a/3d_registration/learn2reg_nlst_paired_lung_ct.ipynb +++ b/3d_registration/learn2reg_nlst_paired_lung_ct.ipynb @@ -242,7 +242,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "edea2f2b", "metadata": {}, "outputs": [], @@ -592,13 +592,13 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "9315e271", "metadata": {}, "outputs": [], "source": [ "# device, optimizer, epoch and batch settings\n", - "device = \"cuda:0\"\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "batch_size = 4\n", "lr = 1e-4\n", "weight_decay = 1e-5\n", diff --git a/3d_segmentation/brats_segmentation_3d.ipynb b/3d_segmentation/brats_segmentation_3d.ipynb index ad52c737e7..6531d776e0 100644 --- a/3d_segmentation/brats_segmentation_3d.ipynb +++ b/3d_segmentation/brats_segmentation_3d.ipynb @@ -433,7 +433,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -442,7 +442,7 @@ "VAL_AMP = True\n", "\n", "# standard PyTorch program style: create SegResNet, DiceLoss and Adam optimizer\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "model = SegResNet(\n", " blocks_down=[1, 2, 2, 4],\n", " blocks_up=[1, 1, 1],\n", diff --git a/3d_segmentation/spleen_segmentation_3d.ipynb b/3d_segmentation/spleen_segmentation_3d.ipynb index a6f0ef2199..dd9e10ce74 100644 --- a/3d_segmentation/spleen_segmentation_3d.ipynb +++ b/3d_segmentation/spleen_segmentation_3d.ipynb @@ -427,12 +427,12 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# standard PyTorch program style: create UNet, DiceLoss and Adam optimizer\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "model = UNet(\n", " spatial_dims=3,\n", " in_channels=1,\n", diff --git a/3d_segmentation/spleen_segmentation_3d_lightning.ipynb b/3d_segmentation/spleen_segmentation_3d_lightning.ipynb index c53332504f..5124425046 100644 --- a/3d_segmentation/spleen_segmentation_3d_lightning.ipynb +++ b/3d_segmentation/spleen_segmentation_3d_lightning.ipynb @@ -532,7 +532,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": { "jupyter": { "outputs_hidden": true @@ -652,7 +652,7 @@ ], "source": [ "net.eval()\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "net.to(device)\n", "with torch.no_grad():\n", " for i, val_data in enumerate(net.val_dataloader()):\n", diff --git a/3d_segmentation/unet_segmentation_3d_ignite.ipynb b/3d_segmentation/unet_segmentation_3d_ignite.ipynb index dc870bf965..858ec22ecc 100644 --- a/3d_segmentation/unet_segmentation_3d_ignite.ipynb +++ b/3d_segmentation/unet_segmentation_3d_ignite.ipynb @@ -258,12 +258,12 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create UNet, DiceLoss and Adam optimizer\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "net = UNet(\n", " spatial_dims=3,\n", " in_channels=1,\n", diff --git a/acceleration/automatic_mixed_precision.ipynb b/acceleration/automatic_mixed_precision.ipynb index b3b8f34c97..8bfcb5212e 100644 --- a/acceleration/automatic_mixed_precision.ipynb +++ b/acceleration/automatic_mixed_precision.ipynb @@ -277,7 +277,7 @@ " num_workers=1,\n", " )\n", " val_loader = DataLoader(val_ds, batch_size=1, num_workers=1)\n", - " device = torch.device(\"cuda:0\")\n", + " device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", " model = UNet(\n", " spatial_dims=3,\n", " in_channels=1,\n", diff --git a/acceleration/dataset_type_performance.ipynb b/acceleration/dataset_type_performance.ipynb index 5982a3f6df..1c946ac4ba 100644 --- a/acceleration/dataset_type_performance.ipynb +++ b/acceleration/dataset_type_performance.ipynb @@ -142,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -156,7 +156,7 @@ " num_workers=8,\n", " )\n", " val_loader = DataLoader(val_ds, batch_size=1, num_workers=4)\n", - " device = torch.device(\"cuda:0\")\n", + " device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", " model = UNet(\n", " spatial_dims=3,\n", " in_channels=1,\n", diff --git a/acceleration/threadbuffer_performance.ipynb b/acceleration/threadbuffer_performance.ipynb index 9e127bbd64..10d4251f74 100644 --- a/acceleration/threadbuffer_performance.ipynb +++ b/acceleration/threadbuffer_performance.ipynb @@ -120,7 +120,7 @@ "metadata": {}, "outputs": [], "source": [ - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "net = UNet(2, 1, 1, (8, 16, 32), (2, 2), num_res_units=2).to(device)\n", "loss_function = Dice(sigmoid=True)\n", "optimizer = torch.optim.Adam(net.parameters(), 1e-5)\n", diff --git a/acceleration/transform_speed.ipynb b/acceleration/transform_speed.ipynb index e4b61e29e4..55c0e00a5a 100644 --- a/acceleration/transform_speed.ipynb +++ b/acceleration/transform_speed.ipynb @@ -308,7 +308,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": { "tags": [] }, @@ -325,6 +325,8 @@ "images = sorted(glob.glob(os.path.join(root_dir, \"im*.nii.gz\")))\n", "segs = sorted(glob.glob(os.path.join(root_dir, \"seg*.nii.gz\")))\n", "\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", + "\n", "# same parameter with different interpolation mode for image and segmentation\n", "rand_affine_img = RandAffine(\n", " prob=1.0,\n", @@ -332,7 +334,7 @@ " translate_range=(96, 96, 96),\n", " spatial_size=(64, 64, 64),\n", " mode=\"bilinear\",\n", - " device=torch.device(\"cuda:0\"),\n", + " device=device,\n", ")\n", "rand_affine_seg = RandAffine(\n", " prob=1.0,\n", @@ -340,7 +342,7 @@ " translate_range=(96, 96, 96),\n", " spatial_size=(64, 64, 64),\n", " mode=\"nearest\",\n", - " device=torch.device(\"cuda:0\"),\n", + " device=device,\n", ")\n", "\n", "imtrans = Compose([LoadImage(image_only=True), ScaleIntensity(), EnsureChannelFirst(), rand_affine_img])\n", @@ -435,7 +437,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -458,7 +460,7 @@ " spatial_size=(64, 64, 64),\n", " mode=3,\n", " padding_mode=\"reflect\",\n", - " device=torch.device(\"cuda:0\"),\n", + " device=device,\n", ")\n", "rand_affine_seg = RandAffine(\n", " prob=1.0,\n", @@ -467,7 +469,7 @@ " spatial_size=(64, 64, 64),\n", " mode=0,\n", " padding_mode=\"reflect\",\n", - " device=torch.device(\"cuda:0\"),\n", + " device=device,\n", ")\n", "\n", "imtrans = Compose([LoadImage(image_only=True), ScaleIntensity(), EnsureChannelFirst(), rand_affine_img])\n", diff --git a/deep_atlas/deep_atlas_tutorial.ipynb b/deep_atlas/deep_atlas_tutorial.ipynb index 799a85fd35..d77ca01378 100644 --- a/deep_atlas/deep_atlas_tutorial.ipynb +++ b/deep_atlas/deep_atlas_tutorial.ipynb @@ -424,12 +424,12 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "a98e74bd", "metadata": {}, "outputs": [], "source": [ - "device = torch.device(\"cuda:0\")" + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")" ] }, { diff --git a/deployment/bentoml/mednist_classifier_bentoml.ipynb b/deployment/bentoml/mednist_classifier_bentoml.ipynb index 256a8f5fb4..75e57aff5b 100644 --- a/deployment/bentoml/mednist_classifier_bentoml.ipynb +++ b/deployment/bentoml/mednist_classifier_bentoml.ipynb @@ -275,13 +275,13 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "net = DenseNet121(spatial_dims=2, in_channels=1, out_channels=len(class_names)).to(device)\n", "loss_function = torch.nn.CrossEntropyLoss()\n", "opt = torch.optim.Adam(net.parameters(), 1e-5)\n", diff --git a/experiment_management/spleen_segmentation_aim.ipynb b/experiment_management/spleen_segmentation_aim.ipynb index 38a1dce859..8a79f98c55 100644 --- a/experiment_management/spleen_segmentation_aim.ipynb +++ b/experiment_management/spleen_segmentation_aim.ipynb @@ -407,7 +407,7 @@ "outputs": [], "source": [ "# standard PyTorch program style: create UNet, DiceLoss and Adam optimizer\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "model = UNet(**UNet_metadata).to(device)\n", "loss_function = DiceLoss(to_onehot_y=True, softmax=True)\n", "loss_type = \"DiceLoss\"\n", diff --git a/experiment_management/spleen_segmentation_mlflow.ipynb b/experiment_management/spleen_segmentation_mlflow.ipynb index a948185c0b..3201962ad8 100644 --- a/experiment_management/spleen_segmentation_mlflow.ipynb +++ b/experiment_management/spleen_segmentation_mlflow.ipynb @@ -392,7 +392,7 @@ "outputs": [], "source": [ "# standard PyTorch program style: create UNet, DiceLoss and Adam optimizer\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "\n", "# easily save all model arguments\n", "UNet_metadata = {\n", diff --git a/experiment_management/unet_segmentation_3d_ignite_clearml.ipynb b/experiment_management/unet_segmentation_3d_ignite_clearml.ipynb index a454086fdd..09c3cc1aee 100644 --- a/experiment_management/unet_segmentation_3d_ignite_clearml.ipynb +++ b/experiment_management/unet_segmentation_3d_ignite_clearml.ipynb @@ -274,7 +274,7 @@ "source": [ "# Create UNet, DiceLoss and Adam optimizer\n", "\n", - "device = None # torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "net = UNet(\n", " spatial_dims=3,\n", " in_channels=1,\n", diff --git a/generation/2d_super_resolution/2d_sd_super_resolution_lightning.ipynb b/generation/2d_super_resolution/2d_sd_super_resolution_lightning.ipynb index 817efe233c..2f0dec68d6 100644 --- a/generation/2d_super_resolution/2d_sd_super_resolution_lightning.ipynb +++ b/generation/2d_super_resolution/2d_sd_super_resolution_lightning.ipynb @@ -680,7 +680,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "ccb6ba9f", "metadata": {}, "outputs": [ @@ -695,7 +695,7 @@ "source": [ "def get_scale_factor():\n", " ae_net.eval()\n", - " device = torch.device(\"cuda:0\")\n", + " device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", " ae_net.to(device)\n", "\n", " train_loader = ae_net.train_dataloader()\n", @@ -1176,7 +1176,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "id": "155be091", "metadata": {}, "outputs": [ @@ -1201,7 +1201,7 @@ "\n", "def get_images_to_plot():\n", " d_net.eval()\n", - " device = torch.device(\"cuda:0\")\n", + " device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", " d_net.to(device)\n", "\n", " val_loader = d_net.val_dataloader()\n", diff --git a/hugging_face/hugging_face_pipeline_for_monai.ipynb b/hugging_face/hugging_face_pipeline_for_monai.ipynb index f1a2c59bf1..6e07748f64 100644 --- a/hugging_face/hugging_face_pipeline_for_monai.ipynb +++ b/hugging_face/hugging_face_pipeline_for_monai.ipynb @@ -475,7 +475,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -523,10 +523,11 @@ "download(\"spleen_ct_segmentation\", bundle_dir=bundle_dir, progress=False)\n", "weight_dir = os.path.join(bundle_dir, \"spleen_ct_segmentation/models/model.pt\")\n", "\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "config = MONAIUNetConfig()\n", "monai_unet = MONAIUNet(config)\n", "monai_unet.unet.load_state_dict(torch.load(weight_dir, weights_only=True))\n", - "pipeline = SpleenCTSegmentationPipeline(model=monai_unet, device=torch.device(\"cuda:0\"), save_output=False)\n", + "pipeline = SpleenCTSegmentationPipeline(model=monai_unet, device=device, save_output=False)\n", "\n", "numpy_transform = ToNumpy()\n", "loader = LoadImage()\n", diff --git a/microscopy/multichannel_microscopy_classification.ipynb b/microscopy/multichannel_microscopy_classification.ipynb index 527e37bdc9..8ed190172c 100644 --- a/microscopy/multichannel_microscopy_classification.ipynb +++ b/microscopy/multichannel_microscopy_classification.ipynb @@ -786,12 +786,12 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "id": "97ba2753", "metadata": {}, "outputs": [], "source": [ - "device = \"cuda:0\"\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "model = DenseNet169(spatial_dims=2, in_channels=6, out_channels=num_classes, pretrained=True)\n", "# Note: In the DenseNet169 constructor, the parameter in_channels=6 already adds a\n", "# 6-channel input layer to the network and connects it to the following\n", diff --git a/modules/cross_validation_models_ensemble.ipynb b/modules/cross_validation_models_ensemble.ipynb index 057a612c9c..ea68dbaaab 100644 --- a/modules/cross_validation_models_ensemble.ipynb +++ b/modules/cross_validation_models_ensemble.ipynb @@ -154,13 +154,13 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "set_determinism(seed=0)\n", "logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n", - "device = torch.device(\"cuda:0\")" + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")" ] }, { diff --git a/modules/decollate_batch.ipynb b/modules/decollate_batch.ipynb index c0e4c36401..7fc2df1536 100644 --- a/modules/decollate_batch.ipynb +++ b/modules/decollate_batch.ipynb @@ -164,7 +164,7 @@ "source": [ "set_determinism(seed=0)\n", "logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n", - "device = torch.device(\"cuda:0\")" + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")" ] }, { diff --git a/modules/jupyter_utils.ipynb b/modules/jupyter_utils.ipynb index c677ec407f..4234632cc3 100644 --- a/modules/jupyter_utils.ipynb +++ b/modules/jupyter_utils.ipynb @@ -118,12 +118,12 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create UNet, DiceLoss and Adam optimizer\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "net = UNet(spatial_dims=2, in_channels=1, out_channels=1, channels=(8, 16, 32), strides=(2, 2)).to(device)\n", "\n", "lossfn = DiceLoss(sigmoid=True)\n", diff --git a/modules/mednist_GAN_tutorial.ipynb b/modules/mednist_GAN_tutorial.ipynb index 01bb2b7ed5..c4fda8045e 100644 --- a/modules/mednist_GAN_tutorial.ipynb +++ b/modules/mednist_GAN_tutorial.ipynb @@ -257,11 +257,11 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "disc_net = Discriminator(\n", " in_shape=(1, 64, 64),\n", " channels=(8, 16, 32, 64, 1),\n", diff --git a/modules/mednist_GAN_workflow_array.ipynb b/modules/mednist_GAN_workflow_array.ipynb index 1fc2ace1fe..61fedf0862 100644 --- a/modules/mednist_GAN_workflow_array.ipynb +++ b/modules/mednist_GAN_workflow_array.ipynb @@ -208,13 +208,13 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n", "set_determinism(0)\n", - "device = torch.device(\"cuda:0\")" + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")" ] }, { diff --git a/modules/mednist_GAN_workflow_dict.ipynb b/modules/mednist_GAN_workflow_dict.ipynb index c2c121f409..06caf320c3 100644 --- a/modules/mednist_GAN_workflow_dict.ipynb +++ b/modules/mednist_GAN_workflow_dict.ipynb @@ -215,13 +215,13 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n", "set_determinism(0)\n", - "device = torch.device(\"cuda:0\")" + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")" ] }, { diff --git a/modules/postprocessing_transforms.ipynb b/modules/postprocessing_transforms.ipynb index 633f3c22bb..d0ff574ceb 100644 --- a/modules/postprocessing_transforms.ipynb +++ b/modules/postprocessing_transforms.ipynb @@ -348,12 +348,12 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# standard PyTorch program style: create UNet, DiceLoss and Adam optimizer\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "model = UNet(\n", " spatial_dims=3,\n", " in_channels=1,\n", diff --git a/modules/public_datasets.ipynb b/modules/public_datasets.ipynb index d1cfbc93b0..721277804a 100644 --- a/modules/public_datasets.ipynb +++ b/modules/public_datasets.ipynb @@ -312,11 +312,11 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "net = DenseNet121(spatial_dims=2, in_channels=1, out_channels=6).to(device)\n", "loss = torch.nn.CrossEntropyLoss()\n", "opt = torch.optim.Adam(net.parameters(), 1e-5)" @@ -501,11 +501,11 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "net = UNet(\n", " spatial_dims=3,\n", " in_channels=1,\n", diff --git a/modules/tcia_dataset.ipynb b/modules/tcia_dataset.ipynb index 09a8a51aed..a1c7d17a08 100644 --- a/modules/tcia_dataset.ipynb +++ b/modules/tcia_dataset.ipynb @@ -703,7 +703,7 @@ "outputs": [], "source": [ "# standard PyTorch program style: create UNet, DiceLoss and Adam optimizer\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "model = UNet(\n", " spatial_dims=3,\n", " in_channels=1,\n", diff --git a/modules/workflow_profiling.ipynb b/modules/workflow_profiling.ipynb index 01c9140b7b..b464b8af7c 100644 --- a/modules/workflow_profiling.ipynb +++ b/modules/workflow_profiling.ipynb @@ -753,7 +753,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "490387f9-d59b-4862-8174-63591341114d", "metadata": {}, "outputs": [ @@ -962,7 +962,7 @@ } ], "source": [ - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "net = UNet(\n", " spatial_dims=3,\n", " in_channels=1,\n", @@ -1026,7 +1026,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "85374f79-9a56-4981-9507-f00ee16ca7b4", "metadata": {}, "outputs": [ @@ -1310,7 +1310,7 @@ "from monai.engines import SupervisedTrainer # noqa\n", "from ignite.engine import Events # noqa\n", "\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "net = UNet(\n", " spatial_dims=3,\n", " in_channels=1,\n", diff --git a/pathology/hovernet/hovernet_torch.ipynb b/pathology/hovernet/hovernet_torch.ipynb index 23f9172166..600966b80c 100644 --- a/pathology/hovernet/hovernet_torch.ipynb +++ b/pathology/hovernet/hovernet_torch.ipynb @@ -504,7 +504,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -519,7 +519,7 @@ ], "source": [ "stage = 0\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "\n", "\n", "def create_model(stage, device):\n", diff --git a/self_supervised_pretraining/vit_unetr_ssl/ssl_train.ipynb b/self_supervised_pretraining/vit_unetr_ssl/ssl_train.ipynb index 92198ef9d9..32019b9842 100644 --- a/self_supervised_pretraining/vit_unetr_ssl/ssl_train.ipynb +++ b/self_supervised_pretraining/vit_unetr_ssl/ssl_train.ipynb @@ -248,7 +248,7 @@ "# Training Config\n", "\n", "# Define Network ViT backbone & Loss & Optimizer\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "model = ViTAutoEnc(\n", " in_channels=1,\n", " img_size=(96, 96, 96),\n", diff --git a/vista_3d/vista3d_spleen_finetune.ipynb b/vista_3d/vista3d_spleen_finetune.ipynb index f6617ea30e..9e3c415c9e 100644 --- a/vista_3d/vista3d_spleen_finetune.ipynb +++ b/vista_3d/vista3d_spleen_finetune.ipynb @@ -431,12 +431,12 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# standard PyTorch program style: create UNet, DiceLoss and Adam optimizer\n", - "device = torch.device(\"cuda:0\")\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "model = vista3d132(encoder_embed_dim=48, in_channels=1).to(device)\n", "model.load_state_dict(torch.load(os.path.join(root_dir, \"model.pt\"), weights_only=True))\n", "loss_function = DiceLoss(to_onehot_y=False, sigmoid=True)\n", From 935599a72decfb6729f2fe9bb99ff58afc6d6b30 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 21 Sep 2026 19:03:33 +0100 Subject: [PATCH 3/9] Undo needless metadata changes made by vscode Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- 2d_classification/mednist_tutorial.ipynb | 2 +- 2d_classification/monai_201.ipynb | 8 ++++---- 3d_classification/densenet_training_array.ipynb | 2 +- 3d_registration/learn2reg_nlst_paired_lung_ct.ipynb | 4 ++-- 3d_segmentation/brats_segmentation_3d.ipynb | 2 +- 3d_segmentation/spleen_segmentation_3d.ipynb | 4 ++-- 3d_segmentation/spleen_segmentation_3d_lightning.ipynb | 4 ++-- 3d_segmentation/unet_segmentation_3d_ignite.ipynb | 2 +- acceleration/TensorRT_inference_acceleration.ipynb | 2 +- acceleration/dataset_type_performance.ipynb | 4 ++-- acceleration/transform_speed.ipynb | 4 ++-- bundle/05_spleen_segmentation_lightning.ipynb | 6 +++--- .../pythonic_usage_guidance/pythonic_bundle_access.ipynb | 2 +- .../endoscopic_inbody_classification.ipynb | 2 +- deep_atlas/deep_atlas_tutorial.ipynb | 2 +- deployment/bentoml/mednist_classifier_bentoml.ipynb | 4 ++-- experiment_management/bundle_integrate_mlflow.ipynb | 2 +- .../client/non_ensemble/client.ipynb | 2 +- .../2d_sd_super_resolution_lightning.ipynb | 4 ++-- generation/maisi/maisi_train_vae_tutorial.ipynb | 2 +- .../finetune_vista3d_for_hugging_face_pipeline.ipynb | 2 +- hugging_face/hugging_face_pipeline_for_monai.ipynb | 4 ++-- microscopy/multichannel_microscopy_classification.ipynb | 2 +- modules/3d_image_transforms.ipynb | 2 +- modules/autoencoder_mednist.ipynb | 2 +- modules/cross_validation_models_ensemble.ipynb | 2 +- modules/csv_datasets.ipynb | 2 +- modules/integrate_3rd_party_transforms.ipynb | 2 +- modules/jupyter_utils.ipynb | 2 +- modules/lazy_resampling_benchmark.ipynb | 2 +- modules/mednist_GAN_tutorial.ipynb | 4 ++-- modules/mednist_GAN_workflow_array.ipynb | 4 ++-- modules/mednist_GAN_workflow_dict.ipynb | 4 ++-- modules/postprocessing_transforms.ipynb | 4 ++-- modules/public_datasets.ipynb | 6 +++--- modules/transform_visualization.ipynb | 2 +- modules/transforms_demo_2d.ipynb | 2 +- modules/varautoencoder_mednist.ipynb | 2 +- modules/workflow_profiling.ipynb | 4 ++-- pathology/hovernet/hovernet_torch.ipynb | 2 +- vista_3d/vista3d_spleen_finetune.ipynb | 4 ++-- 41 files changed, 62 insertions(+), 62 deletions(-) diff --git a/2d_classification/mednist_tutorial.ipynb b/2d_classification/mednist_tutorial.ipynb index a375063d34..fbd1729977 100644 --- a/2d_classification/mednist_tutorial.ipynb +++ b/2d_classification/mednist_tutorial.ipynb @@ -182,7 +182,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": { "tags": [] }, diff --git a/2d_classification/monai_201.ipynb b/2d_classification/monai_201.ipynb index 42630f8601..a199d9d713 100644 --- a/2d_classification/monai_201.ipynb +++ b/2d_classification/monai_201.ipynb @@ -188,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -298,7 +298,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -372,7 +372,7 @@ ], "metadata": { "kernelspec": { - "display_name": "monai", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -386,7 +386,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.20" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/3d_classification/densenet_training_array.ipynb b/3d_classification/densenet_training_array.ipynb index 019ac063e8..087e23e71e 100644 --- a/3d_classification/densenet_training_array.ipynb +++ b/3d_classification/densenet_training_array.ipynb @@ -178,7 +178,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [ { diff --git a/3d_registration/learn2reg_nlst_paired_lung_ct.ipynb b/3d_registration/learn2reg_nlst_paired_lung_ct.ipynb index d72671034c..4e311a8deb 100644 --- a/3d_registration/learn2reg_nlst_paired_lung_ct.ipynb +++ b/3d_registration/learn2reg_nlst_paired_lung_ct.ipynb @@ -242,7 +242,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "edea2f2b", "metadata": {}, "outputs": [], @@ -592,7 +592,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "9315e271", "metadata": {}, "outputs": [], diff --git a/3d_segmentation/brats_segmentation_3d.ipynb b/3d_segmentation/brats_segmentation_3d.ipynb index 6531d776e0..087b453b9e 100644 --- a/3d_segmentation/brats_segmentation_3d.ipynb +++ b/3d_segmentation/brats_segmentation_3d.ipynb @@ -433,7 +433,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ diff --git a/3d_segmentation/spleen_segmentation_3d.ipynb b/3d_segmentation/spleen_segmentation_3d.ipynb index dd9e10ce74..efdedb68cb 100644 --- a/3d_segmentation/spleen_segmentation_3d.ipynb +++ b/3d_segmentation/spleen_segmentation_3d.ipynb @@ -198,7 +198,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "tags": [] }, @@ -427,7 +427,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ diff --git a/3d_segmentation/spleen_segmentation_3d_lightning.ipynb b/3d_segmentation/spleen_segmentation_3d_lightning.ipynb index 5124425046..c4e743a7d6 100644 --- a/3d_segmentation/spleen_segmentation_3d_lightning.ipynb +++ b/3d_segmentation/spleen_segmentation_3d_lightning.ipynb @@ -194,7 +194,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "tags": [] }, @@ -532,7 +532,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": { "jupyter": { "outputs_hidden": true diff --git a/3d_segmentation/unet_segmentation_3d_ignite.ipynb b/3d_segmentation/unet_segmentation_3d_ignite.ipynb index 858ec22ecc..9940524b07 100644 --- a/3d_segmentation/unet_segmentation_3d_ignite.ipynb +++ b/3d_segmentation/unet_segmentation_3d_ignite.ipynb @@ -258,7 +258,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ diff --git a/acceleration/TensorRT_inference_acceleration.ipynb b/acceleration/TensorRT_inference_acceleration.ipynb index bffadbf4e4..05d00dc795 100644 --- a/acceleration/TensorRT_inference_acceleration.ipynb +++ b/acceleration/TensorRT_inference_acceleration.ipynb @@ -129,7 +129,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [ { diff --git a/acceleration/dataset_type_performance.ipynb b/acceleration/dataset_type_performance.ipynb index 1c946ac4ba..894f601704 100644 --- a/acceleration/dataset_type_performance.ipynb +++ b/acceleration/dataset_type_performance.ipynb @@ -142,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -299,7 +299,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "tags": [] }, diff --git a/acceleration/transform_speed.ipynb b/acceleration/transform_speed.ipynb index 55c0e00a5a..032876aff5 100644 --- a/acceleration/transform_speed.ipynb +++ b/acceleration/transform_speed.ipynb @@ -308,7 +308,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": { "tags": [] }, @@ -437,7 +437,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, "outputs": [ { diff --git a/bundle/05_spleen_segmentation_lightning.ipynb b/bundle/05_spleen_segmentation_lightning.ipynb index 0ea16ac29a..2190348bb5 100644 --- a/bundle/05_spleen_segmentation_lightning.ipynb +++ b/bundle/05_spleen_segmentation_lightning.ipynb @@ -158,7 +158,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "672f0168-950a-440e-b77c-f785a92c0f74", "metadata": { "ExecuteTime": { @@ -1124,7 +1124,7 @@ ], "metadata": { "kernelspec": { - "display_name": "monai", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1138,7 +1138,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.20" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/bundle/pythonic_usage_guidance/pythonic_bundle_access.ipynb b/bundle/pythonic_usage_guidance/pythonic_bundle_access.ipynb index 5bff4d19b5..8af48d50a2 100644 --- a/bundle/pythonic_usage_guidance/pythonic_bundle_access.ipynb +++ b/bundle/pythonic_usage_guidance/pythonic_bundle_access.ipynb @@ -124,7 +124,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ diff --git a/computer_assisted_intervention/endoscopic_inbody_classification.ipynb b/computer_assisted_intervention/endoscopic_inbody_classification.ipynb index 9726edff86..58e8c1b204 100644 --- a/computer_assisted_intervention/endoscopic_inbody_classification.ipynb +++ b/computer_assisted_intervention/endoscopic_inbody_classification.ipynb @@ -142,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "495b1db7", "metadata": {}, "outputs": [ diff --git a/deep_atlas/deep_atlas_tutorial.ipynb b/deep_atlas/deep_atlas_tutorial.ipynb index d77ca01378..319845a0ff 100644 --- a/deep_atlas/deep_atlas_tutorial.ipynb +++ b/deep_atlas/deep_atlas_tutorial.ipynb @@ -424,7 +424,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "a98e74bd", "metadata": {}, "outputs": [], diff --git a/deployment/bentoml/mednist_classifier_bentoml.ipynb b/deployment/bentoml/mednist_classifier_bentoml.ipynb index 75e57aff5b..90b6401f36 100644 --- a/deployment/bentoml/mednist_classifier_bentoml.ipynb +++ b/deployment/bentoml/mednist_classifier_bentoml.ipynb @@ -174,7 +174,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "tags": [] }, @@ -275,7 +275,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "scrolled": true }, diff --git a/experiment_management/bundle_integrate_mlflow.ipynb b/experiment_management/bundle_integrate_mlflow.ipynb index 74095e21a0..26da75823b 100644 --- a/experiment_management/bundle_integrate_mlflow.ipynb +++ b/experiment_management/bundle_integrate_mlflow.ipynb @@ -107,7 +107,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [ { diff --git a/full_gpu_inference_pipeline/client/non_ensemble/client.ipynb b/full_gpu_inference_pipeline/client/non_ensemble/client.ipynb index 38c65c6b01..811e510fea 100644 --- a/full_gpu_inference_pipeline/client/non_ensemble/client.ipynb +++ b/full_gpu_inference_pipeline/client/non_ensemble/client.ipynb @@ -119,7 +119,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [ { diff --git a/generation/2d_super_resolution/2d_sd_super_resolution_lightning.ipynb b/generation/2d_super_resolution/2d_sd_super_resolution_lightning.ipynb index 2f0dec68d6..edbe98887d 100644 --- a/generation/2d_super_resolution/2d_sd_super_resolution_lightning.ipynb +++ b/generation/2d_super_resolution/2d_sd_super_resolution_lightning.ipynb @@ -680,7 +680,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "ccb6ba9f", "metadata": {}, "outputs": [ @@ -1176,7 +1176,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "id": "155be091", "metadata": {}, "outputs": [ diff --git a/generation/maisi/maisi_train_vae_tutorial.ipynb b/generation/maisi/maisi_train_vae_tutorial.ipynb index 23f8108323..7d9497d8d6 100644 --- a/generation/maisi/maisi_train_vae_tutorial.ipynb +++ b/generation/maisi/maisi_train_vae_tutorial.ipynb @@ -179,7 +179,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "ec6f0c29-1989-45c6-bd64-35682533794b", "metadata": {}, "outputs": [], diff --git a/hugging_face/finetune_vista3d_for_hugging_face_pipeline.ipynb b/hugging_face/finetune_vista3d_for_hugging_face_pipeline.ipynb index b75c8a3161..83687e70c4 100644 --- a/hugging_face/finetune_vista3d_for_hugging_face_pipeline.ipynb +++ b/hugging_face/finetune_vista3d_for_hugging_face_pipeline.ipynb @@ -164,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "tags": [] }, diff --git a/hugging_face/hugging_face_pipeline_for_monai.ipynb b/hugging_face/hugging_face_pipeline_for_monai.ipynb index 6e07748f64..f76e8fbc2e 100644 --- a/hugging_face/hugging_face_pipeline_for_monai.ipynb +++ b/hugging_face/hugging_face_pipeline_for_monai.ipynb @@ -176,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -475,7 +475,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [ { diff --git a/microscopy/multichannel_microscopy_classification.ipynb b/microscopy/multichannel_microscopy_classification.ipynb index 8ed190172c..3856c23370 100644 --- a/microscopy/multichannel_microscopy_classification.ipynb +++ b/microscopy/multichannel_microscopy_classification.ipynb @@ -786,7 +786,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "97ba2753", "metadata": {}, "outputs": [], diff --git a/modules/3d_image_transforms.ipynb b/modules/3d_image_transforms.ipynb index a8ae5ce1ba..36fa39b54b 100644 --- a/modules/3d_image_transforms.ipynb +++ b/modules/3d_image_transforms.ipynb @@ -118,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "tags": [] }, diff --git a/modules/autoencoder_mednist.ipynb b/modules/autoencoder_mednist.ipynb index 39065929b7..94a02a3649 100644 --- a/modules/autoencoder_mednist.ipynb +++ b/modules/autoencoder_mednist.ipynb @@ -163,7 +163,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "tags": [] }, diff --git a/modules/cross_validation_models_ensemble.ipynb b/modules/cross_validation_models_ensemble.ipynb index ea68dbaaab..0ada70c7e9 100644 --- a/modules/cross_validation_models_ensemble.ipynb +++ b/modules/cross_validation_models_ensemble.ipynb @@ -154,7 +154,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ diff --git a/modules/csv_datasets.ipynb b/modules/csv_datasets.ipynb index 7eb99050e5..6db00af2c4 100644 --- a/modules/csv_datasets.ipynb +++ b/modules/csv_datasets.ipynb @@ -128,7 +128,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "tags": [] }, diff --git a/modules/integrate_3rd_party_transforms.ipynb b/modules/integrate_3rd_party_transforms.ipynb index 6819271d9d..2b6b7d1a46 100644 --- a/modules/integrate_3rd_party_transforms.ipynb +++ b/modules/integrate_3rd_party_transforms.ipynb @@ -142,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "tags": [] }, diff --git a/modules/jupyter_utils.ipynb b/modules/jupyter_utils.ipynb index 4234632cc3..2b0ef354f5 100644 --- a/modules/jupyter_utils.ipynb +++ b/modules/jupyter_utils.ipynb @@ -118,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ diff --git a/modules/lazy_resampling_benchmark.ipynb b/modules/lazy_resampling_benchmark.ipynb index c59199ac04..2259e18489 100644 --- a/modules/lazy_resampling_benchmark.ipynb +++ b/modules/lazy_resampling_benchmark.ipynb @@ -131,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "4255c4b0", "metadata": {}, "outputs": [], diff --git a/modules/mednist_GAN_tutorial.ipynb b/modules/mednist_GAN_tutorial.ipynb index c4fda8045e..f0ba5e340d 100644 --- a/modules/mednist_GAN_tutorial.ipynb +++ b/modules/mednist_GAN_tutorial.ipynb @@ -189,7 +189,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -257,7 +257,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ diff --git a/modules/mednist_GAN_workflow_array.ipynb b/modules/mednist_GAN_workflow_array.ipynb index 61fedf0862..770b080b57 100644 --- a/modules/mednist_GAN_workflow_array.ipynb +++ b/modules/mednist_GAN_workflow_array.ipynb @@ -162,7 +162,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": { "tags": [] }, @@ -208,7 +208,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ diff --git a/modules/mednist_GAN_workflow_dict.ipynb b/modules/mednist_GAN_workflow_dict.ipynb index 06caf320c3..5e1a0b4c6e 100644 --- a/modules/mednist_GAN_workflow_dict.ipynb +++ b/modules/mednist_GAN_workflow_dict.ipynb @@ -161,7 +161,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "tags": [] }, @@ -215,7 +215,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ diff --git a/modules/postprocessing_transforms.ipynb b/modules/postprocessing_transforms.ipynb index d0ff574ceb..3a2cf92c7e 100644 --- a/modules/postprocessing_transforms.ipynb +++ b/modules/postprocessing_transforms.ipynb @@ -189,7 +189,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "tags": [] }, @@ -348,7 +348,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ diff --git a/modules/public_datasets.ipynb b/modules/public_datasets.ipynb index 721277804a..ab5e5cd483 100644 --- a/modules/public_datasets.ipynb +++ b/modules/public_datasets.ipynb @@ -312,7 +312,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -501,7 +501,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -590,7 +590,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ diff --git a/modules/transform_visualization.ipynb b/modules/transform_visualization.ipynb index 9b6cc8fcda..6f3ef2cfd3 100644 --- a/modules/transform_visualization.ipynb +++ b/modules/transform_visualization.ipynb @@ -138,7 +138,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "tags": [] }, diff --git a/modules/transforms_demo_2d.ipynb b/modules/transforms_demo_2d.ipynb index 59fe93f3b2..f9141ff77d 100644 --- a/modules/transforms_demo_2d.ipynb +++ b/modules/transforms_demo_2d.ipynb @@ -166,7 +166,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "tags": [] }, diff --git a/modules/varautoencoder_mednist.ipynb b/modules/varautoencoder_mednist.ipynb index fa2a6a9ba4..9b97a9a82e 100644 --- a/modules/varautoencoder_mednist.ipynb +++ b/modules/varautoencoder_mednist.ipynb @@ -212,7 +212,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "tags": [] }, diff --git a/modules/workflow_profiling.ipynb b/modules/workflow_profiling.ipynb index b464b8af7c..e490a36e3e 100644 --- a/modules/workflow_profiling.ipynb +++ b/modules/workflow_profiling.ipynb @@ -753,7 +753,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "490387f9-d59b-4862-8174-63591341114d", "metadata": {}, "outputs": [ @@ -1026,7 +1026,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "85374f79-9a56-4981-9507-f00ee16ca7b4", "metadata": {}, "outputs": [ diff --git a/pathology/hovernet/hovernet_torch.ipynb b/pathology/hovernet/hovernet_torch.ipynb index 600966b80c..a8e7b49783 100644 --- a/pathology/hovernet/hovernet_torch.ipynb +++ b/pathology/hovernet/hovernet_torch.ipynb @@ -504,7 +504,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, "outputs": [ { diff --git a/vista_3d/vista3d_spleen_finetune.ipynb b/vista_3d/vista3d_spleen_finetune.ipynb index 9e3c415c9e..d2ebc08eb1 100644 --- a/vista_3d/vista3d_spleen_finetune.ipynb +++ b/vista_3d/vista3d_spleen_finetune.ipynb @@ -155,7 +155,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": { "tags": [] }, @@ -431,7 +431,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 57, "metadata": {}, "outputs": [], "source": [ From e38cb2929d309cf8f39edf979106fbfab02fe9d4 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 22 Sep 2026 13:26:24 +0100 Subject: [PATCH 4/9] Fixes from comments Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- acceleration/automatic_mixed_precision.ipynb | 32 ++++++++----- acceleration/transform_speed.ipynb | 22 ++++++--- deep_atlas/deep_atlas_tutorial.ipynb | 48 +++++++++++-------- ...ltichannel_microscopy_classification.ipynb | 7 ++- runner.sh | 1 - 5 files changed, 67 insertions(+), 43 deletions(-) diff --git a/acceleration/automatic_mixed_precision.ipynb b/acceleration/automatic_mixed_precision.ipynb index 8bfcb5212e..c0240dcf51 100644 --- a/acceleration/automatic_mixed_precision.ipynb +++ b/acceleration/automatic_mixed_precision.ipynb @@ -94,8 +94,13 @@ "\n", "print_config()\n", "\n", - "if get_torch_version_tuple() < (1, 6):\n", - " raise RuntimeError(\"AMP feature only exists in PyTorch version greater than v1.6.\")" + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", + "\n", + "if not torch.cuda.is_available() or torch.cuda.device_count() == 0:\n", + " print(\n", + " \"Warning: no CUDA device available, this notebook will still run but the AMP \" \n", + " \"feature will not provide any acceleration.\"\n", + " )" ] }, { @@ -277,7 +282,6 @@ " num_workers=1,\n", " )\n", " val_loader = DataLoader(val_ds, batch_size=1, num_workers=1)\n", - " device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", " model = UNet(\n", " spatial_dims=3,\n", " in_channels=1,\n", @@ -431,7 +435,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -471,8 +475,11 @@ } ], "source": [ - "print(torch.cuda.get_device_name(0))\n", - "print(torch.cuda.memory_summary(0, abbreviated=True))" + "if device.type == \"cuda\":\n", + " print(torch.cuda.get_device_name(0))\n", + " print(torch.cuda.memory_summary(0, abbreviated=True))\n", + "else:\n", + " print(\"Not using a CUDA device!\")" ] }, { @@ -511,7 +518,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -551,8 +558,11 @@ } ], "source": [ - "print(torch.cuda.get_device_name(0))\n", - "print(torch.cuda.memory_summary(0, abbreviated=True))" + "if device.type == \"cuda\":\n", + " print(torch.cuda.get_device_name(0))\n", + " print(torch.cuda.memory_summary(0, abbreviated=True))\n", + "else:\n", + " print(\"Not using a CUDA device!\")" ] }, { @@ -787,7 +797,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "monai", "language": "python", "name": "python3" }, @@ -801,7 +811,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.13" + "version": "3.10.20" } }, "nbformat": 4, diff --git a/acceleration/transform_speed.ipynb b/acceleration/transform_speed.ipynb index 032876aff5..2ab1d29075 100644 --- a/acceleration/transform_speed.ipynb +++ b/acceleration/transform_speed.ipynb @@ -84,7 +84,14 @@ ")\n", "from monai.utils import first\n", "\n", - "print_config()" + "print_config()\n", + "\n", + "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", + "\n", + "if not torch.cuda.is_available() or torch.cuda.device_count() == 0:\n", + " print(\n", + " \"Warning: no CUDA device available, this notebook will run but no GPU acceleration will be present.\"\n", + " )" ] }, { @@ -308,7 +315,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": { "tags": [] }, @@ -325,8 +332,6 @@ "images = sorted(glob.glob(os.path.join(root_dir, \"im*.nii.gz\")))\n", "segs = sorted(glob.glob(os.path.join(root_dir, \"seg*.nii.gz\")))\n", "\n", - "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", - "\n", "# same parameter with different interpolation mode for image and segmentation\n", "rand_affine_img = RandAffine(\n", " prob=1.0,\n", @@ -379,7 +384,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": { "tags": [] }, @@ -417,8 +422,11 @@ } ], "source": [ - "print(torch.cuda.get_device_name(0))\n", - "print(torch.cuda.memory_summary(0, abbreviated=True))" + "if device.type == \"cuda\":\n", + " print(torch.cuda.get_device_name(0))\n", + " print(torch.cuda.memory_summary(0, abbreviated=True))\n", + "else:\n", + " print(\"Not using a CUDA device!\")" ] }, { diff --git a/deep_atlas/deep_atlas_tutorial.ipynb b/deep_atlas/deep_atlas_tutorial.ipynb index 319845a0ff..5b57ef8a94 100644 --- a/deep_atlas/deep_atlas_tutorial.ipynb +++ b/deep_atlas/deep_atlas_tutorial.ipynb @@ -142,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "576b9aa6", "metadata": {}, "outputs": [ @@ -211,10 +211,11 @@ "# Set deterministic training for reproducibility\n", "monai.utils.set_determinism(seed=2938649572)\n", "\n", - "# Turn off the TF32 precision. Otherwise, because of the rounding error, the ssim_loss will be a weird value on some Ampere GPUs, like L40, 3090Ti and 3080Ti.\n", - "# Track this issue (https://github.com/Project-MONAI/tutorials/issues/1336) for more detail.\n", - "torch.backends.cuda.matmul.allow_tf32 = False\n", - "torch.backends.cudnn.allow_tf32 = False\n", + "if torch.cuda.is_available():\n", + " # Turn off the TF32 precision. Otherwise, because of the rounding error, the ssim_loss will be a weird value on some Ampere GPUs, like L40, 3090Ti and 3080Ti.\n", + " # Track this issue (https://github.com/Project-MONAI/tutorials/issues/1336) for more detail.\n", + " torch.backends.cuda.matmul.allow_tf32 = False\n", + " torch.backends.cudnn.allow_tf32 = False\n", "\n", "monai.config.print_config()" ] @@ -288,7 +289,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "549f9bee", "metadata": {}, "outputs": [], @@ -301,7 +302,7 @@ "\n", " compressed_file = os.path.join(root_dir, \"oasis_cross-sectional_disc1.tar.gz\")\n", " if not os.path.exists(data_dir):\n", - " monai.apps.utils.download_and_extract(resource, compressed_file, data_dir, md5)" + " monai.apps.utils.download_and_extract(resource, compressed_file, data_dir, md5, \"md5\")" ] }, { @@ -1292,7 +1293,8 @@ "\n", "# Free up some memory\n", "del loss, predicted_segs, true_segs, imgs\n", - "torch.cuda.empty_cache()" + "if torch.cuda.is_available():\n", + " torch.cuda.empty_cache()" ] }, { @@ -1352,7 +1354,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": null, "id": "91d2f6ec", "metadata": {}, "outputs": [ @@ -1424,7 +1426,7 @@ "test_seg_true = data_item[\"seg\"]\n", "seg_net.eval()\n", "with torch.no_grad():\n", - " test_seg_predicted = seg_net(test_input.unsqueeze(0).cuda()).cpu()\n", + " test_seg_predicted = seg_net(test_input.unsqueeze(0).to(device)).cpu()\n", "\n", "print(\"Original image from validation set:\")\n", "preview_image(test_input[0])\n", @@ -1434,7 +1436,8 @@ "preview_image(torch.argmax(torch.softmax(test_seg_predicted, dim=1), dim=1, keepdim=True)[0, 0])\n", "\n", "del test_seg_predicted\n", - "torch.cuda.empty_cache()" + "if torch.cuda.is_available():\n", + " torch.cuda.empty_cache()" ] }, { @@ -1838,7 +1841,8 @@ "\n", " # Free up memory\n", " del loss, loss_sim, loss_reg, loss_ana\n", - " torch.cuda.empty_cache()\n", + " if torch.cuda.is_available():\n", + " torch.cuda.empty_cache()\n", "\n", " # ------------------------------------------------\n", " # seg_net training, with reg_net frozen\n", @@ -1942,7 +1946,8 @@ " seg1_predicted,\n", " seg2_predicted,\n", " )\n", - " torch.cuda.empty_cache()\n", + " if torch.cuda.is_available():\n", + " torch.cuda.empty_cache()\n", "\n", "print(f\"\\n\\nBest reg_net validation loss: {best_reg_validation_loss}\")\n", "print(f\"Best seg_net validation loss: {best_seg_validation_loss}\")" @@ -2059,7 +2064,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": null, "id": "8972921e", "metadata": {}, "outputs": [ @@ -2138,7 +2143,7 @@ "test_seg_true = data_item[\"seg\"]\n", "seg_net.eval()\n", "with torch.no_grad():\n", - " test_seg_predicted = seg_net(test_input.unsqueeze(0).cuda()).cpu()\n", + " test_seg_predicted = seg_net(test_input.unsqueeze(0).to(device)).cpu()\n", " loss = dice_loss(test_seg_predicted, test_seg_true.unsqueeze(0)).item()\n", "\n", "print(\"original image from validation set:\")\n", @@ -2150,7 +2155,8 @@ "print(f\"dice loss: {loss}\")\n", "\n", "del test_seg_predicted\n", - "torch.cuda.empty_cache()" + "if torch.cuda.is_available():\n", + " torch.cuda.empty_cache()" ] }, { @@ -2163,7 +2169,7 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": null, "id": "5801a48e", "metadata": {}, "outputs": [ @@ -2323,7 +2329,8 @@ "print(f\"number of folds: {(det <= 0).sum()}\")\n", "\n", "del reg_net_example_output, img12, example_warped_image\n", - "torch.cuda.empty_cache()" + "if torch.cuda.is_available():\n", + " torch.cuda.empty_cache()" ] }, { @@ -2359,7 +2366,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": null, "id": "ab53ebb0", "metadata": {}, "outputs": [ @@ -2401,7 +2408,8 @@ " negative_det_values += det[det <= 0].tolist()\n", "\n", "del img12, displacement_fields\n", - "torch.cuda.empty_cache()\n", + "if torch.cuda.is_available():\n", + " torch.cuda.empty_cache()\n", "\n", "plt.hist(fold_counts)\n", "plt.title(\"Number of folds\")\n", diff --git a/microscopy/multichannel_microscopy_classification.ipynb b/microscopy/multichannel_microscopy_classification.ipynb index 3856c23370..2df8bdf66f 100644 --- a/microscopy/multichannel_microscopy_classification.ipynb +++ b/microscopy/multichannel_microscopy_classification.ipynb @@ -155,7 +155,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "9fe67439", "metadata": {}, "outputs": [ @@ -178,9 +178,8 @@ ], "source": [ "url = \"https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/rxrx1_subset_monai.zip\"\n", - "download_and_extract(\n", - " url, filepath=\"./rxrx1_subset_monai.zip\", output_dir=\".\", hash_val=\"5eea02f6b0a6d8cbce6ad66949257438\"\n", - ")" + "md5 = \"5eea02f6b0a6d8cbce6ad66949257438\"\n", + "download_and_extract(url, filepath=\"./rxrx1_subset_monai.zip\", output_dir=\".\", hash_val=md5, hash_type=\"md5\")" ] }, { diff --git a/runner.sh b/runner.sh index 5a24aa2a2c..36225ec59b 100755 --- a/runner.sh +++ b/runner.sh @@ -139,7 +139,6 @@ skip_run_papermill=("${skip_run_papermill[@]}" .*TCIA_PROSTATEx_Prostate_MRI_Ana skip_run_papermill=("${skip_run_papermill[@]}" .*maisi_inference_tutorial.ipynb*) skip_run_papermill=("${skip_run_papermill[@]}" .*image_restoration.ipynb*) # monai.networks.nets.restormer not yet in dev branch skip_run_papermill=("${skip_run_papermill[@]}" .*05_spleen_segmentation_lightning*) # requires GPU; hardcoded .to("cuda") with no CPU fallback -skip_run_papermill=("${skip_run_papermill[@]}" .*deep_atlas_tutorial*) # requires GPU; device hardcoded to "cuda:0" # output formatting separator="" From 47ac6d05a1570040c3895a416e89b1527259d87a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2026 12:27:24 +0000 Subject: [PATCH 5/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- acceleration/automatic_mixed_precision.ipynb | 2 +- acceleration/transform_speed.ipynb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/acceleration/automatic_mixed_precision.ipynb b/acceleration/automatic_mixed_precision.ipynb index c0240dcf51..bfd7913fba 100644 --- a/acceleration/automatic_mixed_precision.ipynb +++ b/acceleration/automatic_mixed_precision.ipynb @@ -98,7 +98,7 @@ "\n", "if not torch.cuda.is_available() or torch.cuda.device_count() == 0:\n", " print(\n", - " \"Warning: no CUDA device available, this notebook will still run but the AMP \" \n", + " \"Warning: no CUDA device available, this notebook will still run but the AMP \"\n", " \"feature will not provide any acceleration.\"\n", " )" ] diff --git a/acceleration/transform_speed.ipynb b/acceleration/transform_speed.ipynb index 2ab1d29075..dd974ad30f 100644 --- a/acceleration/transform_speed.ipynb +++ b/acceleration/transform_speed.ipynb @@ -89,9 +89,7 @@ "device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n", "\n", "if not torch.cuda.is_available() or torch.cuda.device_count() == 0:\n", - " print(\n", - " \"Warning: no CUDA device available, this notebook will run but no GPU acceleration will be present.\"\n", - " )" + " print(\"Warning: no CUDA device available, this notebook will run but no GPU acceleration will be present.\")" ] }, { From c7998616d1e11065f557512b4a67cd276254659a Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 22 Sep 2026 13:38:26 +0100 Subject: [PATCH 6/9] Fixes Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- acceleration/automatic_mixed_precision.ipynb | 2 +- deep_atlas/deep_atlas_tutorial.ipynb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/acceleration/automatic_mixed_precision.ipynb b/acceleration/automatic_mixed_precision.ipynb index c0240dcf51..1582a5e3ec 100644 --- a/acceleration/automatic_mixed_precision.ipynb +++ b/acceleration/automatic_mixed_precision.ipynb @@ -90,7 +90,7 @@ " ScaleIntensityRanged,\n", " Spacingd,\n", ")\n", - "from monai.utils import get_torch_version_tuple, set_determinism\n", + "from monai.utils import set_determinism\n", "\n", "print_config()\n", "\n", diff --git a/deep_atlas/deep_atlas_tutorial.ipynb b/deep_atlas/deep_atlas_tutorial.ipynb index 5b57ef8a94..e0adf31cc9 100644 --- a/deep_atlas/deep_atlas_tutorial.ipynb +++ b/deep_atlas/deep_atlas_tutorial.ipynb @@ -212,7 +212,8 @@ "monai.utils.set_determinism(seed=2938649572)\n", "\n", "if torch.cuda.is_available():\n", - " # Turn off the TF32 precision. Otherwise, because of the rounding error, the ssim_loss will be a weird value on some Ampere GPUs, like L40, 3090Ti and 3080Ti.\n", + " # Turn off the TF32 precision. Otherwise, because of the rounding error, the ssim_loss will be a\n", + " # weird value on some Ampere GPUs, like L40, 3090Ti and 3080Ti.\n", " # Track this issue (https://github.com/Project-MONAI/tutorials/issues/1336) for more detail.\n", " torch.backends.cuda.matmul.allow_tf32 = False\n", " torch.backends.cudnn.allow_tf32 = False\n", From 957a8ac655b1c2abe90551b1feab98e7b6fd4952 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 22 Sep 2026 16:18:38 +0100 Subject: [PATCH 7/9] Further comment updates Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- 3d_segmentation/spleen_segmentation_3d_lightning.ipynb | 2 +- 3d_segmentation/unetr_btcv_segmentation_3d_lightning.ipynb | 2 +- computer_assisted_intervention/video_seg.ipynb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/3d_segmentation/spleen_segmentation_3d_lightning.ipynb b/3d_segmentation/spleen_segmentation_3d_lightning.ipynb index c4e743a7d6..57738bec1a 100644 --- a/3d_segmentation/spleen_segmentation_3d_lightning.ipynb +++ b/3d_segmentation/spleen_segmentation_3d_lightning.ipynb @@ -432,7 +432,7 @@ "\n", "# initialise Lightning's trainer.\n", "trainer = pytorch_lightning.Trainer(\n", - " devices=[0],\n", + " devices=1,\n", " max_epochs=600,\n", " logger=tb_logger,\n", " enable_checkpointing=True,\n", diff --git a/3d_segmentation/unetr_btcv_segmentation_3d_lightning.ipynb b/3d_segmentation/unetr_btcv_segmentation_3d_lightning.ipynb index 1fae50750a..762aa8af0a 100644 --- a/3d_segmentation/unetr_btcv_segmentation_3d_lightning.ipynb +++ b/3d_segmentation/unetr_btcv_segmentation_3d_lightning.ipynb @@ -637,7 +637,7 @@ "\n", "# initialise Lightning's trainer.\n", "trainer = pytorch_lightning.Trainer(\n", - " devices=[0],\n", + " devices=1,\n", " max_epochs=net.max_epochs,\n", " check_val_every_n_epoch=net.check_val,\n", " callbacks=checkpoint_callback,\n", diff --git a/computer_assisted_intervention/video_seg.ipynb b/computer_assisted_intervention/video_seg.ipynb index fb3ab667f6..dc4e16c6c2 100644 --- a/computer_assisted_intervention/video_seg.ipynb +++ b/computer_assisted_intervention/video_seg.ipynb @@ -131,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -153,8 +153,8 @@ "vid_filepath = os.path.join(endo_dir, \"endo.mp4\")\n", "seg_filepath = os.path.join(endo_dir, \"endo_seg.mp4\")\n", "\n", - "download_url(vid_url, vid_filepath, vid_hash)\n", - "download_url(seg_url, seg_filepath, seg_hash)" + "download_url(vid_url, vid_filepath, vid_hash,\"md5\")\n", + "download_url(seg_url, seg_filepath, seg_hash,\"md5\")" ] }, { From b44936f4d1b838e327de6b3783257143519e4c3e Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 22 Sep 2026 16:26:20 +0100 Subject: [PATCH 8/9] Adding `date` to action to keep track of running time Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/test-modified.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-modified.yml b/.github/workflows/test-modified.yml index 2365d17302..4e410ffe67 100644 --- a/.github/workflows/test-modified.yml +++ b/.github/workflows/test-modified.yml @@ -53,6 +53,7 @@ jobs: do if [[ $line == *.ipynb ]] then + date ./runner.sh -p " -and -wholename './${line}'" fi done From f80f02b8de07eb53c93f025ad34c0b4a250258c9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2026 15:27:14 +0000 Subject: [PATCH 9/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- computer_assisted_intervention/video_seg.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/computer_assisted_intervention/video_seg.ipynb b/computer_assisted_intervention/video_seg.ipynb index dc4e16c6c2..346eac7251 100644 --- a/computer_assisted_intervention/video_seg.ipynb +++ b/computer_assisted_intervention/video_seg.ipynb @@ -153,8 +153,8 @@ "vid_filepath = os.path.join(endo_dir, \"endo.mp4\")\n", "seg_filepath = os.path.join(endo_dir, \"endo_seg.mp4\")\n", "\n", - "download_url(vid_url, vid_filepath, vid_hash,\"md5\")\n", - "download_url(seg_url, seg_filepath, seg_hash,\"md5\")" + "download_url(vid_url, vid_filepath, vid_hash, \"md5\")\n", + "download_url(seg_url, seg_filepath, seg_hash, \"md5\")" ] }, {