The NVIDIA NGC Catalogue holds a register of readily available docker images that make installing complex software for the GPU much less complex. Here is the workflow that needs to happen for every one of the images. For more in depth information check the official NGC docker documentation here.
NVIDIA drivers and toolkit
You need the NVIDIA GPU drivers installed, for example by checking the box upon instance creation. Additionally you need the NVIDIA CUDA toolkit.
wget https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run sudo sh cuda_10.1.105_418.39_linux.run --silent --toolkit export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}$ export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
For a complete guide on the driver and toolkit installation check this support article.
NVIDIA docker toolkit
The NVIDIA Container Toolkit allows one to build and run GPU accelerated Docker containers. This is the official repo in case something does not work with the installation.
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/a$ sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
Docker
A more complete guide on how to install docker can be found in the docker documentation. Nevertheless here are the basic steps.
sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" # verify that you have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 sudo apt-key fingerprint 0EBFCD88 sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io
Pulling and running the docker containers
You should be all set! Select the docker container you want to run and pull it using the command given in the NGC catalogue. When running it make sure to include the --gpus all
flag to activate the GPU support.