-
Notifications
You must be signed in to change notification settings - Fork 4.3k
CNTK Docker Containers
You can set up CNTK as a Docker Container on your Linux system.
First you need to install docker. It is highly recommended to follow the installation process in the official docker documentation. Versions that come with your Linux distribution might be outdated and will not work with nvidia-docker
(which you may need to install in addition to docker if you plan to build the GPU image). You should also follow the instructions in the optional section titled creating a docker group.
The correspondent Docker files are in the CNTK Repository at https://github.com/Microsoft/CNTK/tree/master/Tools/docker
To build a docker image with CNTK and all its dependencies, simply clone the CNTK repository, navigate to CNTK/Tools/docker
and use the Dockerfile you want to build from (either CPU only or CPU+GPU). For example, to build CNTK's GPU docker image execute
docker build -t cntk CNTK-GPU-Image
If you receive errors that say Could not resolve 'archive.ubuntu.com'
you will need to modify the file /etc/default/docker
. First find
the IP addresses of your DNS servers using, for example, the command
nm-tool
or the command
nmcli dev show
Then edit /etc/default/docker
so that the line
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
is uncommented and contains the IP addresses of your DNS servers.
Note that some companies block public DNS servers such as 8.8.8.8
and 8.8.4.4. You can try using them but if the problem persists
you should try to use the DNS server IP addresses reported by nm-tool/nmcli
.
(Another possibility is to modify /lib/systemd/system/docker.service
and pass the --dns
options directly to the docker daemon there)
Restart the docker daemon via
sudo service docker restart
and delete any docker images that where created with the wrong DNS settings. To delete all docker images do
docker rmi $(docker images -q)
To delete all docker containers do
docker rm $(docker ps -a -q)
Now try again
docker build -t cntk CNTK-GPU-Image
If you have a GPU you'll want to test if you can access it through a docker container once you have built the image. Try this command:
docker run --rm cntk nvidia-smi
If it works, you are done. If it doesn't, it means that there is a mismatch between the CUDA version and/or drivers installed on your host and in your cntk docker image. Fortunately this is easy to fix. Just install nvidia-docker and use it exactly like docker (no need to rebuild the image)
nvidia-docker run --rm cntk nvidia-smi
This should work and enables CNTK to use the GPU from inside a docker container.