YOLOv5环境搭建

要搭建YOLOv5环境就首先要安装Anaconda,关于Anaconda的安装方法,参考我的另外一篇博客,Anaconda配置安装,亲测有效_weixin_47060902的博客-CSDN博客

Anaconda安装完成之后,首先要创建YOLOv5的虚拟环境,我的python是3.8版本的

conda create -n yolov5 python=3.8

可以在anaconda输入

conda env list

查看创建了哪些虚拟环境。

之后要调用这个环境

conda activate yolov5

之后要更换镜像源,推荐使用清华镜像源

conda config --remove-key channels
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
 
# 搜索时显示通道地址
conda config --set show_channel_urls yes

更换镜像源之后就开始安装pytorch框架

这里给出gpu版本和cpu版本的指令,安装gpu版本要注意pytorch与cuda的版本对应关系

gpu版本

conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1

cpu版本

conda install pytorch torchvision cpuonly 

pytorch框架安装成功之后,需要安装 requirements.txt文件里面的库

首先得找到你程序文件夹存放的位置,我的文件是存放在d盘里,所以输入

d:

然后找到你文件的位置

cd D:\yolov5-master\yolov5-master

 之后输入下面这一行,等待安装完成

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=1000 -r requirements.txt

等待安装完成即可

你可能感兴趣的:(python,开发语言)