基于tensorflow训练模型的显存不足解决办法

 

import tensorflow as tf
import os
os.environ["CUDA_VISIBLE_DEVICES"] = '0' #指定第一块GPU可用
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.5 # 程序最多只能占用指定gpu50%的显存
config.gpu_options.allow_growth = True #程序按需申请内存
sess = tf.Session(config = config)

posted @ 2019-10-14 23:45  tangjunjun  阅读(2777)  评论(0编辑  收藏  举报
https://rpc.cnblogs.com/metaweblog/tangjunjun