as prepared for the Virtual MONAI Label workshop
June 22nd, 2022
Rudolf Bumm (KSGR) and Andres Diaz-Pinto (NVIDIA)
To run MONAI Label locally, you should have a computer with a medium/high-end NVIDIA GPU (16-24 GB totally available video RAM) and CUDA available.
MONAI Label can also be run on CPU, but the performance will lack.
Install Python 3.9 from Windows Store
Use an elevated Powershell (admin mode)
change to (cd) user directory (important, start in a directory with full read/write access)
python -m pip install --upgrade pip setuptools wheel
Install the latest stable version for PyTorch
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
Check if cuda enabled
python -c "import torch; print(torch.cuda.is_available())"
# if false troubleshoot
Install latest monailabel version from Github
git clone https://github.com/Project-MONAI/MONAILabel
pip install -r MONAILabel/requirements.txt
Set MONAILabel script paths
$Env:PATH += ";C:\Users\yourname\MONAILabel\monailabel\scripts"
Download sample apps
monailabel apps # List sample apps monailabel apps --download --name radiology --output apps
Download MSD Datasets
monailabel datasets # List sample datasets monailabel datasets --download --name Task06_Lung --output datasets
Run Segmentation Model.
Options can be (deepedit|deepgrow|segmentation|segmentation_spleen|all) in case of radiology app.
You can also pass comma separate models like –conf models deepedit,segmentation
monailabel start_server --app apps/radiology --studies datasets/Task06_Lung/imagesTr --conf models segmentation
Once you start the MONAI Label Server, by default it will be up and serving at http://127.0.0.1:8000/. Open the serving URL in browser. It will provide you the list of Rest APIs available.
Running MonaiLabel through docker conterization environment will simply installation steps considerably. This is particularly true for GPU support, since Docker will require you to install only the NVIDIA GPU driver and you don’t have to worry about the CUDA environment setup. However, for docker to function you need to have admin (sudo) priviledges on the computer. Instructions here are primarily tested on a Linux environment, but should be applicable to Windows docker as well.
sudo docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi. If this command doesn’t work correctly, you won’t be able to run MonaiLabel with GPU support.
Once you confirmed that NVIDIA docker runtime environment is working correctly for nvidia-smi command above, follow the instructions for MonaiLabel Docker installation.
Changes in docker environments are ephemeral, meaning if you restart your docker session all the changes you made to it will be lost. This would be true for any training session you might have done, any new segmentations you might have pushed to the MonaiLabel server. Therefore, after following the instructions above and confirming that your MonaiLabel docker session is working correctly, you need to modify the docker command to use persistent storage volumes so that changes can be retained. For example, create a Monai folder on your desktop, via command
then you can modify your docker command such that this folder is mapped inside the Docker environment via -v option:
sudo docker run -it --rm --gpus all --ipc=host --net=host -v $USER/Desktop/Monai/:/workspace/ projectmonai/monailabel:latest bash
In this case, contents of $USER/Desktop/Monai will be visible under /workspace folder in docker enviroment. Next, you modify the MonaiLabel server startup scripts to make use of this persistent folder:
monailabel start_server --app /workspace/apps/radiology --studies /workspace/datasets/Task06_Lung/imagesTr --conf models segmentation