Skip to content

Using Docker and GPU Acceleration

Florian Spiess edited this page Jun 13, 2022 · 1 revision

As there is currently no official GPU enabled Docker image for Cineast, this short guide should provide all the necessary information to get started.

Prepare Host

While Docker allows us to use CUDA without tediously installing it on our host machine, we need to install the NVIDIA GPU driver, the NVIDIA container runtime and Docker. If you have already installed these, you can skip ahead to the step Docker Image.

Please keep in mind, that the concrete steps may become outdated and you should always check the official websites for the most current instructions.

(Optional) Disable Sleep and Hibernation

For some reason, some versions of the NVIDIA server GPU drivers install a desktop environment and enable sleep and hibernation, which can cause your server to become unresponsive until woken up through a USB connected device. To prevent this, you can preemptively disable sleep and hibernation as follows:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

NVIDIA GPU Driver

  1. Find out which drivers are available: apt list "nvidia-driver-*"
  2. Install most recent server driver, e.g.: sudo apt install nvidia-driver-510-server
  3. sudo reboot

NVIDIA Container Runtime

curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo apt update
sudo apt install nvidia-container-runtime

Install Docker

Please follow the official documentation.

Docker Image

To use the GPU capabilities of the TensorFlow based Cineast features, you will need a Docker image with the correct version of CUDA installed. For the best chance of success, we recommend basing this Docker image off of the official TensorFlow Docker image, as this should contain the right versions of binaries required by TensorFlow Java.

# Use tf-gpu image
FROM tensorflow/tensorflow:latest-gpu

# Install required tools
RUN apt update && apt install openjdk-17-jdk-headless -y

To start the container, you will need to enable GPU passthrough, mount your data and Cineast directories and modify your user in the container to set the correct user ID for output written to the host file system:

docker run --gpus all -it --rm -v /host/data/:/data/ -v /host/cineast/:/cineast/ -u "$(id -u "$USER")" cuda-java:latest