-
Notifications
You must be signed in to change notification settings - Fork 10
feat: add a Dockerfile #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Jo-Byr
wants to merge
1
commit into
main
Choose a base branch
from
docker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+81
−0
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
| - 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` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.