Skip to content

Instantly share code, notes, and snippets.

@prerakmody
Last active January 5, 2023 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prerakmody/ff37ef6a4f6aee8ee01505b811121ee7 to your computer and use it in GitHub Desktop.
Save prerakmody/ff37ef6a4f6aee8ee01505b811121ee7 to your computer and use it in GitHub Desktop.
Docker Container (for MONAILabel) on Windows 11

Steps

  1. The following steps show how to run the MONAILabel server on Windows via Docker. I have tested these steps on the following software versions:

    Name Version Terminal Command
    Windows Microsoft Windows 11 Pro for Workstations Win Command Prompt systeminfo | findstr /B /C:"OS Name" /B /C:"OS Version
    Nvidia Driver 527.56 Win Command Prompt nvidia-smi --query-gpu=driver_version --format=csv
    Nvidia CUDA Driver API 12.0 Win Command Prompt nvidia-smi
    Nvidia GPU NVIDIA GeForce RTX 2080 Ti Win Command Prompt nvidia-smi --query-gpu=driver_version --format=csv
    WSL 1.0.3.0 Win Command Prompt wsl --version
    WSL Ubuntu 2 Win Command Prompt wsl -l -v
    WSL Ubuntu Release 22.04 (Jammy) WSL Ubuntu Terminal lsb_release -a
    WSL Ubuntu Kernel 5.15.79.1 WSL Ubuntu Terminal uname -a
    WSL Ubuntu Docker 20.10.22 WSL Ubuntu Terminal docker version OR docker --version
    WSL Ubuntu Nvidia Docker 20.10.22 WSL Ubuntu Terminal nvidia-docker --version
    3D Slicer 5.2.1
  2. Ensure you have WSL (Windows Subsystem for Linux) enabled.

    • You need Windows 10 (or greater). Preferably Windows 11
    • Method 1:
      • Follow these steps
      • Install a linux distribution as shown here
      • In a Windows Command Promt or Windows PowerShell you type wsl -l -v to check the available distributions.
    • Method 2:
      • In a command prompt (run as Administrator) run wsl --install.
      • Again type wsl --install to see the list of available distros.
      • For e.g. you can type wsl --install -d Ubuntu. This will then also open up another window with the Ubuntu terminal.
      • Next time to open Ubuntu terminal in the same window, just type wsl -d Ubuntu
      • Type wsl --list to check the installed distributions.
      • You can also move Ubuntu to another directory to preserve space following these steps
    • To remove all distros
      • Type wsl --list or wsl -l -v to see the list of installed distros
      • To uninstall a distro type wsl --unregister <distro-name>
    • WSL Command list (link)
  3. Installing Docker (if you installed WSL Ubuntu)

    • Open Terminal
      • By simply searching in Windows Start menu OR
      • Open a command prompt and type wsl -d Ubuntu
    • Install docker by following these instructions
    • Start docker by typing sudo service docker start and check by sudo service docker status
    • Test docker by typing docker version OR docker run hello-world
    • You can see the downloaded image by docker images
  4. Installing the nvidia-container toolkit in WSL Ubuntu (for WSL Ubuntu docker to be able to access Windows Nvidia GPU)

    • This assumes that your host Windows already has Nvidia drivers installed (i.e. nvidia-smi should work in WIndows terminal)
    • Check if GPU is detected in WSL Ubuntu
      • Run nvidia-smi in WSL Ubuntu terminal. If that works, then simply install nvidia-container toolkit
      • If not, install CUDA toolkit in WSL Ubuntu following these instructions. You can double-check the installation by make(ing) this application.
    • Follow the installation process here for nvidia-container-toolkit.
      • Note: Ubuntu 20.04 and Ubuntu 22.04 packages are symlinked (redirected) to ubuntu18.04
    • Test the installation (assumes docker and nvidia-container toolkit installed)
      • sudo docker run --rm --gpus all nvidia/cuda:12.0.0-base-ubuntu22.04 nvidia-smi
      • Interactive Mode: sudo docker run -it --gpus all nvidia/cuda:12.0.0-base-ubuntu22.04. Then run nvidia-smi
  5. Test if deep learning software installed in WSL Ubuntu is using GPU

    • Download and install Miniconda.
    • Restart WSL Ubuntu terminal to initialize conda on terminal
    • Install pytorch: conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge and then run python -c "import torch; print (torch.cuda.get_device_name())"
    • Install tensorflow: conda install cudatoolkit==11.2.2 cudnn==8.1.0.77 and pip install tensorflow==2.10.0 and export LD_LIBRARY_PATH=/lib64:$LD_LIBRARY_PATH and export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib. Then run python -c "import tensorflow as tf; print (tf.config.list_physical_devices('GPU'))" and this should not show any loading errors.
  6. Run MONAILabel docker (to start the MONAILLabel server in WSL Ubuntu)

    • Reference video (Link)
    • Steps
      • sudo docker run --gpus all --rm -ti --ipc=host --net=host projectmonai/monailabel:latest
      • monailabel apps --download --name radiology --output apps
      • monailabel datasets --download --name Task09_Spleen --output datasets
      • monailabel start_server --app apps/radiology --studies datasets/Task09_Spleen/imagesTr --conf models deepedit
      • Open a web browser on the host Windows machine and type http://localhost:8000/.
  7. Run MONAILabel 3D Slicer Plugin

    • Follow these steps to install the 3D Slicer plugin.
    • <more steps to come>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment