请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

InternalError: Blas GEMM launch failed

运行第二章fashion_mnist代码,我是在本地gpu环境运行的,遇到

InternalError: Blas GEMM launch failed

这个问题,在网上搜索后发现是session创建未关闭导致,

需要添加代码

if 'session' in locals() and session is not None:
    print('Close interactive session')
    session.close()

是在代码中并没有显示的声明session,

model = tf.keras.Sequential([
    tf.keras.layers.Flatten(input_shape=(28, 28)),
    tf.keras.layers.Dense(256, activation=tf.nn.relu),
    tf.keras.layers.Dense(128, activation=tf.nn.relu),
    tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])



model.compile(loss="sparse_categorical_crossentropy",
              optimizer=tf.train.AdamOptimizer(),
              metrics=["accuracy"])

# model.summary()

history = model.fit(x_train, y_train, epochs=10,
                    validation_data=(x_val, y_val))

我应该如何解决这个问题呢

正在回答 回答被采纳积分+3

1回答

正十七 2020-04-15 22:35:24

Tensorflow默认占满GPU,所以第二次的时候就会报错。可以把这段代码放到import tensorflow之后:

tf.debugging.set_log_device_placement(True)
gpus = tf.config.experimental.list_physical_devices('GPU')
for gpu in gpus:
    tf.config.experimental.set_memory_growth(gpu, True)


0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号