当前位置:网站首页>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。
边栏推荐
- 删除分类网络预训练权重的的head部分的权重以及修改权重名称
- 《机器学习》(周志华)第2章 模型选择与评估 笔记 学习心得
- 国内外知名源码商城系统盘点
- Add se channel attention module to the network
- 【activiti】activiti环境配置
- Multi merchant mall system function disassembly lecture 07 - platform side commodity management
- 【activiti】流程实例
- Test whether the label and data set correspond after data enhancement
- 达梦数据库_常用的用户管理命令
- [activiti] activiti process engine configuration class
猜你喜欢

Could not load library cudnn_ cnn_ infer64_ 8.dll. Error code 126Please make sure cudnn_ cnn_ infer64_ eight

Zotero快速上手指南

Recommend a fully open source, feature rich, beautiful interface mall system

《统计学习方法(第2版)》李航 第14章 聚类方法 思维导图笔记 及 课后习题答案(步骤详细) k-均值 层次聚类 第十四章

Multi merchant mall system function disassembly lecture 09 - platform end commodity brands

A small problem in labelme to VOC code
![Use streaming media to transfer RSTP to the Web terminal for playback (II) [review]](/img/b9/2c0e6eb19acaa2356ff49f6e272826.png)
Use streaming media to transfer RSTP to the Web terminal for playback (II) [review]

Inventory of well-known source code mall systems at home and abroad

程序员常说的API是什么意思?API类型有什么呢?

《统计学习方法(第2版)》李航 第17章 潜在语义分析 LSA LSI 思维导图笔记 及 课后习题答案(步骤详细)第十七章
随机推荐
Small operation of statistical signal processing -- detection of deterministic DC signal in Rayleigh distributed noise
【mycat】mycat配置文件
Multi merchant mall system function disassembly lecture 05 - main business categories of platform merchants
Connect CRM system and effect advertising, help enterprises with precision marketing, and help enterprises with precision marketing
Numpy cheatsheet
找数组中出现次数最多的数
Multi merchant mall system function disassembly lecture 06 - platform side merchant settlement agreement
【activiti】个人任务
[vSphere high availability] host failover
Multi merchant mall system function disassembly lecture 09 - platform end commodity brands
多商户商城系统功能拆解06讲-平台端商家入驻协议
A small problem in labelme to VOC code
The SaaS mall system of likeshop single merchant is built, and the code is open source without encryption.
Brief introduction of [data mining] cluster analysis
在网络中添加spp模块中的注意点
在网络中添加SE通道注意力模块
[vSphere high availability] working principle of host and virtual machine fault monitoring
《机器学习》(周志华)第一章 绪论 笔记 学习心得
【activiti】activiti系统表说明
达梦数据库_逻辑备份