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,点击要加入的文件夹,
** 注意: 添加成功之后该文件见的图标会编程蓝色(加入之前是淡蓝色中间一个圆圈)

 

posted @ 2020-11-10 21:34  谢义xieyi521149  阅读(5968)  评论(0编辑  收藏  举报