由于在本地部署该项目时,即使安装了requirements上的库文件还是会遇到一些问题,可能是因为某些库版本过高的原因,因此在此记录一下。首先是笔者的Python版本和安装的库的版本
首先第一个问题是在训练模型时会报错
AttributeError: module 'numpy' has no attribute 'int'.
这里是numpy版本过高的原因,降到1.24.0版本以下就可以解决这个问题
pip uninstall numpy
pip install numpy==1.23.5
第二个错误
RuntimeError: result type Float can't be cast to the desired output type __int64
解决办法
解决Yolov5的RuntimeError: result type Float can‘t be cast to the de - 哔哩哔哩 (bilibili.com)
第三个问题就是在使用export.py导出onnx文件时遇到AttributeError: 'Namespace' object has no attribute 'ncnn'解决办法为将111行的
elif opt.concat or opt.mnnd or opt.mnne or opt.ncnn:
换为
elif opt.concat or opt.mnnd or opt.mnne:
第四个问题就是关于训练环境的配置问题,我的主机是4070显卡,最高支持cuda12.4,因此安装了cuda12.4,并安装了cudnn-windows-x86_64-9.0.0.312_cuda12-archive,将其解压到cuda安装目录替换即可,最后是pytorch,安装的是torch-2.2.2+cu121-cp311-cp311-win_amd64.whl和torchvision-0.17.2+cu121-cp311-cp311-win_amd64.whl,最后就可以愉快的训练啦