To create a VM instance, you have to register on the Google cloud platform, and once you registered, you will get a 300$ free trial. I won’t include the registration part here as it is very easy.
1 External IP addresses
Navigate to “VPC Network – External IP addresses” and apply for a new static IP and name it as you want
The result will look like this, in this case, i named it to taiwan as i choose from asia areas:
3 Apply an API to use GPUs
You have to choose a right area as some areas do not provide GPU usage and the price could be various. In this case, we choose “asia-east1-a” and decide to use its Tesla P100
Navigate to “IAM & admin – Quotas” and select the API you want to apply, you will receive an email from Google, then the follow the instructions to use the GPU you want (usually, just click the link provided in the email).
4 Create an instance
Navigate to “Compute Engine – VM instances” and create an vm instance.
In order to the use GPU we applied, you have to choose the same area.
Hit the “Customize” button and customize your machine type, then expand the GPU section to use a P100.
For the operating system, just choose Ubuntu 16, you can also use an SSD or expand the boot disk size to 20 GB if you like.
For the Firewall section, just tick both the HTTP and HTTPS traffic.
You may also have to expand the next section and configure your network interface to use static IP (optional).
Do not be afraid of the price as Google will only charge you from the 300$ when you are running the device and it is charged by minutes.
5 CUDA® Toolkit 8.0.
Once you have created the instance, click SSH button to open an SSH console and follow the following commands.
sudo apt-get update sudo curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb sudo dpkg -i ./cuda-repo-ubuntu1604_8.0.61-1_amd64.deb sudo apt-get update sudo apt-get install cuda-8-0 -y
6 cuDNN v6 for CUDA 8.0
We have to use the Jupyter Notebook to upload our installation package first. To do this, you can click this link and download one. Remeber, you have to create a NVIDIA account if do not have one. Then, agree terms and choose the following one to download, which is the “cuDNN v6.0 Library for Linux”.
# The file name could be different, be careful. # Download the cudnn package with wget. You can get the download link when you are downlowning a cudnn file. wget https://...../cudnn-8.0-linux-x64-v6.0.tgz.xxxxxxxxxxx # Rename the file mv cudnn-8.0-linux-x64-v6.0.tgz.xxxxxxxxxxx cudnn-8.0-linux-x64-v6.0.tgz # Unzip the file and install cudnn tar -xzvf cudnn-8.0-linux-x64-v6.0.tgz sudo cp cuda/include/cudnn.h /usr/local/cuda/include sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* # Edit .bashrc nano ~/.bashrc # Add the following two lines to the file export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64" export CUDA_HOME=/usr/local/cuda # Press Ctrl+O to save changes and Ctrl+X to exit the editor # Update changes source ~/.bashrc
sudo pip3 install tensorflow-gpu
Now you can have fun with your VM instance.
To save your 300$, do not to forget to shutdown your VM instance after using it.