安装tensorflow的时候出现了几个问题
1、
import tensorflow as tf
报错信息:
2021-08-10 23:56:26.853798: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-08-10 23:56:26.854063: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.`
报错原因:Tensorflow版本过高。
解决措施:将Tensorflow版本,从2.5.0降到2.3.0即可!
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==2.3.0
2、
报错信息:
报错原因:
Consider using the `--user` option or check the permissions.
解决措施:在命令行中添加–user
pip install --user -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==2.3.0
这样就安装好啦:
3、
**问题:**最后还是在“cudart64_110.dll”这个文件出现了的问题
解决:
下载cudart64_101.dll文件
https://www.dll-files.com/cudart64_101.dll.html
下载解压
解压的"cudart64_101"文件夹目录:
我是win10
所以将"cudart64_101.dll"复制到
C:\Windows\System32
这个文件中
重启电脑
测试一下:
import numpy as np
import tensorflow as tf
arr = np.array([1, 5.5, 3, 15, 20])
tensor = tf.convert_to_tensor(arr,tf.float64)
sess = tf.Session()
print(sess.run(tensor))
print(sess.run(tensor[1]))
4、
报错信息:
报错原因:
tensorflow版本2.0无法兼容版本1.0.
解决措施:
tf.compat.v1.Session()
替代
tf.Session()
import numpy as np
import tensorflow as tf
arr = np.array([1, 5.5, 3, 15, 20])
tensor = tf.convert_to_tensor(arr,tf.float64)
sess = tf.compat.v1.Session()
print(sess.run(tensor))
print(sess.run(tensor[1]))
输出:
补充:
5、如果遇到
报错信息:
RuntimeError: The Session graph is empty. Add operations to the graph before calling run().
报错原因:
无法执行sess.run()的原因是tensorflow版本不同导致的,tensorflow版本2.0无法兼容版本1.0.
解决措施:
tf.compat.v1.disable_eager_execution()
import numpy as np
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
arr = np.array([1, 5.5, 3, 15, 20])
tensor = tf.convert_to_tensor(arr,tf.float64)
sess = tf.compat.v1.Session()
print(sess.run(tensor))
print(sess.run(tensor[1]))
输出:
此博客是我在安装tensorflow时遇到的几个问题,仅用于记录。
参考文章:
1、
https://blog.csdn.net/FriendshipTang/article/details/113573114
2、
https://blog.csdn.net/sinat_36413257/article/details/100553689
3、
https://blog.csdn.net/weixin_42122125/article/details/107596238?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-7.pc_relevant_baidujshouduan&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-7.pc_relevant_baidujshouduan
4、
https://blog.csdn.net/weixin_38410551/article/details/103631977
5、
https://blog.csdn.net/qq_33440324/article/details/94200046