How to Setup GPU for TensorFlow in the Cloud

preview_player
Показать описание
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.

#tensorflow #nvidia #gpu

Cuda Nvidia Google Startup Scripts
*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
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.
&& 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
Рекомендации по теме
Комментарии
Автор

Thx for sharing this tutorial, gonna try this to train some CNN's for my thesis

igorvaz
Автор

I am using a mac. I failed to install the gpu driver with script google provided. Do I need to install a ubuntu virtual system on mac before I run gpu on google cloud?

ninalee
Автор

Er... I created my VM with gpu, but when I Deploy to Cloud Run, im not able to use Gpu? Because I would like to run my model and not to train them.

deidy
Автор

Why do all that installing of the nividia drivers on the machine to then use a docker container? Couldn't you just use a docker container? Isn't that the whole point of the docker container, the fact that it is a light weight ubuntu image that has the drivers in it?

dylanf
Автор

Are you doing this for every time you use GPU, or is there an image that we can copy and deploy instantly?

davidrichard
Автор

Awesome stuff.
I had a quite bit of initial hassle getting a GPU resource, because GPUs not available in my own region[UK], so needed to request Google quota uplift to "GPUS_ALL_REGIONS' to 1, so I could reach across to Western_Europe Google cloud GPU resources (Despite Brexit !)
Is there any chance you now providing TensorFlow 2.0 GPU docker images ?

juleswombat
Автор

My google colab runtime disconnects after a few minutes of training... Is there any way I can train for longer without runtime disconnecting?

musaharoon
Автор

when i install Docker just copy your code, i got error:gpg: no valid OpenPGP data found. Do you know why and how to fix it?thx

leochan
Автор

can we get an updated procedure for 2023 plssss

oscarlopez