InternalError: Blas GEMM launch failed
来源:2-5 实战分类模型之数据归一化

Beebop
2020-04-09
运行第二章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))
我应该如何解决这个问题呢
写回答
1回答
-
正十七
2020-04-15
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)
00
相似问题