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
https://morioh.com/p/95672d22da46

TensorFlow 2.0 Case Study
https://morioh.com/p/ea7807ebd73b

PyTorch vs TensorFlow: Which Framework Is Best?
https://morioh.com/p/2f066a0a0150

#tensorflow #nvidia #gpu

Cuda Nvidia Google Startup Scripts
https://cloud.google.com/compute/docs/gpus/add-gpus#install-driver-script
*We used Ubuntu 18 as our operating system

#!/bin/bash
echo “Checking for CUDA and installing.”

Check for CUDA and try to install.

if ! dpkg-query -W cuda-10-0; then
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
dpkg -i ./cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
apt-get update
apt-get install cuda-10-0 -y
fi

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 https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \
    && curl -s -L "https://nvidia.github.io/nvidia-docker/$(. /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?
askmacgyver.com

Run Machine Learning Models in the Cloud
askmacgyver.com

Suggest:

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