搭建YOLO环境配置使用requirements.txt产生的问题

前提

        博主在下载YOLOV7所依赖环境(基于py38的虚拟环境)中发现,requirements.txt文件中的pytorch,torchvision,torchaudio文件均为cpu模式,如果要使用本机GPU训练则需要提前将requirements.txt文件中,有关torch的三个包注释掉。搭建YOLO环境配置使用requirements.txt产生的问题_第1张图片

解决方案

        在pycharm中的终端中输入以下代码,先安装除了torch以外的其他第三方库。

 pip3 install --index-url https://pypi.douban.com/simple -r requirements.txt

        如果报错,pip版本等级过低,请先更新pip版本。

python -m pip install --upgrade pip 

         如果pip版本更新之后,仍然无法下载requirements文件下的库,并报错无法查到该库,请检查是否VPN关闭,无法进入内网下载。

对于Torch

        对于torch采取官网下载的方式,博主的cuda11.6版本,寻找对应的torch-cuda116 1.12.0,torchaudio-cuda116 0.12.0,torchvision-cuda116 0.13.0下载到本机https://download.pytorch.org/whl/cu116/torch/

        在终端,先cd到torch-cuda116所在文件夹下,使用下面代码格式进行安装(先安装torch)

pip install torch-1.12.0+cu116-cp38-cp38-win_amd64.whl 

import torch                         #在控制台使用,若返回True则torch-cuda安装成功

torch.cuda.is_available()

你可能感兴趣的:(目标检测专栏,pytorch,人工智能,python,计算机视觉,神经网络)