Pycharm+Tensorflow安裝和使用出現的問題集合


問題1:Could not load dynamic library  cudart64_101.dll

解決方法:https://www.dll-files.com/download/1d7955354884a9058e89bb8ea34415c9/cudart64_101.dll.html?c=VElyVUtzT2Q0R2xhc2JNK1ZUa0Jvdz09

問題2:tensorflow-gpu版本使用時報錯,各種dll文件找不到

2020-06-15 20:30:54.310396: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library ‘cublas64_10.dll’; dlerror: cublas64_10.dll not found
2020-06-15 20:30:54.311457: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library ‘cufft64_10.dll’; dlerror: cufft64_10.dll not found
2020-06-15 20:30:54.312777: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library ‘curand64_10.dll’; dlerror: curand64_10.dll not found
2020-06-15 20:30:54.314450: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library ‘cusolver64_10.dll’; dlerror: cusolver64_10.dll not found
2020-06-15 20:30:54.315749: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library ‘cusparse64_10.dll’; dlerror: cusparse64_10.dll not found
2020-06-15 20:30:54.316863: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library ‘cudnn64_7.dll’; dlerror: cudnn64_7.dll not found
2020-06-15 20:30:54.317064: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1592] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices…

 解決方法:https://www.pianshen.com/article/37081444749/

 問題3:RuntimeError: The Session graph is empty. Add operations to the graph before calling run().

解決方法:tf.compat.v1.disable_eager_execution()

    無法執行sess.run()的原因是tensorflow版本不同導致的,tensorflow版本2.0無法兼容版本1.0.

import tensorflow as tf
print(tf.__version__)

tf.compat.v1.disable_eager_execution() # 保證sess.run()能夠正常運行
hello = tf.constant('hello tensorflow!')
sess = tf.compat.v1.Session() # 版本2.0的函數
print(sess.run(hello))

問題4:AttributeError: module 'tensorflow' has no attribute 'mul'

解決方法:tf.mul已經在新版本中被移除,請使用 tf.multiply 代替

問題5:AttributeError: module 'tensorflow' has no attribute 'placeholder'

解決方法:

import tensorflow as tf

用以下代碼代替

import numpy as np
#import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

 問題5:Pycharm提示 Unresolved reference 的解決辦法

 

解決方法:

有時候a.py和b.py在一個目錄里面,但是在a.py種寫import b有時會提示Unresolved reference,Pycharm常見。

解決辦法是setting -> Project -> Project structure -> Source,點擊要加入的文件夾,
** 注意: 添加成功之后該文件見的圖標會編程藍色(加入之前是淡藍色中間一個圓圈)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM