How to Setup GPU for TensorFlow in the Cloud

How to Setup GPU for TensorFlow in the Cloud
How to Setup GPU for TensorFlow in the Cloud

This tutorila will show you how to create a google cloud enviornment to perform Tensorflow machine learning tasks with a GPU graphic processing unit. We will use Google Compute Engine in conjunction with a Tesla K80 Nvidia GPU card. We will also create a jupyter notebook to use in the browser as an example. We will also use docker as an easy way to create a tensorflow enviornment.

In general, if the step of the process can be described such as “do this mathematical operation thousands of times”, then send it to the GPU. Examples include matrix multiplication and computing the inverse of a matrix. In fact, many basic matrix operations are prime candidates for GPUs. As an overly broad and simple rule, other operations should be performed on the CPU.

How to Set up a TensorFlow GPU Docker

TensorFlow 2.0 Case Study

PyTorch vs TensorFlow: Which Framework Is Best?

#tensorflow #nvidia #gpu

Cuda Nvidia Google Startup Scripts
*We used Ubuntu 18 as our operating system

echo “Checking for CUDA and installing.”

Check for CUDA and try to install.

if ! dpkg-query -W cuda-10-0; then
curl -O
dpkg -i ./cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
apt-key adv --fetch-keys
apt-get update
apt-get install cuda-10-0 -y

Enable persistence mode

nvidia-smi -pm 1

Install Docker

Add NVIDIA’s docker repository to your system.

Install nvidia-docker2 and restart the Docker daemon.

curl -s -L | sudo apt-key add - \
    && curl -s -L "$(. /etc/os-release; echo $ID$VERSION_ID)/nvidia-docker.list" \
    | sudo tee /etc/apt/sources.list.d/nvidia-docker.list \
    && sudo apt-get update \
    && sudo apt-get install -y nvidia-docker2 \
    && sudo pkill -SIGKILL dockerd

Test nvidia-smi within the Docker container.

sudo docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi

Docker Container Pre-Configured with TensorFlow

docker run -it -d macgyvertechnology/tensorflow-gpu:basic-jupyter

Need Consulting?

Run Machine Learning Models in the Cloud


Introduction to Machine Learning with TensorFlow.js

Machine Learning Zero to Hero - Learn Machine Learning from scratch

TensorFlow.js Bringing Machine Learning to the Web and Beyond

Machine Learning Tutorial - Image Processing using Python, OpenCV,

Platform for Complete Machine Learning Lifecycle

Docker Tutorial A Full DevOps Course on How to Run Applications