Project-MONAI/tutorials

Kernel hangs in "TCIA_PROSTATEx_Prostate_MRI_Anatomy_Model.ipynb"

KumoLiu opened this issue ยท 11 comments

Describe the bug
Kernel hangs after itkwidgets visualization in jupyter notebook
https://github.com/Project-MONAI/tutorials/blob/main/model_zoo/TCIA_PROSTATEx_Prostate_MRI_Anatomy_Model.ipynb

To Reproduce

  1. docker pull projectmonai/monai:latest
  2. create a new container
  3. run into container
  4. pip install 'itkwidgets[notebook]>=1.0a49'
from monai.transforms import LoadImage
root_dir = "/opt/monai/workspace/Data"
data_dir = os.path.join(root_dir, "Task09_Spleen")
train_images = sorted(glob.glob(os.path.join(data_dir, "imagesTr", "*.nii.gz")))
out = LoadImage(ensure_channel_first=True)(train_images[0])
view(image=out)

Expected behavior
Kernal will not hangs after using view.

Screenshots
Screen Shot 2024-04-17 at 15 46 44

Additional context

  • Look similar to this one:
    InsightSoftwareConsortium/itkwidgets#688
  • After install itkwidgets[notebook]>=1.0a49, look like there will be a requirement compatibility issues for pandas, not sure whether it's related the issue.
Collecting pandas>=2.0.0 (from dask-image->ngff-zarr[dask-image]>=0.4.3->itkwidgets>=1.0a49->itkwidgets[notebook]>=1.0a49)
  Downloading pandas-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (19 kB)
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
cudf 24.2.0 requires pandas<1.6.0dev0,>=1.3, but you have pandas 2.2.2 which is incompatible.
dask-cuda 24.2.0 requires pandas<1.6.0.dev0,>=1.3, but you have pandas 2.2.2 which is incompatible.
dask-cudf 24.2.0 requires pandas<1.6.0dev0,>=1.3, but you have pandas 2.2.2 which is incompatible.
  • After install the itkwidgets and exiting the Jupyter notebook, trying to launch the notebook again leads to a configuration error. It appears that the installation of itkwidgets is causing a disruption in the configuration settings.
Screen Shot 2024-04-17 at 15 51 33

cc @kirbyju @aylward and @thewtex, in case you can shed any light on this issue, it would be greatly appreciated.

Also created a ticket here InsightSoftwareConsortium/itkwidgets#743
Thanks.

Also tried this notebook with pytorch container: nvcr.io/nvidia/pytorch:24.03-py3.
See the same issue.
https://github.com/InsightSoftwareConsortium/itkwidgets/blob/v1.0a50/examples/integrations/MONAI/transform_visualization.ipynb

Thank you for the detailed report on the itkwidget repo. Matt and Brianna are looking into it!

Hello ๐Ÿ‘‹ ,

With itkwidgets 1.0a50, itkwidgets supports JupyterLab 4 and Jupyter Notebook 7. The Jupyter project made these versions major breaking changes. So, there are a few approaches:

a) Update the JupyterLab and Jupyter Notebook version
b) Set the itkwidgets dependency to itkwidgets==1.0a49 until a) can be performed.

After install itkwidgets[notebook]>=1.0a49, look like there will be a requirement compatibility issues for pandas, not sure whether it's related the issue.

This seems to be unrelated in the transitive dependency arena, but a patch is here:

InsightSoftwareConsortium/itkwidgets#744

Testing and feedback to see if it addresses your use cause are appreciated. ๐Ÿ™ Thanks!

Hi @thewtex, thanks for the quick response.
I update the notebook version but the same issue occurred.
Step to reproduce:

docker run -it --ipc=host --rm --net host --gpus all  nvcr.io/nvidia/pytorch:24.03-py3
pip install -U notebook
Then run this notebook: https://github.com/InsightSoftwareConsortium/itkwidgets/blob/v1.0a50/examples/integrations/MONAI/transform_visualization.ipynb

You can see from the screen shot after view even import numpy as not be executed. Also can see the output from view.
Screen Shot 2024-04-17 at 23 54 21

BTW, where can I find the requirement for the notebook, I didn't find it in the requirement. Perhaps I want to try the version which can run in notebook 6.
Thanks!

@KumoLiu thanks for the reproducible example!

Addressed here:

InsightSoftwareConsortium/itkwidgets#745

After it is released, it will be better to install itkwidgets in the containers so all javascript is loaded at startup.

BTW, where can I find the requirement for the notebook, I didn't find it in the requirement. Perhaps I want to try the version which can run in notebook 6.

The dependencies are here:

https://github.com/InsightSoftwareConsortium/itkwidgets/blob/5d83f28c4c076e6227ff4434484e105d57614aa8/pyproject.toml#L37-L92

We keep them as small and light and universal as possible.

Hi @KumoLiu , these improvements have now been released in itkwidgets 1.0a51.

Please try:

docker run -it --ipc=host --rm --net host --gpus all  nvcr.io/nvidia/pytorch:24.03-py3
pip install -U notebook
pip install 'itkwidgets[notebook]==1.0a51'
# Start the notebook

Hi @thewtex, thanks for the quick fix.
I tried with 1.0a51, and the same issue occurred.
In addition, after this command pip install 'itkwidgets[notebook]==1.0a51' and jupyter notebook can not even launched correctly.
Screen Shot 2024-04-18 at 11 29 37

@KumoLiu thanks for testing.

I also observed that error in my testing when I tried installing widgetsnbextension (a different, unrelated package), made for notebook==6 when notebook==7 was installed.

I am wondering if there is something else in your installation?

Could you please try:

docker run -it -p 8888:8888 --ipc=host --rm --net host --gpus all thewtex/monai-1694

or simply build and run the following Dockerfile:

FROM nvcr.io/nvidia/pytorch:24.03-py3

RUN pip install -U notebook
RUN pip install 'itkwidgets[notebook]==1.0a51'
RUN curl -L -o /transform_visualization.ipynb https://raw.github.com/InsightSoftwareConsortium/itkwidgets/main/examples/integrations/MONAI/transform_visualization.ipynb
CMD jupyter notebook /transform_visualization.ipynb

?

You should see:

image

(there is an issue with the last cell, but I have a fix in progress for that).

(there is an issue with the last cell, but I have a fix in progress for that).

This was a side-effect of fixing the pandas dependency issue, but it has been addressed in itkwidgets 1.0a52.