When using tensorflow, set on the GPU

View card usage:

nvidia-smi

Set tensorflow-demand resources:

import os

os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"

os.environ [ "CUDA_VISIBLE_DEVICES"] = "1" # using the GPU second block (starting with 0)

gpu_options = tf.GPUOptions(allow_growth=True)

sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) 

Guess you like

Origin www.cnblogs.com/hellojiaojiao/p/10984422.html