參考解決方案1:https://stackoverflow.com/questions/38303974/tensorflow-running-error-with-cublas
參考解決方案2:https://github.com/tensorflow/tensorflow/issues/9489
本人環境:
Hassee G7-CT7NK
Ubuntu 18.04.2、anaconda 4.7.11、tensorflow-gpu 1.14.0
cudatoolkit 10.0.130、cudnn 7.6.0、NVidia Driver Version 430.40
本人測試使能允許增加GPU內存后,運行正常。
一勞永逸的辦法如下:
- 在全局使能GPU內存,根據需要增加GPU內存,代價是增加內存碎片。
- 修改腳本:~/anaconda3/envs/xxxxx/lib/python3.7/site-packages/tensorflow/python/client/session.py
- 找到tf.Session的基類BaseSession,修改其__init__中的代碼,在適當位置添加如下腳本,即可正常使用。
if config is None: config = context.context().config # Grow GPU memory as needed at the cost of fragmentation. config.gpu_options.allow_growth = True