Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM nvidia/opengl:1.2-glvnd-devel-ubuntu22.04

WORKDIR /app

# Avoid buffering the server URL
ENV PYTHONUNBUFFERED=1

# Prevent apt from prompting us about various decisions
ENV DEBIAN_FRONTEND=noninteractive

# Allow driver to do rendering
ENV NVIDIA_DRIVER_CAPABILITIES=all
ENV NVIDIA_VISIBLE_DEVICES=all

# Install trame-slicer dependencies and pyenv build dependencies
RUN apt-get update && apt-get install -y libturbojpeg \
make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl git
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

# Install Pyenv
ENV HOME=/root
ENV PYENV_DIR="${HOME}/.pyenv"
RUN curl -fsSL https://pyenv.run | bash && \
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc && \
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc && \
echo 'eval "$(pyenv init - bash)"' >> ~/.bashrc
ENV PATH="${PYENV_DIR}/shims:${PYENV_DIR}/bin:${PATH}"

# Install SHARED Python3.10
RUN PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.10.18 && \
pyenv global 3.10.18 && \
python -m pip install --upgrade pip

# Install trame-slicer
RUN mkdir trame_slicer
COPY . trame_slicer
RUN pip install --no-cache-dir ./trame_slicer && \
pip install --no-cache-dir https://github.com/KitwareMedical/trame-slicer/releases/download/v1.4.0/vtk_mrml-9.4.0-cp310-cp310-manylinux_2_35_x86_64.whl

RUN chmod +x /app/trame_slicer/docker_run.sh
ENTRYPOINT ["/app/trame_slicer/docker_run.sh"]
35 changes: 35 additions & 0 deletions docker/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
This builds an image launching the medical_viewer_app example in a container with GPU capacities, on 127.0.0.1:8080.

You need nvidia-container-toolkit and up to date NVIDIA drivers to run it.

To build it, use `docker build . -f {Dockerfile_path} -t trame-slicer`

The run command depends on the image:

- WSL
Copy link
Member

Choose a reason for hiding this comment

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

how about adding instructions for CPU (Mesa) rendering.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should I also remove X render instructions as discussed ?

Copy link
Member

Choose a reason for hiding this comment

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

For X, the thing is that you manage to get it to work in another project, so the problem does not seem to come from the docker image. Maybe you can document something like that: the docker image is known to work with a X server, yet no instruction is provided)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added MESA instructions and a warning for X server on WSL. I was able to make it work on Linux.


- To use EGL:

`docker run -p 8080:8080 -it -e MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA -e VTK_DEFAULT_OPENGL_WINDOW=vtkEGLRenderWindow -e LD_LIBRARY_PATH=/usr/lib/wsl/lib -v /usr/lib/wsl:/usr/lib/wsl trame-slicer`

- To use X server: This image is supposed to allow using X server with the following command, but it still uses EGL

`docker run -p 8080:8080 -it -e MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -e LD_LIBRARY_PATH=/usr/lib/wsl/lib -v /usr/lib/wsl:/usr/lib/wsl trame-slicer`

- To use MESA: After removing NVIDIA_DRIVER_CAPABILITIES and NVIDIA_VISIBLE_DEVICES declarations from the Dockerfile

`docker run -p 8080:8080 -it trame-slicer`

- Linux

- To use EGL:

`docker run -it -p 8080:8080 --runtime=nvidia -e VTK_DEFAULT_OPENGL_WINDOW=vtkEGLRenderWindow trame-slicer`

- To use X server:

`docker run -it -p 8080:8080 --runtime=nvidia -v {path to your Xauthority}:/root/.Xauthority -e DISPLAY=$DISPLAY --net host trame-slicer`

- To use MESA: After removing NVIDIA_DRIVER_CAPABILITIES and NVIDIA_VISIBLE_DEVICES declarations from the Dockerfile

`docker run -p 8080:8080 -it trame-slicer`
5 changes: 5 additions & 0 deletions docker/docker_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
python trame_slicer/examples/medical_viewer_app.py --host 0.0.0.0

# Forcer le code de retour à 0
exit 0
Loading