Changes

Jump to navigation Jump to search

Tutorials:Install the nVidia docker system

1,583 bytes added, 6 years ago
m
Install the correct docker version
Unfortunately, the docker version available with the usual package manager is incompatible with the nVidia docker tools. Thus, we have to install a version directly from the repositories. The following script (which needs sudo privileges to run) shows you how.
 
NOTE: The following scripts require <code>curl</code>, which may be not yet installed on your system (especially on a fresh Ubuntu). If so, install with <code>sudo apt-get install curl</code>.
<syntaxhighlight lang="bash">
Note that the string "bionic" is the output of the command "lsb_release -cs". If you have another version of Ubuntu than 18.04, you can try to replace "bionic" with the output of this command, but it might not be supported. On a derivative Linux, this does not work, and you need to find out the correct Ubuntu lsb release by consulting their documentation. Do the same for similar occurences in scripts further below.
You also need a more recent version of a tool called "docker-compose", more on this later.Install the latest version like this: <syntaxhighlight lang="bash">sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-composesudo chmod +x /usr/bin/docker-compose</syntaxhighlight> Post install, you have to allow docker access for your account. Note that this comes which with a bunch of privileges which are essentially equivalent to admin rights on your machine. Thus, some guides recommend to set up a special user account for this. Anyway, assign the respective rights by adding your user to the docker group:
<syntaxhighlight lang="bash">
After that, it is at least necessary to log out and back in to update the privileges, but a reboot also can not hurt.
 
== Installing the nVidia docker extension ==
# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerdsystemctl restart docker
</syntaxhighlight>
<syntaxhighlight lang="bash">
docker run --runtime=nvidia --rm nvidia/cuda:9.0-devel nvcc --version
</syntaxhighlight>
<syntaxhighlight lang="bash">
docker run --runtime=nvidia --rm nvidia/cuda:9.0-devel nvidia-smi
</syntaxhighlight>
This should show a similar output as when you run it directly, i.e. show the same graphics card(s).
 
== Access the containers on the nVidia GPU cloud ==
then everything is fine. When you are done testing, just enter the line "quit()" to exit the Python interpreter, which will also terminate the container.
 
 
 
== Making nvidia-docker the default runtime (optional) ==
 
You will note that you always had to select "--runtime=nvidia" for every docker command which runs a GPU container. This is fine in principle, but if you do it on a regular basis (or if you want to set up your own kubernetes minikube for testing), you might wish to make this the default.
 
For this, edit /etc/docker/daemon.json to look as follows (it will also configure a larger amount of memory, which is recommended for tensorflow):
 
<syntaxhighlight lang="json">
{
"default-runtime": "nvidia",
"default-shm-size": "1g",
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
</syntaxhighlight>
 
After you did this, you need to restart your docker daemon for the changes to go into effect:
 
<syntaxhighlight lang="bash">
sudo systemctl restart docker
</syntaxhighlight>
 
Note that it remembers all running containers and will restart them once it is back up.
You are now ready for the next tutorial, which will show you how to use the nVidia GPU cloud images as a basis for your own applications.
 
 
 
 
 
 
[[Category:Tutorials]]
ccu
2
edits

Navigation menu