搭建Windows11下yolov5环境

该博客主要介绍了Yolov5环境搭建的步骤。首先需下载安装Anaconda3,接着创建yolov5虚拟环境,可在CMD或Anaconda3中操作。然后查看电脑显卡适合的cuda与cudnn版本,最后进入官网寻找相应pytorch版本并下载,还提及更改通道以加快下载速度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 下载和安装Anaconda3

见链接:Anaconda3安装

2. 创建yolov5的虚拟环境

在CMD或者Anaconda Prompt(Anaconda3)创建

2.1 WIN+R调出运行框,输入CMD,回车

2.1.1 创建新的虚拟环境

create Create a new conda environment from a list of specified packages.

命令:conda create -n your_env_name python=x.x
创建python版本为x.x,名字为your_env_name的虚拟环境。your_env_name文件可以在Anaconda安装目录envs文件下找到。

conda create -n yolov5 python=3.9.12
有时候会出现失败的情况
在这里插入图片描述
找到C:\Users\用户名(比如xxx).condarc这个隐藏文件,内容改为下面

ssl_verify: true
show_channel_urls: true

channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

然后重新执行conda create -n yolov5 python=3.9.12命令,成功激活的情况如下
在这里插入图片描述

2.1.2 进入(激活/切换)所创建的环境

conda activate your_env_name
在这里插入图片描述
输入conda list即可查看环境配置
在这里插入图片描述
退出环境:deactivate
移除某个环境: conda remove --name xxx --all

2.2 在Anaconda3创建

在开始菜单,所有程序找到Anaconda Navigator(Anaconda3),点击Cteate创建一个环境。
在这里插入图片描述

3. 查看电脑显卡适合的cuda与cudnn版本

找到显卡型号,到nvidia geforce驱动下载对应的驱动,安装驱动后,通过
Win11查看CUDA版本,非常简单的三步
可以查看到CUDA版本,如下图
在这里插入图片描述

DNN的下载链接cuDNN Download
NVIDIA cuDNN is a GPU-accelerated library of primitives for deep neural networks.
在这里插入图片描述

在这里插入图片描述
这两种方式获取CUDNN都可以,我选择第1张图这个版本

4. 下载相应的pytorch,cuda与cudnn版本

更改通道(为了下载的更快)
1.用txt形式打开C:\Users\xxx(用户名)该目录下.condarc文件
2.将如下代码全部复制进该txt

channels:
  - defaults

show_channel_urls: true

default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud`

下载相应的pytorch,cuda与cudnn

4.1 进入官网寻找相应pytorch版本

官网链接:https://pytorch.org/get-started/locally/
根据自己的需求选择,如图所示,我们用cuda11.4为例,通过pythorch非最新版本
找到我们cuda11.4的版本,对应cudatoolkit=11.3
在这里插入图片描述

conda install pytorch1.12.1 torchvision0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch

4.2 打开cmd,激活你为yolov5配置的环境

在这里插入图片描述

4.3 下载pytorch

调用 conda install 安装的包将安装到此环境中
install Installs a list of packages into a specified conda environment.

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

loongembedded

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值