Skip to content

Instantly share code, notes, and snippets.

@sentient
Last active June 27, 2017 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sentient/9e723feada552666e1d1b9bcd4134760 to your computer and use it in GitHub Desktop.
Save sentient/9e723feada552666e1d1b9bcd4134760 to your computer and use it in GitHub Desktop.
Notes on CUDA docker installation

Notes setting up NVidia Docker

My laptop:

Ubuntu 16.04 with GPX 1070 (System76, Oryx Pro)

Install the NVIDIA driver

[http://support.system76.com/articles/cuda/]

From [https://developer.nvidia.com/cuda-downloads]

$ wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb
$ sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb

[https://github.com/NVIDIA/nvidia-docker/wiki/Installation]

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install cuda

Verify

$ nvidia-smi 
Wed Mar 22 07:54:12 2017       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.39                 Driver Version: 375.39                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1070    Off  | 0000:01:00.0      On |                  N/A |
| N/A   44C    P0    30W /  N/A |   1814MiB /  8080MiB |      3%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0      1370    G   /usr/lib/xorg/Xorg                            1153MiB |
|    0      3906    G   ...s-passed-by-fd --v8-snapshot-passed-by-fd   117MiB |
|    0     17228    G   compiz                                         540MiB |
+-----------------------------------------------------------------------------+

Running samples

The included source code references a hardcoded prior nvidia driver. You must update this. For the 375 driver version, update by

find /usr/local/cuda-8.0/samples -type f -exec sed -i 's/nvidia-3../nvidia-375/g' {} +

The libraries that are linked by the examples are in /usr/lib/nvidia-375/

Copy all the files to a local folder and run 'make'

Install docker-engine

(Do NOT install docker.io)

https://docs.docker.com/engine/installation/linux/ubuntu/

Install packages to allow apt to use a repository over HTTPS:

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

(Nothing new installed)

$ curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add -

$ sudo apt-key fingerprint 58118E89F3A912897C070ADBF76221572C52609D

$ sudo add-apt-repository \
       "deb https://apt.dockerproject.org/repo/ \
       ubuntu-$(lsb_release -cs) \
       main"

New repository is added to

$ more /etc/apt/sources.list

Update sources and install docker-engine

$ sudo apt-get update

$ sudo apt-get -y install docker-engine

Verify

docker -v
Docker version 17.03.0-ce, build 60ccb22

It is still called xxx-ce. But nvidia-docker works with it

Docker permissions

Make sure you have the right permission to run the docker binaries. Adding your user account to the group 'docker'

  $ sudo usermod -aG docker {user}

Verifiy with 'groups {user}'

Test if you can run the following command without any issues. (I need a logout and login. There must be a better way for that)

 $ docker stats

Installing nvidia-docker

  $ wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
  $ sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb

verify with running a simple docker test

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

Install Keras

Get the docker file (And all other keras goodies)

git clone https://github.com/fchollet/keras.git
cd keras\docker

Create an interactive python shell

make ipython
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment