Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Kernel hangs in "TCIA_PROSTATEx_Prostate_MRI_Anatomy_Model.ipynb" #1694

Open
KumoLiu opened this issue Apr 17, 2024 · 11 comments
Open

Kernel hangs in "TCIA_PROSTATEx_Prostate_MRI_Anatomy_Model.ipynb" #1694

KumoLiu opened this issue Apr 17, 2024 · 11 comments

Comments

@KumoLiu
Copy link
Contributor

KumoLiu commented Apr 17, 2024

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

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
@KumoLiu
Copy link
Contributor Author

KumoLiu commented Apr 17, 2024

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.

@KumoLiu
Copy link
Contributor Author

KumoLiu commented Apr 17, 2024

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

KumoLiu added a commit to KumoLiu/tutorials that referenced this issue Apr 17, 2024
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
@aylward
Copy link
Contributor

aylward commented Apr 17, 2024

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

@thewtex
Copy link
Collaborator

thewtex commented Apr 17, 2024

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!

@KumoLiu
Copy link
Contributor Author

KumoLiu commented Apr 17, 2024

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!

@thewtex
Copy link
Collaborator

thewtex commented Apr 17, 2024

@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.

@thewtex
Copy link
Collaborator

thewtex commented Apr 17, 2024

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.

@thewtex
Copy link
Collaborator

thewtex commented Apr 18, 2024

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

@KumoLiu
Copy link
Contributor Author

KumoLiu commented Apr 18, 2024

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

@thewtex
Copy link
Collaborator

thewtex commented Apr 18, 2024

@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).

@thewtex
Copy link
Collaborator

thewtex commented Apr 19, 2024

(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.

Nic-Ma pushed a commit that referenced this issue Apr 22, 2024
Fixes #1692
workaround for #1694 

### Description

- Install dependency required by tcia_utils manually to avoid installing
opencv-python
- comment view command in the notebook

### Checks
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [ ] Avoid including large-size files in the PR.
- [ ] Clean up long text outputs from code cells in the notebook.
- [ ] For security purposes, please check the contents and remove any
sensitive info such as user names and private key.
- [ ] Ensure (1) hyperlinks and markdown anchors are working (2) use
relative paths for tutorial repo files (3) put figure and graphs in the
`./figure` folder
- [ ] Notebook runs automatically `./runner.sh -t <path to .ipynb file>`

---------

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants