Docker and NVIDIA-docker on your workstation: Installation

Hopefully the last post on "Docker and NVIDIA-Docker on your Workstation" provided clarity on what is motivating my experiments with Docker. Being able to run NVIDA GPU accelerated application in containers was a big part of that motivation. In this post I'll go through the basic install and setup for Docker and NVIDIA-Docker.

I'll be using our base DIGITS workstation hardware for the installation since it's sitting on my test-bench. :-) I'll use Ubuntu 16.04 for the workstation OS. I have been doing testing on other systems too; My "gaming" laptop with a GTX 1070 on Ubuntu 16.10, and my older home workstation with a GTX 980 GPU currently running Ubuntu 16.04 (will be experimenting with Ubuntu 17.04 soon).

What Workstation Host OS to use for Docker?

There are Linux distributions that are focused on providing a host environment for Docker like, CoreOS, Atomic, RancherOS, etc.. These specialized "micro" OSs are interesting in their own right but they are not at all what we are interested in for a desktop workstation. For our experiments we want a "standard" Linux workstation desktop distribution for the base OS. Docker is something we are adding to supplement usage of a standard workstation setup. A reasonable choice would be Ubuntu 16.04.

Why Ubuntu 16.04?

It is common well known Linux distribution with an active user community

It is a LTS (long term support) version

There are several optional Desktop user interfaces to chose from

It is a base distribution for other popular distributions such as Linux Mint

It is up-to-date and maintained to provide recent versions of common desktop applications

It should be possible to use any Linux distribution that supports Docker but starting with Ubuntu 16.04 seems "reasonable".

I normally do Ubuntu installs by starting with a simple server install and then add a desktop interface on top of that. It's quick and can be scripted. Following is a simple, lightly commented script that would setup the desktop. [Note: I'm using MATE because I like it] Of course you will need to run this script (or the individual commands) using sudo.

How to install Docker Engine

The next step is to get Docker engine on the system. Docker has installation instructions for several Linux distributions. There are currently instructions and deb packages for Ubuntu 14.04 (Trusty), 16.04 (Xenial) and 16.10 (Yakkety). [ There were incorrect instructions for proper Ubuntu repo configuration for several months but as of this writing it looks OK ]. The install and initial configuration follows as a series of commands to be run using sudo.

Add your login user name to the docker group so you can run docker commands without being root

usermod -aG docker yourLoginUsername

Enable docker to start on boot

systemctl enable docker

Note: The commands above will give you a "normal" docker install and setup. In the next post in this series I will discuss using kernel user-namespaces for a more secure "single user workstation" setup.

How to Install NVIDIA-Docker

One of the driving factors for investigating Docker on the desktop is that NVIDIA GPUs can be cleanly accesses from containers now. I wouldn't have considered it there had not been a good way to access the GPU hardware for compute. The reason that this is a problem in the first place is that the graphics driver is in kernel space and Docker is not able at this time to directly special drivers like this. NVIDIA has created a wrapper and daemon to make the GPU available to containers without a driver install in the container. This allows running GPU accelerated applications in containers.

Fortunately NVIDA has a deb file that will install and setup NVIDIA-Docker easily on Ubuntu 16.04. Ubuntu 14.04 and CentOS versions should also work well.

I recommend that you go to the main "nvidia-docker" GitHub page and read what it there. You will find installation instructions however, I do recommend that you have a look at the release page to check for the latest build. As of this writing the build was 1.0.0 (yay! it's at version 1) You can download the deb file from your browser or you could use wget

That should install the nvidia-docker service and the nvidia-docker-plugin and have them configured to start automatically on boot.

Note for Ubuntu 16.10: as of this writing, the install fails to configure the systemd service file for nvidia-docker-plugin on Ubuntu 16.10. This daemon can be started manually from the command line with

sudo -b nohup nvidia-docker-plugin > /tmp/nvidia-docker.log

We have made several configuration changes on the system with new services and adding our user to another group. Before testing the install it would be good to go ahead and reboot the system to be sure all of the services start up correctly. [ I didn't have any trouble with Ununtu 16.04 ]

...reboot

For a quick test of your main Docker setup you can try the following.

docker run --rm hello-world

That will give you a "hello-world" with a bit of an explanation of what just happened. We will look at details of using the docker command and examples in later posts.

To test NVIDIA-Docker try the following,

nvidia-docker run --rm nvidia/cuda nvidia-smi

That nvidia-docker command will pull down a NVIDA CUDA image from the NVIDIA repository on Docker Hub based on Ubuntu 14.04 libs and CUDA 8 and then run then system management interface nvidia-smi. That will show you some general information about your GPU from within the container. There is a lot going on the first time you do that command. If you run it again it will start a new container and run that command almost instantly.

In the next post on this Docker Desktop setup we will make some configuration changes to get a more secure and sensible configuration using "user-namespaces". We'll also do some more interesting examples including connecting a container to the display!

Happy computing! --dbk

Tags: Docker, NVIDIA-docker, GPU

Related Articles

Tagged

Subscribe

Hi, I was trying to use the nvidia-docker to play with nvidia-digits. However, I am a bit confused about how to get training images into digits since using the digits-root folder to import feature images or labels would result in an invalid path. Do you happen to know how to load them?