【tensorflow报错】tensorflow.python.framework.errors_impl.InternalError: Blas GEMM launch failed:XXX

背景:

最近遇到了一个较为头痛的问题,连续改BUG两天最终才解决掉,解决此问题流程及方法如下:
此问题是在tf-gpu=2.3、cuda=10.1、cudnn=7.4.2环境下出现在(tf的cpu版本时,是可以跑通模型的)。

具体BUG情况如下:

1、failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED

2、Blas GEMM launch failed :

tensorflow.python.framework.errors_impl.InternalError: Blas GEMM launch failed : a.shape=(2048, 2), b.shape=(2, 768), m=2048, n=768, k=2

[[{{nodeStatefulPartitionedCall/StatefulPartitionedCall/transformer_encoder/StatefulPartitionedCall/type_embeddings/MatMul}}]] [Op:__forward_restored_function_body_32773]

Function call stack:
restored_function_body

以下办法总有适合你的一个:

1.在主代码最上面尝试加入(允许GPU占用问题):

import tensorflow as tf
physical_devices = tf.config.list_physical_devices('GPU') 
for device in physical_devices:
   tf.config.experimental.set_memory_growth(device, True)

2.在主代码最上面又尝试加入:

configuration = tf.compat.v1.ConfigProto()
configuration.gpu_options.allow_growth = True
session = tf.compat.v1.Session(config=configuration)

3.在主代码最上面又又尝试加入:

gpu_options=tf.GPUOptions(per_process_gpu_memory_fraction=0.8)  
sess=tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))

4.GPU占用问题(杀掉之前用到GPU的项目):

ps -aux | grep program_name
kill -9 PID

5.删除带有.nv的文件:

sudo rm -rf ~/.nv/

6.batch_size太大,那就一步一步缩小喽,还能有啥办事嘞(下面还有哈哈哈)

7.上面都不行直接重启服务器吧,兄弟们reboot用起来。

以上的方式对我都不适用,最终我选择了重装NVIDIA驱动、cuda、cudnn

下篇将详细介绍如何进行重装具体版本,以及如何解决了tensorflow.python.framework.errors_impl.InternalError: Blas GEMM launch failed:XXX这个让人头疼的B!U!G!

引用
[1]:https://stackoverflow.com/questions/43990046/tensorflow-blas-gemm-launch-failed

你可能感兴趣的:(Tensorflow,tensorflow,python,深度学习)