限制tensorflow训练时的显存设置,以及可见显卡号

import tensorflow as tf
import os
os.environ["CUDA_VISIBLE_DEVICES"] = '0' #use GPU with ID=0
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.5 # maximun alloc gpu50% of MEM
config.gpu_options.allow_growth = True #allocate dynamically
sess = tf.Session(config = config)
posted @ 2020-01-04 11:58  you-wh  阅读(706)  评论(0编辑  收藏  举报
Fork me on GitHub