py3.7配置tensorflow-GPU总结、The channel is not accessible错误、CUDA driver version is insufficient for CUDA

本篇是主要包含两个内容

一、Win10+Python3.7anaconda配置tensorflow-GPU与tensorflow-CPU总结

       安装GPU后,报错CUDA driver version is insufficient for CUDA runtime version的解决方法(大坑)  

二、conda命令窗口出现UnavailableInvalidChannel: The channel is not accessible or is invalid。。。404。。。错误提示的解决方法

一、Win10+Python3.7anaconda配置tensorflow-GPU与tensorflow-CPU总结 

环境说明:

我的笔记本是win10,Python3.7,anaconda3(版本记不清了,18年12月后的版本),pycharm18年12月版本

最终配置结果:

tensorflow-gpu 1.13版本,cuda10,cudnn7.3

1、配置tensorflow cpu版本

进入conda命令窗(进去就是base环境),输入“conda install tensorflow”,显示secessfully就成功了。

在命令行窗口输入“Python”---------进入Python环境--------输入“import tensorflow as tf”,没报错就基本没问题了

不用看各种教程说建一个Python3.6的环境然后在这个py3.6的环境里面安装tensorflow包。Python3.7早支持tensorflow了,我之前按照那些教程还出了错(师兄说原因是numpy版本太高不匹配),花了好久才弄好。。。其实一句代码就能搞定

conda install tensorflow

2、配置tensorflow-gpu版本

网上教程一堆,都是手动下载安装cuda和cudnn,较为麻烦失败率较高。

方法:进入conda命令窗(进去就是base环境)--------输入“conda install tensorflow-gpu”安装最新版本(其实建议安装低版本,不易出错,看本文末尾的解释和代码即可明白),显示secessfully就成功了---------输入“Python”---------进入Python环境--------输入“import tensorflow as tf”,“tf.__version__”验证

注:指令:conda list  可查看安装包版本号

安装至此我以为没问题了,但是之后运行别的程序报错:CUDA driver version is insufficient for CUDA runtime version。根据https://blog.csdn.net/li57681522/article/details/82491617得知是cuda的驱动版本不匹配,但该博客不能解决我的问题。

https://zhuanlan.zhihu.com/p/59109217大神给出解决方法。去官网https://www.geforce.cn/drivers下载最新驱动。

 下载安装后,找到“驱动程序driver更新”,下载安装(好像是几百M)

安装成功后,查看NVIDIA控制面板,可以看到驱动程序版本从380变为430,conda list查看得知tensorflow-gpu 1.13版本,cuda10和cudnn7.3,大功告成!!

由于是在base环境装的,在pycharm里找到base环境的解释器就行(下载anaconda后配置pycharm时解释器一般都是base环境的,因为刚下载就只有这一个环境)

测试代码:

import tensorflow as tf
a=tf.constant([1,2,3],shape=[3],name="a")
b=tf.constant([1,2,3],shape=[3],name="b")

c=a+b
sess=tf.Session(config=tf.ConfigProto(log_device_placement=True))
print(sess.run(c))
sess.close()

'''
显示如下,即成功
2019-05-28 09:37:49.590066: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2019-05-28 09:37:50.501663: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties: 
name: GeForce GTX 960M major: 5 minor: 0 memoryClockRate(GHz): 1.176
pciBusID: 0000:02:00.0
totalMemory: 4.00GiB freeMemory: 3.34GiB
2019-05-28 09:37:50.502165: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce GTX 960M, pci bus id: 0000:02:00.0, compute capability: 5.0
add: (Add): /job:localhost/replica:0/task:0/device:GPU:0
a: (Const): /job:localhost/replica:0/task:0/device:GPU:0
b: (Const): /job:localhost/replica:0/task:0/device:GPU:0
2019-05-28 09:37:51.816402: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-05-28 09:37:51.816683: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0 
2019-05-28 09:37:51.816848: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N 
2019-05-28 09:37:51.817173: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3050 MB memory) -> physical GPU (device: 0, name: GeForce GTX 960M, pci bus id: 0000:02:00.0, compute capability: 5.0)
2019-05-28 09:37:51.819865: I tensorflow/core/common_runtime/direct_session.cc:317] Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce GTX 960M, pci bus id: 0000:02:00.0, compute capability: 5.0

2019-05-28 09:37:51.822325: I tensorflow/core/common_runtime/placer.cc:1059] add: (Add)/job:localhost/replica:0/task:0/device:GPU:0
2019-05-28 09:37:51.822733: I tensorflow/core/common_runtime/placer.cc:1059] a: (Const)/job:localhost/replica:0/task:0/device:GPU:0
2019-05-28 09:37:51.823151: I tensorflow/core/common_runtime/placer.cc:1059] b: (Const)/job:localhost/replica:0/task:0/device:GPU:0
[2 4 6]
'''


 

二、conda命令窗口出现UnavailableInvalidChannel: The channel is not accessible or is invalid。。。404。。。错误提示的解决方法

我是19年4月先安装的tensorflow cpu,然后今天想着把GPU版本的也装上,结果conda install tensorflow-gpu后,出错提示UnavailableInvalidChannel: The channel is not accessible or is invalid。。。404。。。

https://blog.csdn.net/aaa958099161/article/details/90271642的博客中得知原因,该博客的评论区的一位大哥给了优秀找到解决方法,参考他的博客https://blog.csdn.net/qq_42859864/article/details/90340164#comments

解决方法:在conda里一行行键入以下命令即可:

conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://repo.continuum.io/pkgs/free/ 
conda config --add channels https://repo.continuum.io/pkgs/main/ 
conda config --set show_channel_urls yes

三、解决上述一系列问题后,我运行了yolov3网络加载官网权重做个测试,成功!!!然后第三天我又运行这个代码,哈哈哈报错UnknownError: 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.我重启电脑再运行yolov3,没报错!!!重启大法好!

总结这一路的踩坑,其实就不应该下载tensorflow-gpu1.13版本,太高了。安装低版本tf-gpu就不太会出错,conda自行安装的cuda和cudnn版本是9.0,和电脑的显卡驱动正好适配!!

conda install tensorflow-gpu==1.9.0

 

  • 7
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值