tensorflow錯誤解決

文|seraph

  1. AttributeError: module 'tensorflow' has no attribute 'sub'
    解決:將tf.sub換成tf.subtract

  2. AttributeError: module 'tensorflow' has no attribute 'mul'
    解決:將tf.mul換成tf.multiply

  3. AttributeError: module 'tensorflow' has no attribute 'types'
    解決:將tf.types.float32換成tf.float32

  4. TensorFlow please use urllib or similar directly
    解決:在 from tensorflow.examples.tutorials.mnist import input_data之前,加入

old_v = tf.logging.get_verbosity()
tf.logging.set_verbosity(tf.logging.ERROR)

mnist = input_data.read_data_sets('./data/mnist', one_hot=True)之後,加入

tf.logging.set_verbosity(old_v)
  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.
    解決:添加動態申請顯存的代碼即可
config = ConfigProto()
config.gpu_options.allow_growth = True
  1. 執行for k, v in six.iteritems(FLAGS.__dict__['__flags']):報錯誤:KeyError: '__flags'
    解決:將循環語句修改爲
for k in FLAGS:
    v = FLAGS[k].value
  1. 已經安裝tensorflow,但是報:ImportError: No module named tensorflow
    解決:可能安裝的使python3版本的,使用python3執行py文件即可。或者調整python默認版本爲python3。

  2. Could not dlopen library 'libcudart.so.10.0';
    解決:查看CUDA是否安裝,如已經安裝,檢查是否是10.0版本的。
    也可能沒有配好LIB_LIBRARY_PATH環境變量,導致不能搜索到文件。

  3. CUDA driver version is insufficient for CUDA runtime version
    解決:如提示所示,NVIDIA驅動和CUDA版本不兼容。使用nvidia-smi查看驅動和CUDA版本是否符合如下圖所示:
    在這裏插入圖片描述
    詳細內容可以參考官網

  4. *** Error in 'python': free(): invalid pointer
    解決:apt-get install libtcmalloc-minimal4
    然後在加入環境變量:
    export LD_PRELOAD="/usr/lib/libtcmalloc_minimal.so.4"

  5. could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
    解決:具體問題未能完全定位,可能是顯存不夠,但加入下面按需申請顯存代碼,暫時能正常運行。

config = ConfigProto()
config.gpu_options.allow_growth = True
tf.Session(config=config) #在設置會話加入配置即可。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章