当前位置:网站首页>tensorflow和pytorch框架的安装以及cuda踩坑记录
tensorflow和pytorch框架的安装以及cuda踩坑记录
2022-07-24 05:20:00 【Julyers】
pytorch
采用conda创建虚拟环境python=3.6以后,我发现使用conda install torchvision安装完pytorch是cpu版本的,不支持gpu,在跑代码时报错了。
import torch
torch.__version__
torch.cuda.is_available()
此时cuda是False,gpu不可用。然后需要用conda uninstall torchvision卸载torchvision。
再使用pip install torchvision -i https://pypi.douban.com/simple安装,验证gpu是否可用,此时是True,gpu可用。
以上亲测,pip安装的torchvision会同时安装对应cuda toolkit包,而conda安装只支持cpu。
tensorflow
在我折腾半天显卡驱动、cuda、cudnn以后,发现使用conda安装tensorflow,会自动安装对应的cuda,验证gpu是否可用,竟然是True。。。
import tensorflow as tf
tf.test.is_gpu_available()
亲测:
不装cuda和cudnn,直接采用conda创建虚拟环境以后,使用conda install tensorflow-gpu==1.15.0会自动安装对应cuda toolkit包,然后验证gpu是否可用,是True。
关于cuda和cudnn
1、显卡驱动可以在ubuntu的Software & Updates中的additional drivers中进行更换。
2、nvidia-smi显示的是驱动cuda版本为11.2。与手动安装的cuda toolkit包不同。
查看cuda版本
手动安装会在usr/local文件夹下。
cat /usr/local/cuda/version.txt
没有安装cuda输入nvcc -V命令,会出现安装cuda的sudo apt-get install命令,使用这个命令安装的cuda不在local文件夹下,而在usr/lib文件夹下。输入上面的命令会显示没有该目录。手动进入lib文件夹下,也有version.txt可看到版本。不建议用此方式。
查看cudnn版本
1)使用tar.gz安装的cudnn
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
2)使用deb安装的cudnn
dpkg -l | grep cudnn

3、关于3者的版本问题。
驱动cuda版本向下兼容cuda toolkit版本。通俗的解释就是,nvidia-smi显示的驱动cuda是11.2,最高支持cuda11.2。这里tensorflow1.15.0对应的cuda为10.0,cudnn为7.4.2。
边栏推荐
- Flink format series (1) -json
- 【mycat】mycat介绍
- Could not load library cudnn_ cnn_ infer64_ 8.dll. Error code 126Please make sure cudnn_ cnn_ infer64_ eight
- PyTorch 单机多卡分布式训练
- 《统计学习方法(第2版)》李航 第15章 奇异值分解 SVD 思维导图笔记 及 课后习题答案(步骤详细)SVD 矩阵奇异值 十五章
- 【activiti】activiti介绍
- plsql查询数据乱码
- 第五章神经网络
- 测试数据增强后标签和数据集是否对应
- [data mining] zero foundation entry decision tree
猜你喜欢
随机推荐
Sqlserver completely deleted
My little idea -- using MATLAB to realize reading similar to ring buffer
ERP+RPA 打通企业信息孤岛,企业效益加倍提升
如何在网页上下载视频
The female colleague of the company asked me to go to her residence to repair the computer at 11 o'clock at night. It turned out that disk C was popular. Look at my move to fix the female colleague's
对接CRM系统和效果类广告,助力企业精准营销助力企业精准营销
Zotero Quick Start Guide
jupyter notebook一直自动重启(The kernel appears to have died. It will restart automatically.)
国内外知名源码商城系统盘点
How to quickly recover data after MySQL misoperation
【activiti】流程变量
Multi merchant mall system function disassembly lecture 04 - platform side merchants settling in
++cnt1[s1.charAt(i) - ‘a‘];
Brief introduction of [data mining] cluster analysis
Zotero快速上手指南
Problems in SSM project configuration, various dependencies, etc. (for personal use)
公众号开发自定义菜单和服务器配置同时启用
Read "Enlightenment: a 20-year career experience of an IT executive"
关于卷积神经网络中的“输入通道”和“输出通道”的概念
达梦数据库_逻辑备份









