环境:ubuntu 20.04
tensorflow-gpu=1.15
cuda=10.10
cudnn=7.6
显卡:RTX2070
主要问题:
2020-09-02 23:35:17.561688: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7215 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2070, pci bus id: 0000:01:00.0, compute capability: 7.5) 2020-09-02 23:35:17.635400: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7 2020-09-02 23:35:18.335566: E tensorflow/stream_executor/cuda/cuda_dnn.cc:329] Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR 2020-09-02 23:35:18.344331: E tensorflow/stream_executor/cuda/cuda_dnn.cc:329] Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR Traceback (most recent call last): File "/home/lbz/anaconda3/envs/Compress/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1365, in _do_call return fn(*args) File "/home/lbz/anaconda3/envs/Compress/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1350, in _run_fn target_list, run_metadata) File "/home/lbz/anaconda3/envs/Compress/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1443, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.UnknownError: 2 root error(s) found. (0) Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above. [[{{node analysis/layer_0/convolution}}]] (1) Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above. [[{{node analysis/layer_0/convolution}}]] [[entropy_model/entropy_model_2/compress/strided_slice/_15]] 0 successful operations. 0 derived errors ignored.
解决方法:
在程序中加入:
gpus= tf.config.experimental.list_physical_devices('GPU') # gpus = tf.config.list_physical_devices('GPU') # tf2.1版本该函数不再是experimental print(gpus) # 前面限定了只使用GPU1(索引是从0开始的,本机有2张RTX2080显卡) tf.config.experimental.set_memory_growth(gpus[0], True) # 其实gpus本身就只有一个元素来源:https://blog.csdn.net/ouening/article/details/104011542
https://github.com/tensorflow/tensorflow/issues/24496#