Difference between revisions of "Docker"

From Interaction Station Wiki
Jump to navigation Jump to search
 
(24 intermediate revisions by 2 users not shown)
Line 1: Line 1:
ML Docker Image installed on the Interaction Station ML computers:<br/>
+
ML Docker Image installed on the Interaction Station ML computers (Ubuntu 16.04):<br/>
'''Deepo'''. It includes:<br/>
 
*cudnn
 
*theano
 
*tensorflow
 
*sonnet
 
*pytorch 
 
*keras
 
*lasagne
 
*mxnet
 
*cntk
 
*chainer
 
*caffe
 
*caffe2
 
*torch
 
  
'''Run Deepo image with Docker:'''
+
=Installing Docker CE:=
*sudo nvidia-docker run -it ufoym/deepo:gpu bash
+
*sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
 +
*curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
 +
*sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
 +
*sudo apt-get update
  
'''Run Deepo image with Docker (with python 2.7):'''
+
*More info: https://unix.stackexchange.com/questions/363048/unable-to-locate-package-docker-ce-on-a-64bit-ubuntu
*sudo nvidia-docker run -it ufoym/deepo:py27 bash
 
  
'''Setting up ML computers:'''
+
==Change Docker root dir using systemd (Don't do this, set volume instead)==
*Linux distribution installed: Ubuntu 16.04
+
*systemctl status docker.service
 +
*sudo nano /etc/default/docker
 +
*Edit ExecStart line to look like this ExecStart =/usr/bin/dockerd -g /media/MachineLearning/docker -H fd://
 +
*systemctl daemon-reload
 +
*systemctl restart docker
 +
*sudo docker info - verify the root dir has updated
 +
*https://github.com/IronicBadger/til/blob/master/docker/change-docker-root.md
  
'''Partition made for machine learning:MachineLearning'''
+
==Docker - clean up all the volumes==
*In Windows: Disk Management -> Resize DataStorage
+
*sudo docker system prune -a -f --volumes
*Create new ext4 patition
 
  
'''Mounting the partition automatically:'''
 
  
*'''Get the UUID of the learning:MachineLearning partition'''
+
=Installing nvidia-docker v1 (deprecated!):=
*sudo blkid
+
*docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
 
+
*sudo apt-get purge -y nvidia-docker
*'''Add partition to fstab:'''
+
*curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
*sudo nano /etc/fstab
+
*sudo apt-key add -
*Add at the bottom these two lines:
+
*distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
*UUID=(id of the MachineLearning partition) /media/MachineLearning rw,suid,dev,auto,user,async,exec      0      2
+
*curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
*UUID=(id of the DataStorage partition) /media/DataStorage ntfs-3g defaults=en_US.UTF-8 0 0
+
*sudo tee /etc/apt/sources.list.d/nvidia-docker.list
 
+
*sudo apt-get update
*The parameters mounting the MachineLearning partition solved this problem running caffe from that partition:
+
*sudo apt-get install -y nvidia-docker
*https://github.com/rbgirshick/py-faster-rcnn/issues/162
+
*sudo pkill -SIGHUP dockerd
*https://askubuntu.com/questions/678857/fstab-doesnt-mount-with-exec
+
* #Test nvidia-smi with the latest official CUDA image
 +
*docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi
 +
*Link:
 +
*https://github.com/NVIDIA/nvidia-docker
  
'''Give writting permissions to new MachineLearning partition'''
+
=Installing docker-compose:=
*sudo chmod -R a+rwx /media/MachineLearning/
 
  
'''Installing NVIDIA Driver:'''
+
=Installing nvidia-docker-compose:=
*Set Ubuntu to boot on console mode. Type:
+
*pip install nvidia-docker-compose
*sudo apt-get install systemd
+
*link: https://hackernoon.com/docker-compose-gpu-tensorflow-%EF%B8%8F-a0e2011d36
*sudo systemctl set-default multi-user.target
+
* Permission Denied on curl and save for docker compose: https://github.com/docker/machine/issues/652
*sudo reboot now
 
*Login and in console mode, type:
 
*sudo add-apt-repository ppa:graphics-drivers/ppa
 
*sudo apt update
 
*sudo apt upgrade
 
*For GeForce 1070Ti (07/2018), type:
 
*sudo apt-get install nvidia-390
 
*Re-set Ubuntu to boot on graphical mode. Type:
 
*sudo systemctl set-default graphical.target
 
*sudo reboot now
 
  
 +
=Using Docker with nvidia-docker-compose=
  
'''Checking if Nvidia Driver is properly installed. Type:'''
+
*Public docker repository (When doing FROM in Dockerfile, we need to select one of those)
*nvidia-smi
+
*https://hub.docker.com/
*nvidia-settings
 
  
'''Installing CUDA 9.0 for Ubuntu 16.04 (the latest version is not supported by TensorFlow):'''
+
*Dir structure:
*wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
+
*docker-compose.yml
*wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
+
*deepo
*wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
+
*deepo/do_not_finish.sh
*wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl2_2.1.4-1+cuda9.0_amd64.deb
+
*deepo/Dockerfile
*wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
+
*deepo_data (folder that is visible by deepo image)
*sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
 
*sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
 
*sudo dpkg -i libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
 
*sudo dpkg -i libnccl2_2.1.4-1+cuda9.0_amd64.deb
 
*sudo dpkg -i libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
 
*sudo apt-get update
 
*sudo apt-get install cuda=9.0.176-1
 
*sudo apt-get install libcudnn7-dev
 
*sudo apt-get install libnccl-dev
 
*sudo reboot now
 
*export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
 
*export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
 
*sudo nano .bashrc
 
*Add the two last export lines at the end of the file. Save and reboot.
 
  
'''Checking if CUDA is properly installed. Type:'''
+
*docker-compose.yml:
*nvcc --version
+
version: '3'
 +
services:
 +
  #machine name
 +
  deepo:
 +
    #container name
 +
    container_name: deepo
 +
    #path to Dockerfile
 +
    build: deepo
 +
    command: sh do_not_finish.sh
 +
    volumes:
 +
      - ./deepo_data:/media/deepo_data
 +
    tty: true
  
'''Resources used:'''
+
*Dockerfile:
*https://askubuntu.com/questions/61396/how-do-i-install-the-nvidia-drivers
+
FROM ufoym/deepo
*https://medium.com/@bbloks/a-machine-learning-environment-with-ubuntu-and-gpu-acceleration-in-5-steps-765608325356
+
ADD do_not_finish.sh /
*https://yangcha.github.io/CUDA90/
+
*Dockerfiles guide:
 +
*https://rock-it.pl/how-to-write-excellent-dockerfiles/
  
'''Installing Docker CE on Ubuntu 16.04:'''
+
*do_not_finish.sh:
*sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
+
#!/bin/bash
*curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
+
sh -c 'while :; do sleep 100; done'
*sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
 
*sudo apt-get update
 
  
*More info: https://unix.stackexchange.com/questions/363048/unable-to-locate-package-docker-ce-on-a-64bit-ubuntu
+
*We need that endless loop, because docker-compose closes the container when is deployed
 +
*The endless loop allowed us to use it with a docker exec
  
'''Installing Deepo:'''
+
==Run it==
*[http://www.nvidia.com/content/DriverDownload-March2009/confirmation.php?url=/XFree86/Linux-x86_64/340.107/NVIDIA-Linux-x86_64-340.107.run&lang=us&type=TITAN Prerequisite 1: Nvidia driver ]
+
*Steps 1 and 2: Within the folder where is the docker-compose.yml file
*[https://github.com/NVIDIA/nvidia-docker Prerequisite 2: nvidia-docker]
+
*sudo nvidia-docker-compose build
*[https://github.com/ufoym/deepo Deepo (for GPU)]
+
*sudo nvidia-docker-compose up
  
 +
*Step 3: From another terminal:
 +
*sudo nvidia-docker exec -it deepo bash
  
 +
==Troubleshooting problems==
 +
*Check nvidia-docker version (needs to be version 1)
 +
*nvidia-docker version
 +
*More info:
 +
*https://github.com/eywalker/nvidia-docker-compose/issues/26
  
  
 +
*Permission denied: u'./docker-compose.yml
 +
*https://github.com/docker/docker-snap/issues/26
  
 +
=Deepo=
 +
It includes:<br/>
 +
*cudnn
 +
*theano
 +
*tensorflow
 +
*sonnet
 +
*pytorch 
 +
*keras
 +
*lasagne
 +
*mxnet
 +
*cntk
 +
*chainer
 +
*caffe
 +
*caffe2
 +
*torch
  
'''Change Docker root dir using systemd'''
 
*systemctl status docker.service
 
*sudo nano /etc/default/docker
 
*Edit ExecStart line to look like this ExecStart =/usr/bin/dockerd -g /media/MachineLearning/docker -H fd://
 
*systemctl daemon-reload
 
*systemctl restart docker
 
*sudo docker info - verify the root dir has updated
 
*https://github.com/IronicBadger/til/blob/master/docker/change-docker-root.md
 
  
'''Docker - clean up all the volumes'''
+
==Installing Deepo:==
*sudo docker system prune -a -f --volumes
+
*[http://www.nvidia.com/content/DriverDownload-March2009/confirmation.php?url=/XFree86/Linux-x86_64/340.107/NVIDIA-Linux-x86_64-340.107.run&lang=us&type=TITAN Prerequisite 1: Nvidia driver ]
 +
*[https://github.com/NVIDIA/nvidia-docker Prerequisite 2: nvidia-docker]
 +
*[https://github.com/ufoym/deepo Deepo (for GPU)]
  
'''Other options:'''
+
==Run Deepo image with Docker:==
 +
*sudo nvidia-docker run -it ufoym/deepo:gpu bash
  
'''NTFS fstab wizard:'''
+
==Run Deepo image with Docker (with python 2.7):==
*sudo apt-get install ntfs-config
+
*sudo nvidia-docker run -it ufoym/deepo:py27 bash
*sudo ntfs-config
 
  
'''Format large capacity HD with fs ExFat for having access to it from Ubuntu:'''
+
[[Category: AI & Machine Learning]]
*On Windows 10
 
*cmd
 
*diskpart
 
*select disk '#' (where # is the number of the target drive)
 
*list part
 
*select part # (where # is the number of the partition)
 
*format fs=exfat QUICK
 

Latest revision as of 10:22, 25 November 2022

ML Docker Image installed on the Interaction Station ML computers (Ubuntu 16.04):

Installing Docker CE:

Change Docker root dir using systemd (Don't do this, set volume instead)

Docker - clean up all the volumes

  • sudo docker system prune -a -f --volumes


Installing nvidia-docker v1 (deprecated!):

Installing docker-compose:

Installing nvidia-docker-compose:

Using Docker with nvidia-docker-compose

  • Dir structure:
  • docker-compose.yml
  • deepo
  • deepo/do_not_finish.sh
  • deepo/Dockerfile
  • deepo_data (folder that is visible by deepo image)
  • docker-compose.yml:
version: '3'
services:
  #machine name
  deepo:
    #container name
    container_name: deepo
    #path to Dockerfile
    build: deepo
    command: sh do_not_finish.sh
    volumes:
      - ./deepo_data:/media/deepo_data
    tty: true
  • Dockerfile:

FROM ufoym/deepo ADD do_not_finish.sh /

  • do_not_finish.sh:
  1. !/bin/bash

sh -c 'while :; do sleep 100; done'

  • We need that endless loop, because docker-compose closes the container when is deployed
  • The endless loop allowed us to use it with a docker exec

Run it

  • Steps 1 and 2: Within the folder where is the docker-compose.yml file
  • sudo nvidia-docker-compose build
  • sudo nvidia-docker-compose up
  • Step 3: From another terminal:
  • sudo nvidia-docker exec -it deepo bash

Troubleshooting problems


Deepo

It includes:

  • cudnn
  • theano
  • tensorflow
  • sonnet
  • pytorch
  • keras
  • lasagne
  • mxnet
  • cntk
  • chainer
  • caffe
  • caffe2
  • torch


Installing Deepo:

Run Deepo image with Docker:

  • sudo nvidia-docker run -it ufoym/deepo:gpu bash

Run Deepo image with Docker (with python 2.7):

  • sudo nvidia-docker run -it ufoym/deepo:py27 bash