Docker



Installation - 20.04

For both NVidia, get the latest debs served on each group’s apt repo servers (i.e. don’t use Ubuntu’s):

Docker

$ sudo groupadd docker $ sudo usermod -aG docker $USER # Logout, Login $ docker run hello-world

Nvidia

# NVIDIA # https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#setting-up-nvidia-container-toolkit # NB: It uses their 18.04 repo for 20.04, this is OK $ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \ && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \ && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \ sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list $ sudo apt-get update $ sudo apt-get install nvidia-container-toolkit $ sudo nvidia-ctk runtime configure --runtime=docker $ sudo systemctl restart docker $ sudo docker run --rm --runtime=nvidia --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi

Development Environment

 

These instructions are pretty dated. Better work went into groot_rocker, but these days, using vscode devcontainers instead.

Goal

A dockerised development environment that exactly emulates the usual workflows in a non-dockerised environment. The use case is to enable development for a version of the OS one currently doesn’t have installed (e.g. for Ubuntu Xenial or Focal when the installed operating system is Ubuntu Bionic) and the implicit, but critical requirement is that the docker container itself doesn’t subsume any of the tasks (e.g. dependency installation) of the workspace your are building.

Dockerfile

  • Arguments for the user (id/name) to be created within the docker environment

  • Provisions a workspace that can be bound from the local system in ~/workspace.

# Ubuntu images are listed at https://hub.docker.com/_/ubuntu/, can also use 'latest' FROM ubuntu:18.04 LABEL maintainer="Daniel Stonier" # Build Arguments ARG USER_ID=1000 ARG USER_NAME=bob ARG WORKSPACE_DIR="/home/\${USER_NAME}/workspace" # Bash Shell # Compatible User / Group # Basic operating system / development tools RUN adduser --quiet --disabled-password \ --shell /bin/bash --home /home/${USER_NAME} \ --gecos "Daniel Stonier" ${USER_NAME} \ --uid ${USER_ID} && \ apt-get update && \ apt-get -y install apt-utils bash-completion build-essential curl lsb-release sudo wget && \ echo "${USER_NAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ usermod -a -G sudo ${USER_NAME} && \ echo "I'm grooty, you should be too" USER \${USER_NAME} # Use root to debug # USER root # Not sure if this is the best option, just what my non-docker user has, needed by some shell commands. ENV TERM xterm-256color SHELL ["/bin/bash", "--login", "-i"] WORKDIR \${WORKSPACE_DIR} # Used instead of CMD here so it can't be overridden on the command line ENTRYPOINT ["/bin/bash", "--login", "-i"]

Docker Image

Docker Run

Management

Docker + NVidia

Installation - 20.04

Docker

Nvidia