我在配备GeForce GT 750M的Macbook Pro上安装了tensorflow 1.0.1 GPU版本.还安装了CUDA 8.0.71和cuDNN 5.1.我运行的tf代码可以很好地处理非CPU张量流,但是在GPU版本上,我得到了这个错误(曾经有一段时间它也有效):
name: GeForce GT 750M
major: 3 minor: 0 memoryClockRate (GHz) 0.9255
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 67.48MiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0: Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 750M, pci bus id: 0000:01:00.0)
E tensorflow/stream_executor/cuda/cuda_driver.cc:1002] failed to allocate 67.48M (70754304 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
Training...
E tensorflow/stream_executor/cuda/cuda_dnn.cc:397] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:364] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:605] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)
Abort trap: 6
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?这是张量流中的错误吗?请帮忙.
当我运行python代码时,这是GPU内存空间:
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 83.477 of 2047.6 MB (i.e. 4.08%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 83.477 of 2047.6 MB (i.e. 4.08%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 83.477 of 2047.6 MB (i.e. 4.08%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 1.1016 of 2047.6 MB (i.e. 0.0538%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 1.1016 of 2047.6 MB (i.e. 0.0538%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 1.1016 of 2047.6 MB (i.e. 0.0538%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 1.1016 of 2047.6 MB (i.e. 0.0538%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 91.477 of 2047.6 MB (i.e. 4.47%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 22.852 of 2047.6 MB (i.e. 1.12%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 22.852 of 2047.6 MB (i.e. 1.12%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 36.121 of 2047.6 MB (i.e. 1.76%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 71.477 of 2047.6 MB (i.e. 3.49%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 67.477 of 2047.6 MB (i.e. 3.3%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 67.477 of 2047.6 MB (i.e. 3.3%) Free
MacBook-Pro:cuda-smi-master xxxxxx$ ./cuda-smi
Device 0 [PCIe 0:1:0.0]: GeForce GT 750M (CC 3.0): 67.477 of 2047.6 MB (i.e. 3.3%) Free
Run Code Online (Sandbox Code Playgroud)
ave*_*evu 35
在 Tensorflow 2.0 中,通过设置内存增长解决了我的问题。ConfigProto 在 TF 2.0 中已弃用,我使用了 tf.config.experimental。我的电脑规格是:
我使用的代码是:
physical_devices = tf.config.experimental.list_physical_devices('GPU')
assert len(physical_devices) > 0, "Not enough GPU hardware devices available"
config = tf.config.experimental.set_memory_growth(physical_devices[0], True)
Run Code Online (Sandbox Code Playgroud)
Fél*_* Fu 17
我已经设法通过删除我的主文件夹中的.nv文件夹来使其工作:
sudo rm -rf ~/.nv/
Run Code Online (Sandbox Code Playgroud)
小智 9
添加以下代码对我有用:
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)
Run Code Online (Sandbox Code Playgroud)
在我的环境中,CuDNN 和 Cuda 版本之间没有不匹配。操作系统:ubuntu-18.04;张量流:1.14;CuDNN:7.6;cuda:10.1 (418.87.00)。
小智 7
对我来说,第四个可以很好地解决问题。 https://blog.csdn.net/comway_Li/article/details/102953634?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-2
1.
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 1.0
session = tf.Session(config=config, ...)
2.
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)
3.
sudo rm -f ~/.nv
4.
from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession
#from tensorflow import ConfigProto
#from tensorflow import InteractiveSession
config = ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)
Run Code Online (Sandbox Code Playgroud)
小智 6
就我而言,检查cuDNN和CUDA版本后,我发现我的GPU内存不足。watch -n 0.1 nvidia-smi在另一个bash终端中使用的那一刻2019-07-16 19:54:05.122224: E tensorflow/stream_executor/cuda/cuda_dnn.cc:334] Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR起就是GPU内存即将满的那一刻。
屏幕截图
因此,我为tnsorflow配置了使用我的GPU的限制。在使用tf.keras模块时,我将以下代码添加到程序的开头:
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.9
tf.keras.backend.set_session(tf.Session(config=config));
Run Code Online (Sandbox Code Playgroud)
然后,问题解决了!
您可以更改您batch_size的训练数据或使用更智能的方法来输入您的训练数据(例如tf.data.Dataset和使用缓存)。我希望我的回答可以帮助其他人。
听起来可能有些奇怪,请尝试重新启动计算机并重新运行模型。如果模型运行良好,则问题在于您的GPU内存分配和该可用内存的张量流管理。在Windows 10上,我有两个打开和关闭终端,一个解决了我的问题。可能有开放线程(僵尸)仍在保留内存。
小智 2
我也遇到同样的错误,我解决了这个问题。我的系统属性如下:
我解决这个问题的方法如下:
我将 cudnn 文件复制到适当的位置(/usr/local/cuda/include和/usr/local/cuda/lib64)
我将环境变量设置为:
* export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
* export CUDA_HOME=/usr/local/cuda
Run Code Online (Sandbox Code Playgroud)
我还运行sudo ldconfig -v command来缓存运行时链接器的共享库。
| 归档时间: |
|
| 查看次数: |
20440 次 |
| 最近记录: |