在腾讯云IDE上部署 YOLOv5-v6.0 环境
0 前言
本章节主要记录在远古设备上使用v6.0版本的yolov5的搭建,主要原因还是经常性有人来问,太长了。
这次的平台在 腾讯云IDE 上搭建,2024-11-18仍可免费。
硬件与软件列表:
- NVIDIA Tesla T4 (8h32g 8TFlops SP)
- Linux VM-0-203-ubuntu 5.4.0-166-generic #183-Ubuntu SMP Mon Oct 2 11:28:33 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
- CUDA12.0 (用
nvidia-smi
查看)
1 环境
先把yolov5-v6.0的pull到本地,https://github.com/ultralytics/yolov5/releases/tag/v6.0 。
1.1 Conda 环境
conda create -n yolov5-v6.0 python=3.8
conda activate yolov5-v6.0
1.2 pip 环境
一般都是 pytorch 版本不好找,去 Pytroch官方 找比较方便,直接搜对应的CUDA版本, 没有就往下降,如CUDA12.0,选择CUDA11.8的也行
# CUDA 11.8
conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 pytorch-cuda=11.8 -c pytorch -c nvidia
不建议使用 pip install -r requirements.txt
,单独安装比较好:
# Base ----------------------------------------
pip install matplotlib==3.2.2
pip install numpy==1.18.5
pip install opencv-python==4.1.2.30
pip install Pillow==7.1.2
pip install PyYAML==5.3.1
pip install requests>=2.23.0
pip install scipy==1.4.1
pip install tqdm==4.41.0
pip install protobuf==3.20.3
# Logging -------------------------------------
pip install tensorboard==2.4.1
# Plotting ------------------------------------
pip install pandas==1.1.4
pip install seaborn==0.11.0
# Export --------------------------------------
pip install onnx==1.9.0 # ONNX export
pip install onnx-simplifier==0.3.6 # ONNX simplifier
pip install onnxruntime==1.6.0
# pip install numpy==1.18.5
# Extras --------------------------------------
pip install thop # FLOPs computation
1.2.1 依赖导致报错问题
另外在腾讯云的平台上缺了mkl
依赖,导致报错:
from torch._C import * # noqa: F403......site-packages/torch/lib/libtorch_cpu.so: undefined symbol: iJIT_NotifyEvent
补上
pip install mkl==2024.0.0
另外torch版本太高了,会报错:AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
定位到.../site-packages/torch/nn/modules/upsampling.py”
修改成:
def forward(self, input: Tensor) -> Tensor:
# return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners,
# recompute_scale_factor=self.recompute_scale_factor)
return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners)
报错:RuntimeError: result type Float can't be cast to the desired output type long int
修改loss.py
# anchors = self.anchors[i]
anchors, shape = self.anchors[i], p[i].shape
# indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices
indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1))) # image, anchor, grid
py38_yolov5-6.0_requirements.txt
:
Package Version
---------------------- --------------------
absl-py 2.1.0
cachetools 4.2.4
certifi 2024.8.30
charset-normalizer 3.4.0
coloredlogs 15.0.1
cycler 0.12.1
flatbuffers 24.3.25
google-auth 1.35.0
google-auth-oauthlib 0.4.6
grpcio 1.68.0
humanfriendly 10.0
idna 3.10
importlib_metadata 8.5.0
intel-cmplr-lib-ur 2024.2.1
intel-openmp 2024.2.1
kiwisolver 1.4.7
Markdown 3.7
MarkupSafe 2.1.5
matplotlib 3.2.2
mkl 2024.0.0
mpmath 1.3.0
numpy 1.18.5
oauthlib 3.2.2
onnx 1.9.0
onnx-simplifier 0.3.6
onnxoptimizer 0.3.13
onnxruntime 1.6.0
opencv-python 4.1.2.30
packaging 24.2
pandas 1.1.4
Pillow 7.1.2
pip 24.3.1
protobuf 5.28.3
pyasn1 0.6.1
pyasn1_modules 0.4.1
pyparsing 3.1.4
python-dateutil 2.9.0.post0
pytz 2024.2
PyYAML 5.3.1
requests 2.32.3
requests-oauthlib 2.0.0
rsa 4.9
scipy 1.4.1
seaborn 0.11.0
setuptools 75.3.0
six 1.16.0
sympy 1.13.3
tbb 2021.13.1
tensorboard 2.4.1
tensorboard-plugin-wit 1.8.1
thop 0.1.1.post2209072238
torch 1.10.0
torchaudio 0.10.0
torchvision 0.11.0
tqdm 4.41.0
typing_extensions 4.12.2
urllib3 2.2.3
Werkzeug 3.0.6
wheel 0.45.0
zipp 3.20.2
1.3 测试
python -c "import torch; print(torch.cuda.is_available())"
python detect.py
python export.py --weights yolov5s.pt --include onnx --dynamic
python train.py
版权申明
本文系作者 @ATRAY 原创发布在ATRAY站点。未经许可,禁止转载。
暂无评论数据