训练yolo时报错RuntimeError: result type Float can‘t be cast to the desired output type __int64个人解决方案

2023-11-15

运行YOLOv5 6.1和yolor的时候,训练都没能正常运行,均出现了如下错误:

AutoAnchor: 5.00 anchors/target, 1.000 Best Possible Recall (BPR). Current anchors are a good fit to dataset
Image sizes 640 train, 640 val
Using 0 dataloader workers
Logging results to runs\train\exp14
Starting training for 300 epochs...

 Epoch   gpu_mem       box       obj       cls    labels  img_size
0%| | 0/8 [00:03<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 634, in
main(opt)
File "train.py", line 525, in main
train(opt.hyp, opt, device, callbacks)
File "train.py", line 320, in train
loss, loss_items = compute_loss(pred, targets.to(device)) # loss scaled by batch_size
File "E:Deeplearn\yolov5\utils\loss.py", line 120, in call
tcls, tbox, indices, anchors = self.build_targets(p, targets) # targets
File "E:Deeplearn\yolov5\utils\loss.py", line 217, in build_targets
indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices
RuntimeError: result type Float can't be cast to the desired output type __int64

在网络上搜索错误,没有找到解决方案,只能尝试自己分析错误原因。

由于学校的电脑可以正常运行,家中电脑就出现了这个问题,两台电脑的环境差别只有pytorch版本不同,故合理怀疑是Pytorch 1.12版本的问题,将pytorch降级为1.11版本,再次运行后问题解决

PS:pytorch降级办法:

用anaconda管理环境的话,直接输入官方上提供的安装1.11的指令,就可以,由于1.12支持11.6版本的cuda,所以很多人因为cuda版本是11.6所以安装的pytorch1.12(比如我),所以降级的时候一定要注意自己的cuda版本与1.11要求的匹配

# CUDA 10.2
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=10.2 -c pytorch

# CUDA 11.3
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch

# CPU Only
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cpuonly -c pytorch

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

训练yolo时报错RuntimeError: result type Float can‘t be cast to the desired output type __int64个人解决方案 的相关文章

  • OA项目软件说明书

    最近写了一个OA项目 主要根据这个软件说明书来编写的 此处省略了封面的一些格式不友好的内容 目 录 1 引言 1 1 目的 1 2 定义 1 3 参考资料 2 软件总体概述 2 1 软件标识 2 1 1 项目名称 2 1 2 产品标识 2
  • 2023校园招聘求职报告

    导读 超四成学生选择就业 近三成学生选择继续深造 近两成的学生计划考公务员 还有6 1 的学生有自主创业的想法 从学生反馈来看大家在毕业后的计划多元化趋势明显 选择就业的人数偏少而深造和考公人数比例达到45 受疫情影响和不少行业的升级调整过

随机推荐