├── .gitignore ├── Dockerfile.base ├── Dockerfile.devel ├── Dockerfile.runtime ├── LICENSE ├── README.md ├── build.sh ├── cleanup.sh ├── run-base.sh ├── run-devel.sh └── run-runtime.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | apt-trusted-keys 3 | var -------------------------------------------------------------------------------- /Dockerfile.base: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:experimental 2 | FROM ubuntu:18.04 3 | LABEL maintainer "Ralf Sippl " 4 | 5 | ENV CUDA_VERSION 10.0 6 | ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn 7 | 8 | COPY apt-trusted-keys /tmp/ 9 | 10 | RUN apt-get update && apt-get install -y gnupg2 && apt-key add /tmp/apt-trusted-keys && \ 11 | echo "deb file:///var/cuda-repo /" > /etc/apt/sources.list.d/cuda.list && \ 12 | echo "deb http://international.download.nvidia.com/jetson/repos/common r32 main" > /etc/apt/sources.list.d/nvidia-l4t-apt-source.list && \ 13 | echo "deb http://international.download.nvidia.com/jetson/repos/t210 r32 main" >> /etc/apt/sources.list.d/nvidia-l4t-apt-source.list 14 | 15 | # Mount local CUDA apt repo only during build, to reduce image size 16 | RUN --mount=type=bind,readonly,source=/var/cuda-repo,target=/var/cuda-repo \ 17 | apt-get update && \ 18 | apt-get install -y cuda-cudart-$CUDA_VERSION && \ 19 | rm -rf /var/lib/apt/lists/* 20 | 21 | RUN ln -s /usr/local/cuda-$CUDA_VERSION /usr/local/cuda 22 | 23 | ENV LD_LIBRARY_PATH /usr/lib/aarch64-linux-gnu/tegra 24 | 25 | ENV NVIDIA_VISIBLE_DEVICES all 26 | ENV NVIDIA_DRIVER_CAPABILITIES compute,utility 27 | ENV NVIDIA_REQUIRE_CUDA "cuda>=10.0" 28 | -------------------------------------------------------------------------------- /Dockerfile.devel: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:experimental 2 | 3 | # Base image, usually cuda-jetpack:4.2.1-runtime 4 | ARG BASE_IMAGE 5 | FROM ${BASE_IMAGE} 6 | 7 | LABEL maintainer "Ralf Sippl " 8 | 9 | # Mount local CUDA apt repo only during build, to reduce image size 10 | RUN --mount=type=bind,readonly,source=/var/cuda-repo,target=/var/cuda-repo \ 11 | apt-get update && \ 12 | apt-get install -y \ 13 | cuda-libraries-dev-$CUDA_VERSION \ 14 | cuda-nvml-dev-$CUDA_VERSION \ 15 | cuda-minimal-build-$CUDA_VERSION \ 16 | cuda-command-line-tools-$CUDA_VERSION \ 17 | cuda-samples-$CUDA_VERSION \ 18 | && rm -rf /var/lib/apt/lists/* 19 | -------------------------------------------------------------------------------- /Dockerfile.runtime: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:experimental 2 | 3 | # Base image, usually cuda-jetpack:4.2.1-base 4 | ARG BASE_IMAGE 5 | FROM ${BASE_IMAGE} 6 | 7 | LABEL maintainer "Ralf Sippl " 8 | 9 | # Mount local CUDA apt repo only during build, to reduce image size 10 | RUN --mount=type=bind,readonly,source=/var/cuda-repo,target=/var/cuda-repo \ 11 | apt-get update && \ 12 | apt-get install -y \ 13 | cuda-libraries-$CUDA_VERSION \ 14 | cuda-nvtx-$CUDA_VERSION \ 15 | && rm -rf /var/lib/apt/lists/* 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 jetsistant 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-cuda-jetpack 2 | Docker containers for CUDA with GPU acceleration, running on Nvidia Jetson. 3 | 4 | Tested on a Jetson Nano, using Docker 18.09.2. **Make sure you're on JetPack 4.2.1.** 5 | 6 | Use the build.sh script to build the containers. Then use one of the run-....sh scripts. You'll have to enter your root password. 7 | 8 | There are three containers: 9 | 10 | * `base`: bare minimum to deploy pre-built CUDA app 11 | * `runtime`: extends *base* adding all shared libs from the CUDA toolkit. Use if you have pre-built apps using multiple CUDA libs 12 | * `devel`: the 'real thing' for development; extends *runtime* by adding the compiler, debugging tools, headers, static libs and the CUDA samples 13 | 14 | Here's how you can use the `devel` container to run one of the CUDA samples: 15 | 16 | ```bash 17 | ./run-devel.sh 18 | cp -r /usr/local/cuda/samples /tmp 19 | cd /tmp/samples/5_Simulations/nbody 20 | make 21 | ./nbody 22 | ``` 23 | 24 | For more details, see the [nvidia-docker wiki](https://github.com/NVIDIA/nvidia-docker/wiki/NVIDIA-Container-Runtime-on-Jetson) (instead of `nvcr.io/nvidia/l4t-base:r32.2`, use `cuda-jetpack:4.2.1-devel`). 25 | 26 | Also available on Docker Hub: https://hub.docker.com/r/jetsistant/cuda-jetpack 27 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | mkdir -p var 5 | 6 | if ! [ -x "$(command -v rsync)" ]; then 7 | echo 'rsync needs to be installed!' 8 | sudo apt-get install -y rsync 9 | fi 10 | 11 | echo 'Syncing files for local CUDA apt repo...' 12 | rsync -aq /var/cuda-repo-10-0-local-10.0.326/ var/cuda-repo 13 | 14 | echo 'Exporting repo keys...' 15 | export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn 16 | apt-key exportall > apt-trusted-keys 17 | 18 | echo 'Building cuda-jetpack:4.2.1-base container...' 19 | sudo DOCKER_BUILDKIT=1 docker build \ 20 | -t cuda-jetpack:4.2.1-base \ 21 | -f Dockerfile.base . 22 | 23 | echo 'Building cuda-jetpack:4.2.1-runtime container...' 24 | sudo DOCKER_BUILDKIT=1 docker build \ 25 | -t cuda-jetpack:4.2.1-runtime \ 26 | --build-arg BASE_IMAGE=cuda-jetpack:4.2.1-base \ 27 | -f Dockerfile.runtime . 28 | 29 | echo 'Building cuda-jetpack:4.2.1-devel container...' 30 | sudo DOCKER_BUILDKIT=1 docker build \ 31 | -t cuda-jetpack:4.2.1-devel \ 32 | --build-arg BASE_IMAGE=cuda-jetpack:4.2.1-runtime \ 33 | -f Dockerfile.devel . 34 | 35 | sudo docker tag cuda-jetpack:4.2.1-runtime cuda-jetpack:latest -------------------------------------------------------------------------------- /cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | rm -rf var apt-trusted-keys 5 | 6 | # BEWARE, this removes all containers 7 | docker system prune -a 8 | -------------------------------------------------------------------------------- /run-base.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | sudo docker run --runtime nvidia -it --rm cuda-jetpack:4.2.1-base 4 | -------------------------------------------------------------------------------- /run-devel.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | sudo xhost +si:localuser:root 4 | sudo docker run --runtime nvidia -it --rm --network host -e DISPLAY=$DISPLAY \ 5 | -v /tmp/.X11-unix/:/tmp/.X11-unix cuda-jetpack:4.2.1-devel 6 | -------------------------------------------------------------------------------- /run-runtime.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | sudo docker run --runtime nvidia -it --rm cuda-jetpack:4.2.1-runtime 4 | --------------------------------------------------------------------------------