Workflow with Docker and Slicer

Hi,

I’am a scientist and working with Slicer build inside a docker image but I want make some upgrade in a workflow and add SlicerJupyter extension. I have a dream that I am preparing a docker image for my friends in team. In last few days I did some research about your solution with docker but I got lost in this topic. What need I to create a dream workflow:

  • Create docker image with build version Slicer Qt5 (always need builded version because I working with own extensions
  • Build and install to Slicer SlicerJupyter extension(this will allow me to accelerate my work considerably and simply - JUPYTER is awesome)
  • Redistribute created image.
    Now I have only working version with Slicer Qt4 but for this version I can’t build SlicerJupyter.

Have you got some suggestion how I can improve that workflow? What image (for example from https://github.com/thewtex/SlicerDocker) should I use? And what do if my computer has Nvidia and other ATI or Intel graphic cards? Should I install all drivers?

Regards,
Darek

Hi Darek -

You can have a look at my dockerfiles. It should be no problem to get a latest nightly build and install the jupyter extension in a dockerfile. Then you can push the result back to dockerhub or other repository.

This will provide a software rendering layer with vnc access for the browser (not GPU accelerated but still typically quite usable).

1 Like

Thank you for your reply. I have got your solution before and additionaly I have installed X11 and nvidia drivers inside. Then connect to container with volume /tmp/X11 and share $DISPLAY. Works great but now I have simplier solution as I think:
I get out from docker packed Slicer nightly build and packed SlicerJupyter and working on this. Then I have gave a chance for https://github.com/Slicer/SlicerBuildEnvironment: build Slicer and SlicerJupyter but with this envoronment I dont know why Slicer (when I connect to SlicerJupyter) has 100% CPU usage.
Well now I have working nightly Slicer from pieper/SlicerDockers extracted and I build my extension through SlicerBuildEnvironment and copy libs.

Sounds great - if you have any examples of installing nvidia drivers or running jupyter through Slicer in docker please post.

I have been working with Docker and Slicer around 2 years and I installed packages in the docker by trial and error (I have never successfully compile Qt 4 and 5). Probably it’s nothing revealing:

  • I use Ubuntu 16.04 image(with 18 I have compile errors),
  • Download prebuilt qt unified version,
  • Install dependencies etc https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Instructions, after successfully building process I test Slicer on my laptop with GTX 980m and of course in docker I have got errors. Simple solution:
  • Install nvidia drivers but carefully. I have on my host a nvidia-396 drivers and the same drivers must be installed in docker(now Slicer is running),
  • Install dependencies for SlicerJupyter:
  sudo apt-get install libicu-dev
  sudo apt-get install uuid-dev
  • Build SlicerJupyter based on previously built Slicer,
  • Create conda environment and connect Slicer with Jupyter.
    I run docker with this script:

#!/bin/bash
xhost +local:docker
PATH_TO_EHDD=$1
docker run\
–privileged\
-v $PATH_TO_EHDD/software:/home/software:rw\
-v /dev:/dev/:ro\
-e QT_X11_NO_MITSHM=1\
-e DISPLAY=$DISPLAY\
-v /tmp/.X11-unix/:/tmp/.X11-unix:ro\
–user broncho\
-it slicer_jupyter:nv /bin/bash

Explanation of some parameters:
-v /dev/:/dev/
I need this volume because I use sensors on /dev/ttyACM*

-e DISPLAY=$DISPLAY\
-v /tmp/.X11-unix/:/tmp/.X11-unix:ro\
It allows me to run GUI programs like Slicer

Now as I said before I packed Slicer and SlicerJupyter and working with it outside the docker on the host. JupyterLab is my current IDE.
Remember that when you are move Slicer executables(for example working on a packaged version) you need to change paths in this two files: kernel.json and AdditionalLauncherSettings.ini

It is great that you find Slicer and SlicerJupyter useful. Thanks for sharing information about how your setup works.

Note that Slicer can install when you click “Install Slicer kernel in Jupyter” then it updates the path in the kernel file and installs it. I’ve updated JupyterKernel module to make this feature available from Python (so that you can automate it as part of the installation process).

If you package the extension and install the extension from file it using the extension manager (by calling slicer.app.extensionsManagerModel().installExtension()) then you don’t need additional launcher settings, because all the libraries are installed into standard locations where Slicer can find them automatically.

See this issue: JupyterKernel uses 100% CPU when idle · Issue #16 · Slicer/SlicerJupyter · GitHub
It would be nice if you could give it a try to solve this problem.

Hi Andras,

I always do what you wrote, but it doesn’t update kernel.json. After click “Install Slicer kernel in Jupyter” it fills the template with paths to SuperBuild/Slicer-build not to for example Slicer-2018.08.20-amd64/. Tested few times. I give a try for slicer.app.extensionsManagerModel().installExtension(), because can’t install builded and packed SlicerJupyter through GUI extension manager.

Maybe I will find some time in a break from my doctorate.

Could you start Slicer using Jupyter, enter these commands and let us know what you got as output?

print slicer.app.launcherExecutableFilePath
print slicer.app.applicationFilePath()

Is this an installed Slicer or a custom-built Slicer run from the build tree?
Is this an SlicerJupyter package installed or a custom-built SlicerJupyter left in the build tree?

I’ve updated SlicerJupyter with an option to use a timer instead of watching socket changes. This option (JUPYTER_POLL_USING_TIMER) is enabled on Windows by default. Could you check if you build SlicerJupyter with this option enabled then your 100% CPU usage problem is resolved?

Answering to kernel.json:

  1. I did something wrong with kernel-template.json(doesn’t exists). Works now.

  2. I have a custom-build Slicer with built in SlicerJupyter. I used this script: https://github.com/Slicer/SlicerBuildEnvironment/issues/8, because I can’t built SlicerJupyter standalone what is write here https://github.com/Slicer/SlicerBuildEnvironment#configure-build-and-package-a-slicer-extension-for-linux. I have an error:

    ninja: error: unknown target ‘package’

  3. Yes, I’m tracking an extension on github and I’m going answer there.