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

Updates aide-svrtk MAP with MONAI-based CNN #13

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

alenauus
Copy link
Member

@alenauus alenauus commented Sep 13, 2023

Resolves #10

  • Integration of auto-proc-svrtk MONAI CNN 3D brain recon code into MAP
  • Updated Dockerfile to use latest model weights, and a couple of other changes due to porting code

@tomaroberts
Copy link
Member

tomaroberts commented Sep 13, 2023

TODO:

  • improve folder and file structure so that code can be tested locally easily AND works inside the MAP
    • currently, the code uses a mix of /home directory and /var/monai directory, which causes some pains when trying to test locally.

@tomaroberts tomaroberts changed the title Add MONAI CNN SVRTK Updates aide-svrtk MAP with MONAI-based CNN Sep 13, 2023
@alenauus
Copy link
Member Author

the paths to MIRTK were updated to /bin - the docker script is now copied from https://github.com/SVRTK/auto-proc-svrtk

Copy link
Member

@tomaroberts tomaroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alenauus – the MAP is not quite working yet. See line-by-line comments below for some initial suggestions.

To test your changes, I recommend the following process:

  1. Change line 1 in app/Dockerfile to create new version (0.2.1) of the MAP so you don't conflict with the released version (0.2.0), e.g.:
FROM ghcr.io/svrtk/aide-svrtk/map-init:0.2.1 AS build
  1. Make your changes ...

  2. Build the first stage of the MAP (known as "map-init" – this is a workaround because we need to put SVRTK into the MAP, which is third-party non-Python code):

monai-deploy package app -t ghcr.io/svrtk/aide-svrtk/map-init:0.2.1 -r requirements.txt -l DEBUG
  1. Build the final MAP:
docker build -t ghcr.io/svrtk/aide-svrtk/map:0.2.1 app/
  1. Create input and output directories and put some 2D DICOM stacks in the input folder

  2. Run the MAP to test your changes:

monai-deploy run ghcr.io/svrtk/aide-svrtk/map:0.2.1 input/ output/

Everytime you make a change, repeat steps 3–6.

I expect it will error, but hopefully you should see it at least make some progress. Give that a go and then we can look at the next bits to fix.


WORKDIR /home

# Setup 3D UNet models
RUN git clone https://github.com/SVRTK/Segmentation_FetalMRI.git --branch svrtk-docker-gpu-0.10 --single-branch /home/Segmentation_FetalMRI
RUN git clone https://github.com/SVRTK/auto-proc-svrtk.git /home/auto-proc-svrtk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the errors are to do with this line currently. You've changed the location of the recon Shell script, but not updated the rest of the Dockerfile and Python code to reflect the new script location, so... see other comments where I can see you need to make changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i fixed paths and was able to run monai-deploy run ghcr.io/svrtk/aide-svrtk/map:0.2.1 input/ output/

app/Dockerfile Outdated

# Bugfix: without below, cannot import torch within Python
# Error: OSError: /opt/hpcx/ompi/lib/libmpi.so.40: undefined symbol: opal_hwloc201_hwloc_get_type_depth
# Fix: https://forums.developer.nvidia.com/t/issues-building-docker-image-from-ngc-container-nvcr-io-nvidia-pytorch-22-py3/209034/5
ENV PATH="${PATH}:/opt/hpcx/ompi/bin"
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/hpcx/ompi/lib"

COPY docker-recon-brain-auto.bash /home/scripts/docker-recon-brain-auto.bash
COPY /home/auto-proc-svrtk/scripts/auto-brain-reconstruction-aide.sh /home/scripts/auto-brain-reconstruction.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this line entirely. The COPY command in Docker copies from your local machine into the corresponding place in the container. It fails here because /home/auto-proc-svrtk/scripts/auto-brain-reconstruction-aide.sh doesn't exist in the aide-svrtk repo.

Instead, you clone the auto-proc-svrtk repo into the container further up this file, which means auto-brain-reconstruction.sh will be downloaded into the container already.

One thing I noticed – you have two scripts in here, one of which is labelled "aide". Make sure you are pointing at the correct script.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated thank you

app/Dockerfile Outdated
Comment on lines 74 to 76
RUN mkdir -p /home/recon \
&& mkdir -p /home/output \
&& chmod +x /home/scripts/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most important thing here is the chmod on the scripts folder. This enables the Docker container to run the shell scripts in the folder. You need to update this so that it points at the correct folder in the cloned auto-proc-svrtk repo.

I think you can remove the mkdir lines – I don't think they are needed anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated thank you

Comment on lines +36 to +44
# if torch.cuda.is_available():
# cnn_mode = "1"
# logging.info("SVRTK reconstruction using GPU mode ...")
# if not torch.cuda.is_available():
# cnn_mode = "-1"
# logging.info("SVRTK reconstruction using CPU mode ...")
#
# motion_correction_mode = "-1" # -1 minor, 1 severe
# logging.info("SVRTK reconstruction ...")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not keen on commenting this out. I see you've shifted the cnn_mode/motion_correction_mode variables into the bash script. The problem is that it puts a hard requirement on GPU. In testing, I've found it useful to run in CPU mode.

Leave it for now, but something we can discuss.

Copy link
Member Author

@alenauus alenauus Oct 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the current recon code is fully CPU based (it is fast)

# logging.info("SVRTK reconstruction using CPU mode ...")
#
# motion_correction_mode = "-1" # -1 minor, 1 severe
# logging.info("SVRTK reconstruction ...")

subprocess.run([
"/home/scripts/docker-recon-brain-auto.bash",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line refers to the old recon .bash script. It needs to be updated to reflect the new shell script at the correct location in the container.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, thank you

@alenauus
Copy link
Member Author

alenauus commented Oct 1, 2023

updated paths in the docker file and recon operator & references to auto-svrtk-proc repo

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

Successfully merging this pull request may close these issues.

Update MAP with latest Auto SVRTK reconstruction pipeline
2 participants