快速配置深度学习环境

查看版本适配
https://blog.csdn.net/caiguanhong/article/details/112184290
https://tensorflow.google.cn/install/source

在这里插入图片描述

pytorch查看gpu
https://blog.csdn.net/nima1994/article/details/83001910
Import torch
torch.cuda.is_available()
cuda是否可用;

torch.cuda.device_count()
返回gpu数量;

torch.cuda.get_device_name(0)
返回gpu名字,设备索引默认从0开始;

torch.cuda.current_device()
返回当前设备索引;

tensorflow查看gpu
https://blog.csdn.net/u013538542/article/details/83830249
tf.test.is_gpu_available()

anaconda镜像站(换源用)
https://mirrors.bfsu.edu.cn/

pytorch安装gpu环境

先查看云环境提供的显卡驱动版本,然后根据版本选择合适的cuda,cudnn在虚拟环境中使用conda进行安装:conda install cudnn=8.1.0
tensorflow可以使用pip安装

gpu版本pytorch:conda install pytorch torchvision cudatoolkit

一定要注意显卡驱动版本、深度学习框架版本、cudnn,cuda,cudatoolkit之间的兼容关系:
https://www.jianshu.com/p/ac70300b598b
https://tensorflow.google.cn/install/source#gpu_support_3
https://blog.csdn.net/caiguanhong/article/details/112184290
https://www.cnblogs.com/Wanggcong/p/12625540.html

一个可以兼容的配置:
Pytorch 1.4.0
Tensorflow 2.3.0
Cuda 10.1
Cudnn 7.6.5
base环境装好的cuda等可以给虚拟环境用,虚拟环境也可以另装

驱动向下兼容,装高版本的驱动没错
我装的驱动版本是
在这里插入图片描述

但是装上低版本的torch依旧可以用gpu
https://pytorch.org/get-started/previous-versions/
在这里插入图片描述
在这里插入图片描述

此时可以再装个tf-gpu=1.12
https://blog.csdn.net/K1052176873/article/details/114526086
完美兼容
在这里插入图片描述

归纳:
1.base环境下的驱动,cudnn其实对虚拟环境中的torch,tf等影响不大;驱动版本向下兼容,所以建议驱动安装高版本
2.在高级版本中,同时兼容tf和torch调用gpu,我使用的版本的:
Torch=1.4.0
Tensorflow=2.3.0
兼容如图
在这里插入图片描述
在这里插入图片描述

低版本中使用的是:
Tensorflow-gpu=1.12.0,keras=2.2.4(https://blog.csdn.net/l641208111/article/details/117123397)torch=0.4.1
兼容如图
在这里插入图片描述

3.安装时,先在pytorch官网选择对应命令安装torch的gpu环境,然后测试gpu是否可用,接着根据安装torch时的cuda版本选择tf的版本,使用pip安装对应版本tf,此时测试如果不可用,再conda search cudnn,根据cuda版本找到合适的cudnn进行安装。完毕后,就得到了同时兼容的环境。以安装低版本的兼容环境为例,步骤如下
安装torch
在这里插入图片描述

安装tf
在这里插入图片描述

寻找合适的cudnn版本
在这里插入图片描述

确认安装

在这里插入图片描述

我的base环境如下
在这里插入图片描述

在这里插入图片描述

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值