10/15/2019
TensorFlow with GPU - Colaboratory
1/2
This notebook provides an introduction to computing on a
GPU
in Colab. In this notebook you will connect to a
GPU, and then run some basic TensorFlow operations on both the CPU and a GPU, observing the speedup
provided by using the GPU.
Tensor±ow with GPU
First, you'll need to enable GPUs for the notebook:
Navigate to Edit
→
Notebook Settings
select GPU from the Hardware Accelerator drop-down
Next, we'll con±rm that we can connect to the GPU with tensor²ow:
Enabling and testing the GPU
Found GPU at: /device:GPU:0
import
tensorflow
as
tf
device_name = tf.test.gpu_device_name()
if
device_name !=
'/device:GPU:0'
:
raise
SystemError(
'GPU device not found'
)
print
(
'Found GPU at: {}'
.format(device_name))
This example constructs a typical convolutional neural network layer over a random image and manually places
the resulting ops on either the CPU or the GPU to compare execution speed.


You've reached the end of your free preview.
Want to read both pages?
- Fall '19