April 2017
Intermediate to advanced
320 pages
7h 46m
English
To use a GPU in your TensorFlow program, just type the following:
with tf.device("/gpu:0"):
Followed by the setup operations. This line of code will create a new context manager, telling TensorFlow to perform those actions on the GPU.
Let's consider the following example, in which we want to execute the following sum of two matrices, An + Bn.
Define the basic imports:
import numpy as np import tensorflow as tf import datetime
We can configure a program to find out which devices your operations and tensors are assigned. To realize this, we'll create a session with the following log_device_placement parameter set to True:
log_device_placement = True
Then we fix the n parameter, that is, the number of multiplication ...
Read now
Unlock full access