diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..f8c142b --- /dev/null +++ b/docker/Dockerfile @@ -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"] diff --git a/docker/README b/docker/README new file mode 100644 index 0000000..7766621 --- /dev/null +++ b/docker/README @@ -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 + + - 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` diff --git a/docker/docker_run.sh b/docker/docker_run.sh new file mode 100644 index 0000000..9b869f6 --- /dev/null +++ b/docker/docker_run.sh @@ -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