安装tensorflow的时候出现了几个问题

安装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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值