Skip to content

Instantly share code, notes, and snippets.

@zhaobaiyu
Last active April 25, 2018 06:41
Show Gist options
  • Save zhaobaiyu/7b463d3e23a3b9c5313471928da9b184 to your computer and use it in GitHub Desktop.
Save zhaobaiyu/7b463d3e23a3b9c5313471928da9b184 to your computer and use it in GitHub Desktop.
Tensorflow指定GPU使用量

动态查看nvidia-smi

watch -n 1 -d nvidia-smi

在Python代码中指定GPU

import os
os.environ[“CUDA_VISIBLE_DEVICES”] = “0”

设置定量的GPU使用量

config = tf.ConfigProto() 
config.gpu_options.per_process_gpu_memory_fraction = 0.9 # 占用GPU90%的显存 
sess = tf.Session(config=config)

设置最小的GPU使用量

config = tf.ConfigProto() 
config.gpu_options.allow_growth = True 
sess = tf.Session(config=config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment