修改源码:/usr/local/lib/python3.5/dist-packages/keras/backend/tensorflow_backend.py
else:
if _SESSION is None:
if not os.environ.get(‘OMP_NUM_THREADS’):
config = tf.ConfigProto(allow_soft_placement=True)
config.gpu_options.per_process_gpu_memory_fraction = 0.3 # zhex add
print(‘keras/backend/tensorflow_backend.py: config.gpu_options.per_process_gpu_memory_fraction = 0.3 #zhex’)
else:
num_thread = int(os.environ.get(‘OMP_NUM_THREADS’))
config = tf.ConfigProto(intra_op_parallelism_threads=num_thread, allow_soft_placement=True)
config.gpu_options.per_process_gpu_memory_fraction = 0.3 #yuzhijun add
print(‘config.gpu_options.per_process_gpu_memory_fraction = 0.3 #yuzhijun’)
_SESSION = tf.Session(config=config)
session = _SESSION
使用keras框架训练神经网络时显卡内存使用很大很大的解决方案
最新推荐文章于 2022-09-23 20:49:35 发布