NVIDIA docker の インストール




全体の流れ
=============


- [Docker](https://docs.docker.com/linux/step_one/)をセットアップする
- [NVIDIA-docker](https://github.com/NVIDIA/nvidia-docker/wiki/Installation#installing-from-binaries)をインストールする

0. 前提条件
=================

- [g2.2xlargeのインスタンスにログインしていること。リージョンはどこでもOK](http://qiita.com/daikumatan/items/58daff99250d4698d659)
- [K520 用の NVIDIA DriverとCUDAがインストールされていること](http://qiita.com/daikumatan/items/26039fc23edabf76a9c4)



1. docker の インストール
==================


基本[docker](https://docs.docker.com/linux/step_one/)のサイトをそのまま行えば問題なく進みます。

1.1 docker 環境の準備
----------------

```bash:download/install
curl -fsSL https://get.docker.com/ | sh
```

1.2 動作確認
----------------

<!--
なぜかsudoでしか動かせない。。。
-->

```bash:確認コマンド
sudo docker run hello-world
```

```bash:result
sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
4276590986f6: Pull complete 
a3ed95caeb02: Pull complete 
Digest: sha256:4f32210e234b4ad5cac92efacc0a3d602b02476c754f13d517e1ada048e5a8ba
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/
```

2. NVIDIA docker の インストール
====================================

こちらも、[このページ](https://github.com/NVIDIA/nvidia-docker/wiki/Installation#installing-from-binaries)をそのまま実行するだけです。


2.1 NVIDIA docker の インストール
----------------

```bash:download
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.0-rc/nvidia-docker_1.0.0.rc-1_amd64.deb
```

```bash:install
sudo dpkg -i /tmp/nvidia-docker_1.0.0.rc-1_amd64.deb && rm /tmp/nvidia-docker*.deb
```

2.2 NVIDIA docker の 確認
----------------

```bash:確認コマンド
sudo nvidia-docker run --rm nvidia/cuda nvidia-smi
```

```bash:result
Using default tag: latest
latest: Pulling from nvidia/cuda
6599cadaf950: Already exists 
23eda618d451: Already exists 
f0be3084efe9: Already exists 
52de432f084b: Already exists 
a3ed95caeb02: Already exists 
24b2d6bd67a5: Already exists 
50fc465d0eb2: Already exists 
77e34dcfe8aa: Already exists 
b4452c773698: Already exists 
b5d072a31309: Already exists 
a117546727ce: Already exists 
Digest: sha256:cadb56c64e2c09c374b129ccbdaa151204be4c024ecc61ce6e5f13493e92a75a
Status: Downloaded newer image for nvidia/cuda:latest
Fri May  6 02:53:18 2016       
+------------------------------------------------------+                       
| NVIDIA-SMI 352.63     Driver Version: 352.63         |                       
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GRID K520           Off  | 0000:00:03.0     Off |                  N/A |
| N/A   30C    P8    17W / 125W |     11MiB /  4095MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
```


------

__このQiitaの情報は、おいらがプライベートで作っているもので、NVIDIAとは無関係です。個人責任でお試しください。インスタンス等の消し忘れ等ご注意ください。__