Tutorial by Examples

To ensure that a GPU version TensorFlow process only runs on CPU: import os os.environ["CUDA_VISIBLE_DEVICES"]="-1" import tensorflow as tf For more information on the CUDA_VISIBLE_DEVICES, have a look to this answer or to the CUDA documentation.
import tensorflow as tf sess = tf.Session(config=tf.ConfigProto(device_count={'GPU': 0})) Bear in mind that this method prevents the TensorFlow Graph from using the GPU but TensorFlow still lock the GPU device as described in this an issue opened on this method. Using the CUDA_VISIBLE_DEVICES se...
To use a particular set of GPU devices, the CUDA_VISIBLE_DEVICES environment variable can be used: import os os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID" # see issue #152 os.environ["CUDA_VISIBLE_DEVICES"]="0" # Will use only the first GPU device os.en...
from tensorflow.python.client import device_lib print(device_lib.list_local_devices())
By default, TensorFlow pre-allocate the whole memory of the GPU card (which can causes CUDA_OUT_OF_MEMORY warning). To change this, it is possible to change the percentage of memory pre-allocated, using per_process_gpu_memory_fraction config option, A value between 0 and 1 that indicates wh...

Page 1 of 1