Project-MONAI / monai-deploy-app-sdk

MONAI Deploy App SDK offers a framework and associated tools to design, develop and verify AI-driven applications in the healthcare imaging domain.
Apache License 2.0
94 stars 48 forks source link

[DOC] Outdated/incomplete examples documentation #490

Closed kavmar closed 5 months ago

kavmar commented 6 months ago

Hi,

I am trying to start off with monai-deploy by following examples/apps breast_density_classifier

I am on ubuntu 22.04 and I am only able to run successfully using Python CLI.

When I try to run it using monai-deploy cli monai-deploy exec app.py -i ./sampleDICOMs/3/BI_BREAST_SCREENING_BILATERAL_WITH_TOMOSYNTHESIS-2019-08-06/3 -m ./model/traced_ts_model.pt

I get error: monai-deploy: error: argument command: invalid choice: 'exec' (choose from 'package', 'run', 'version', 'nics')

So obviously 'exec' needs to be replaced by 'run'

However, when I do that, I get further error: monai-deploy: error: unrecognized arguments: -m ./model/traced_ts_model.pt

Running monai-deploy run --help does not list any -m cli argument. Removing it and trying to run:

monai-deploy run app.py -i ./sampleDICOMs/3/BI_BREAST_SCREENING_BILATERAL_WITH_TOMOSYNTHESIS-2019-08-06/3

results in next error: [2024-05-22 11:22:11,121] [INFO] (runner) - Checking dependencies... [2024-05-22 11:22:11,121] [INFO] (runner) - --> Verifying if "docker" is installed...

[2024-05-22 11:22:11,130] [INFO] (runner) - --> Verifying if "docker-buildx" is installed...

[2024-05-22 11:22:11,152] [INFO] (runner) - --> Verifying if "app.py" is available...

[2024-05-22 11:22:11,199] [INFO] (common) - Attempting to pull image app.py.. Using default tag: latest Error response from daemon: pull access denied for app.py, repository does not exist or may require 'docker login': denied: requested access to the resource is denied [2024-05-22 11:22:13,124] [ERROR] (common) - The docker command executed was /usr/bin/docker image pull app.py. It returned with code 1 The content of stdout can be found above the stacktrace (it wasn't captured). The content of stderr can be found above the stacktrace (it wasn't captured). [2024-05-22 11:22:13,124] [ERROR] (runner) - Unable to fetch required image. [2024-05-22 11:22:13,124] [ERROR] (runner) - Execution Aborted

Going one level up, as suggested nd running: monai-deploy run breast_density_classifer_app -i ./sampleDICOMs/3/BI_BREAST_SCREENING_BILATERAL_WITH_TOMOSYNTHESIS-2019-08-06/3

results in the same error as with previous command.

And finally packaging does'n seem to work either for me: monai-deploy package -b nvcr.io/nvidia/pytorch:21.12-py3 breast_density_classification_app --tag breast_density:0.1.0

results in error: monai-deploy package: error: argument application: No such file/folder: '/PATH/TO/PROJECT/monai-deploy/nvcr.io/nvidia/pytorch:21.12-py3'

I found out that if I don't use abbreviated cli argument, -b, for base image but a full one, --base-image this works. So this might even classify as a bug. However, this still does not fly since the next problem is: monai-deploy package: error: the following arguments are required: --config/-c, --platform

I had to pull in and adapt the app.yaml from other examples and provide --platform. So the correct cli which moved me further was: monai-deploy package --base-image nvcr.io/nvidia/pytorch:21.12-py3 breast_density_classifer_app --tag breast_density:0.1.0 --config breast_density_classifer_app/app.yaml --platform x64-workstation

However, as of today the base-image for pytorch container with version 21.12 (december 2021) is very outdated and it was not able to resolve conflicting packages and creating of docker image failed. So I tried using more recent base image 24.04.-py3, which succeeded, but then running the whole thing failed:

monai-deploy run breast_density_classifer_app-x64-workstation-dgpu-linux-amd64:0.2.0 -i breast_density_classifer_app/sampleDICOMs/3/BI_BREAST_SCREENING_BILATERAL_WITH_TOMOSYNTHESIS-2019-08-06/3 [2024-05-22 12:01:26,929] [INFO] (runner) - Checking dependencies... [2024-05-22 12:01:26,929] [INFO] (runner) - --> Verifying if "docker" is installed...

[2024-05-22 12:01:26,930] [INFO] (runner) - --> Verifying if "docker-buildx" is installed...

[2024-05-22 12:01:26,930] [INFO] (runner) - --> Verifying if "breast_density_classifer_app-x64-workstation-dgpu-linux-amd64:0.2.0" is available...

[2024-05-22 12:01:27,066] [INFO] (runner) - Reading HAP/MAP manifest... Successfully copied 2.56kB to /tmp/tmp4et7tool/app.json Successfully copied 2.05kB to /tmp/tmp4et7tool/pkg.json [2024-05-22 12:01:28,360] [INFO] (runner) - --> Verifying if "nvidia-ctk" is installed...

[2024-05-22 12:01:28,361] [INFO] (runner) - --> Verifying "nvidia-ctk" version...

[2024-05-22 12:01:29,008] [INFO] (common) - Launching container (01deeea6c946) using image 'breast_density_classifer_app-x64-workstation-dgpu-linux-amd64:0.2.0'... container name: heuristic_perlman host name: buddha network: host user: 1000:1000 ulimits: memlock=-1:-1, stack=67108864:67108864 cap_add: CAP_SYS_PTRACE ipc mode: host shared memory size: 67108864 devices:
group_add: 44 2024-05-22 10:01:34 [INFO] Launching application python3 /opt/holoscan/app ...

Error processing line 1 of /home/holoscan/.local/lib/python3.10/site-packages/holoscan-2.0.0.pth:

Traceback (most recent call last):

File "/usr/lib/python3.10/site.py", line 192, in addpackage

  exec(line)

File "<string>", line 1, in <module>

File "/home/holoscan/.local/lib/python3.10/site-packages/wheel_axle/runtime/__init__.py", line 77, in finalize

  from filelock import FileLock  # Local import for speed

ModuleNotFoundError: No module named 'filelock'

Remainder of file ignored

Traceback (most recent call last):

File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main

return _run_code(code, main_globals, None,

File "/usr/lib/python3.10/runpy.py", line 86, in _run_code

exec(code, run_globals)

File "/opt/holoscan/app/main.py", line 3, in

from app import BreastClassificationApp

File "/opt/holoscan/app/app.py", line 4, in

from breast_density_classifier_operator import ClassifierOperator

File "/opt/holoscan/app/breast_density_classifier_operator.py", line 8, in

from monai.data import DataLoader, Dataset

ModuleNotFoundError: No module named 'monai.data'

[2024-05-22 12:01:41,772] [INFO] (common) - Container 'heuristic_perlman'(01deeea6c946) exited.

**Would be great if we could have a complete and working example.

Thanks**

MMelQin commented 5 months ago

@kavmar, thanks for raising the issues on the outdated documentation for this example.

A pull request is being prepared by the contributor, in the meantime, please use the Jupyter notebooks to see the correct commands for running the example applications as script, packaging the application into MONAI Application Package (container image), and running the MAP container.

Below are the root causes of the errors:

@vikashg

MMelQin commented 5 months ago

@kavmar I've gone ahead and created a pull request to fix the issues.

kavmar commented 5 months ago

Thanks a lot. Going to test.

kavmar commented 5 months ago

@MMelQin thanks a lot, I confirm the instructions in breast classifier application example work.

A tiny glitch/request: would be great to support monai-deploy-app-sdk on Ubuntu 24 as well. holoscan is not compatible. I am lucky to have also a box with Ubuntu 22

MMelQin commented 5 months ago

@MMelQin thanks a lot, I confirm the instructions in breast classifier application example work.

A tiny glitch/request: would be great to support monai-deploy-app-sdk on Ubuntu 24 as well. holoscan is not compatible. I am lucky to have also a box with Ubuntu 22

@kavmar I'd love to support Ubuntu 24 as well, and technically it should work.

The Holoscan SDK dependency has only been formally tested on Ubuntu 22.04 LTS. Holoscan V&V encompasses hardware (including ARM/X86 CPU, integrated and discreet GPU), OS, and the software, for the devkit to be capable of being cleared as a medical device.

However, here is the official statement on Holoscan SDK python package: "The Holoscan SDK python wheels are only formally tested on Ubuntu 22.04. They are, however, expected to work on any Linux distribution with glibc 2.35 or above (see output of ldd --version) and CUDA Runtime 12.2 or above."

So, technically on X86 with discreet GPU and Ubuntu 24, Holoscan SDK would work fine, so does MONAI Deploy App SDK.