Deep Learningç°å¢ã¯Keras + Docker + Jupyter Notebook + GPUãããã«ã³ã¸
ã¯ããã«
- ããããKerasåããã®ã«ã©ã®ãããªç°å¢ãããã®ãèãã¦ã¿ã¾ãã
- Keras + Docker + Jupyter Notebook + GPUã®ç°å¢æ§ç¯ä½æ¥ãã°ãç´¹ä»ãã¾ã
Keras
- ããããããã¤ã³ã¿ã¼ãã§ã¼ã¹ãããªã好ã
Docker
- TensorFlowã§å¦ã¶ãã£ã¼ãã©ã¼ãã³ã°å
¥éï½ç³ã¿è¾¼ã¿ãã¥ã¼ã©ã«ãããã¯ã¼ã¯å¾¹åºè§£èª¬ ãåèã«ãã¾ãã
- ãã®æ¬ã§ã¯Dockerã使ç¨ãã¦ã¾ã
- å½åã¯virtualenv使ç¨ãã¦ç°å¢ä½ãäºå®ã ã£ãã®ã§ãåå¼·ã«ãªãã¾ãã
- ç°å¢ã®ç§»æ¤æ§ããã
- GPU使ç¨ã§ããã®ããã
Jupyter Notebook
- è¨ãããããª
GPU
- éãã¯æ£ç¾©
ææ
- GCPã®Datalabã§BigQuery, GCS, åæ£TensorFlow使ç¨ã§ããããã«ãªãã¨æé«
- AWSã§ããã¿ã³ããã§ç°å¢æ§ç¯ã§ããããã«ãªã£ã¦æ¬²ãã
Keras + Docker + Jupyter Notebook + GPUã®ç°å¢æ§ç¯
åæ
GPUでTensorFlowを動かす - もょもとの技術ノート
- GPUç°å¢ ï¼ NVIDIAã¾ããã®ãããããã¤ã³ã¹ãã¼ã«ããã¦ãããã¨
- GPUã§TensorFlowã稼åãããã¨
NVIDIAãã©ã¤ãå ¥ãç´ã
ä¸è¨ã§ã¯NVIDIAãã©ã¤ããæåã§ã¤ã³ã¹ãã¼ã«ãã¾ãããããã¼ã¸ã§ã³ã®ç¸æ§ãããï¼ã¾ããããï¼ãapt-getã§ã¤ã³ã¹ãã¼ã«ãç´ãã¾ãããã¨ãããNVIDIAãã©ã¤ããã¤ã³ã¹ãã¼ã«ãç´ãã¨OSãèµ·åããªããªã£ãã®ã§ãçµå±OSããåã¤ã³ã¹ãã¼ã«ãã¾ããã
$ sudo add-apt-repository ppa:graphics-drivers/ppa $ sudo apt-cache search nvidia-\d+ nvidia-352 - Transitional package for nvidia-361 mate-sensors-applet-nvidia-dbg - Display readings from hardware sensors in your MATE panel (NVIDIA, dbg package) nvidia-304 - NVIDIA legacy binary driver - version 304.132 nvidia-304-updates - Transitional package for nvidia-304 nvidia-340 - NVIDIA binary driver - version 340.98 nvidia-355 - NVIDIA binary driver - version 355.11 nvidia-358 - NVIDIA binary driver - version 358.16 nvidia-361 - NVIDIA binary driver - version 361.45.18 nvidia-364 - NVIDIA binary driver - version 364.19 nvidia-367 - NVIDIA binary driver - version 367.44 nvidia-370 - NVIDIA binary driver - version 370.28 $ sudo apt-get install nvidia-370
Docker
- å
¬å¼ãµã¤ãéãã«å®æ½
- å ¨ãèºããªãã£ã
- Ubuntu 16.04 (LTS)ã使ç¨
nvidia-docker
- DockerããGPUæä½ã§ããããã«ãããå°å ¥
$ wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.0-rc.3/nvidia-docker_1.0.0.rc.3-1_amd64.deb $ sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb # Test nvidia-smi $ sudo nvidia-docker run --rm nvidia/cuda nvidia-smi
注æ
- ä»åã¯Dockerã°ã«ã¼ãä½æããªãã£ãã®ã§ãdocker, nvidia-dockerã³ãã³ãã®ã¾ãã«ãã¹ã¦sudoã¤ãã¾ãã
ãã¡ã¤ã¢ã¦ã©ã¼ã«éæ¾
$ sudo ufw enable $ sudo ufw allow 8888 $ sudo ufw status $ sudo ufw status ç¶æ : ã¢ã¯ãã£ã To Action From -- ------ ---- 8888 ALLOW Anywhere 8888 (v6) ALLOW Anywhere (v6)
Dockerèµ·å
$ sudo nvidia-docker run -m 10g -it -p 8888:8888 gcr.io/tensorflow/tensorflow:0.10.0-gpu
- 0.11ã¯Kerasã¨ã®ç¸æ§ãæªãã£ãããã0.10ã使ç¨
- out of memoryã¨ã©ã¼åºãã®ã§ã -m ã§å¤ãã«ã¡ã¢ãªç¢ºä¿
- 2GBããã°ååããª
$ sudo docker stats CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS 8661fc7f4cea 1.42% 1.345 GiB / 10 GiB 13.45% 11.97 MB / 599.6 kB 0 B / 26.95 MB 44
MNISTãµã³ãã«ã³ã¼ãåãã
- Jupyter Notebookèµ·å
- Jupyterä¸ããterminalãèµ·åããpip install kerasãå®è¡
- Jupyterä¸ãããããªãã¨ã§ããã®ã§ãã
- ãµã³ãã«ã³ã¼ããåãã keras/mnist_cnn.py at master · fchollet/keras · GitHub
CPU使ç¨æ
- 10åã¡ãã£ã¨
GPU使ç¨æ
- 1åå¼±
- ãããããï¼
ãä¸è©±ã«ãªã£ããµã¤ã
ubuntu14.04にnvidia-dockerをインストールする - Qiita
ä»åãã£ã¦ãªããã¨
- Dockerã¤ã¡ã¼ã¸ã®ä½æ
- Dockeråèµ·åããã¨Kerasæ¶ãã¡ããã
- ãã¼ã¿ããªã¥ã¼ã ãæ¥ç¶
- Dockeråèµ·åããã¨æ¸ããã³ã¼ãæ¶ãã¡ããã
- -vãªãã·ã§ã³ã¤ããã°OK