输入nvidia-smi命令查看cuda版本号, 系统的CUDA版本决定了系统最高可以支持什么版本的cudatoolkit,它是向下兼容的, 可以装低版本但是不能装高版本。

更新下conda,用管理员打开cmd

conda update -n base -c defaults conda

安装CUDATookit

使用以下命令:

conda install -c conda-forge cudatoolkit=10.2

安装CUDNN

注意:安装的cudnn版本必须依赖于cudatookit的版本

cuda与cudnn的对应关系可以在cuDNN历史版本下载页面看到:

这里我简单列出来了较新的一些版本之间的对应关系

根据上图可知,我安装了CUDA 10.2版本,那么可选的cuDNN版本有很多,这里我直接无脑安装了最新版本,也就是cuDNN的8.4.0版本,同样是用清华镜像源来安装

conda install cudnn=8.4.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/

 提示Your installed version is: 0,说我的版本冲突,安装低版本的试下

conda install cudnn=8.2.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/

 安装pytorch

conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=10.2 -c pytorch

反复版本安装测试,发现每次都是安装成了CPU版本,解决办法就是手动下载进行安装

网址https://download.pytorch.org/whl/torch_stable.html

比如说我创建的环境python版本为3.9,电脑为64位,10.2的CUDA,下载对应版本的torch和torchvision,torch下载版本

接下来再安装torchvision,它的版本要和自己下的torch版本所对应,对应表如下图所示。

我下载的1.10.2的版本,所以对应torchvision的版本为0.11.3,其余也要对应torchvision下载版本 

下载后进入进入虚拟环境,使用pip install进行安装

测试环境

安装yolov5测试例程的依赖

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple

测试推理,速度比CPU快很多

Logo

分享最新的 NVIDIA AI Software 资源以及活动/会议信息,精选收录AI相关技术内容,欢迎大家加入社区并参与讨论。

更多推荐