使用GPU进行训练,及解决jupyter 问题:The kernel appears to have died. It will restart automatically

转载自:https://blog.csdn.net/github_36326955/article/details/79910448
代码如下:
import os
import tensorflow as tf
import keras.backend.tensorflow_backend as KTF #进行配置,每个GPU使用80%上限现存
os.environ[“CUDA_VISIBLE_DEVICES”]=“1” # 使用编号为1号的GPU
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.8 # 每个GPU现存上届控制在80%以内
session = tf.Session(config=config) # 设置session KTF.set_session(session )
#设置session
KTF.set_session(session )
【使用GPU进行训练,及解决jupyter 问题:The kernel appears to have died. It will restart automatically】注意:
config.gpu_options.per_process_gpu_memory_fraction = 0.8 # 每个GPU现存上届控制在80%以内
设置GPU使用上限,可以有效避免显存不足而导致的jupyter 问题:
The kernel appears to have died. It will restart automatically

    推荐阅读