Google Cloud TF-GPU Setup for Ubuntu 16.04
Prahlad Chari
pnchari@connect.ust.hk
PART 1
#1) Create an Instance
#2) Select appropriate servers
us-east1-d
asia_east1-a
europe_west1-b
The above servers are where you will find the option to enable GPU usage...
#3) Choosing GPU option
#4) Configuring your GPU
PART 2
Brief Overview
1) Install NVIDIA Cuda
2) Install NVIDIA cuDNN
3) Install and upgrade PIP
4a) Install TensorFlow (without Bazel)
4b) Install Bazel
4b2) Install TensorFlow
4b3) Upgrade Protobuf
5) Test Installation
#1) Install Cuda
#2) Install cuDNN
This might change based on your download!!!
#3) Install PIP
Our cuda installation should be in /usr/local/cuda at this point. We should now set the LD_LIBRARY_PATH and CUDA_HOME environment variables
Method 1 (without Bazel)
#4a) Install TensorFlow-GPU using PIP
If you want to install TensorFlow without installing Bazel, then you can follow the tutorial from this point after installing Cuda, cuDNN and upgrading PIP
IF NOT
Method 2 (using Bazel)
#4b) Install Bazel
#4b2) Install TensorFlow
In the blank space above, we should � include the ‘code’ of the latest commit� from the TensorFlow main branch.
Image on the right for reference →
Once we’ve installed TensorFlow, we should now configure it so that it can be setup to run with the Cuda GPUs / other dependencies as required…
During the configure process, you should follow the prompts that appear on these slides as specified. For other prompts that are not included on these slides, you can choose the option according to your preference…
After this step, the configuration should be finished successfully and you will get a message saying ‘Configuration finished’ after TensorFlow sets up various libraries and files based on your specifications.
Now we call bazel to build the TensorFlow pip package. This step takes a long time [generally more than 1 hour], so we can do other stuff meanwhile :)
The first part of this script, i.e. ‘bazel build…’ until ‘...:build_pip_package’ takes the majority of the time. After this part is over, the rest of the script, i.e. ‘bazel-bin/…’ until ‘.../tensorflow_pkg’ will be in the command line, so don’t forget to press enter to execute the second part of the script.
(The above command might differ slightly based on your version of TF)
#4b3) Upgrade Protobuf
#5) Test Installation!
One way to check if your TensorFlow is using GPU or not, is by doing the following:
After running a TensorFlow session by doing sess = tf.Session(), we are presented with information about ‘device 0’, which in this case is our NVIDIA Tesla K80 GPU
Another way to check if your GPU is working is by running nvidia-smi. If we run it while there is no training going on, we can see on the left that the memory used is very low and the power consumed by the GPU is low as well. Furthermore the GPU utilization is set at 0%.
On the right we can see that if we run nvidia-smi when our model is training, we can see that the power consumed significantly more, the memory taken up is 10914MiB and GPU-Util is at 92%. Furthermore, process ID (PID) 2740, aka python is added to the list of GPU processes, indicating that it is working.
END