How to create a Machine Learning VM from scratch

  • fennng 

The quickest way to own a Azure Deep Learning VM with CUDA GPU support.

Pre-requisites: You will need to have a azure subscription

Firstly, create a NC6 VM with Ubuntu 16.4 LTS, make sure HDD is selected and port 80, 443 and 22 are open. This VM comes with a Tesla K80 GPU.

In my case, I have to select East US before I could find NC6 in the list.

SSH to the VM

Install docker

Don’t use the following command to install docker, as it’s an old version: Docker version 18.09.7, build 2d0083d

#don't run this
sudo apt install

Follow this page to install the latest docker

sudo apt-get install     apt-transport-https     ca-certificates     curl     gnupg-agent     software-properties-common
sudo apt-key fingerprint 0EBFCD88
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli
docker -v  
Docker version 19.03.4, build 9013bf583a

Then Install Nvidia Driver

The info from this page is useful, but don’t build the gpu docker using this docker file.

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update 
sudo apt-get install nvidia-352

Restart VM with following command

sudo shutdown -r now

check driver

cat /proc/driver/nvidia/version
[email protected]:~$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  384.130  Wed Mar 21 03:37:26 PDT 2018
GCC version:  gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)

install nvidia docker

# Add the package repositories
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L | sudo apt-key add -
curl -s -L$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker

Test the enviroment

docker run --gpus all nvidia/cuda:9.0-base nvidia-smi

Don’t do this — Build the docker, this will take a while, about 20 minutes

#don't run this, as the built image doesn't work properly.
git clone
cd dl-docker
docker build -t floydhub/dl-docker:gpu -f Dockerfile.gpu .

The reason of the failure as shown below.

So I switch to the following docker image.

sudo docker run --gpus all -it --rm -p 8888:8888 -v /sharefolder:/root/workspace jihong/keras-gpu bash
jupyter notebook --allow-root

Now, the jupyter notebook is ready. We need to find a easy way to access it. So I use ngrok here. For proper setup, nginx-proxy with SSL is a better option.

Install ngrok following this instruction

#in my case
sudo apt install unzip  
mv ngrok /usr/bin/ngrok

Run ngrok

ngrok http 8888

Copy the jupyter notebook token from the linux bash to login

Then navigate to /sharefolder and run

git clone

Then you will be able to see a bunch of notebook to start with

Pickup the first one and have a play.


电子邮件地址不会被公开。 必填项已用*标注