YOLO改进模块出现的问题及改进方法

1.grid_sampler_2d_backward_cuda

在对YOLOv9进行改进的过程中,有的时候就会出现这种报错:RuntimeError: grid_sampler_2d_backward_cuda does not have a deterministic implementation,but you set 'torch.use_deterministic_algorithms(True)'. You can turn off determinism just for this operation, or you can use the 'warn_only=True' option,

解决办法:

问题出在反向传播上面。在train_dual.py(train文件)直接搜索scaler.scale(loss).backward(),在其前面关闭这个决定性算法。

            torch.use_deterministic_algorithms(False)
            # Backward
            scaler.scale(loss).backward()

成功运行!

2. DataLoader worker

在对YOLOv9进行改进的过程中,有的时候就会出现这种报错:RuntimeError: DataLoader worker (pid(s) 10556, 2552, 32032, 34540, 34092, 24356) exited unexpectedly

原因:cuda 虚拟环境的共享内存不足

解决办法:

我是因为走之前开的Pycharm运行代码太多,又没有关机。直接在任务管理器把之前跑过的python服务台都关掉了。

有的同学可以直接

  • 要么改成更小的batchsize,
  • 将numworkers = 1注释掉,不用多进程

3. CUDA out of memory

报错RuntimeError: CUDA out of memory. Tried to allocate 50.00 MiB (GPU 0; 8.00 GiB total capacity; 5.91 GiB already allocated; 0 bytes free; 6.06 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

解决办法:同2

4.Input type (torch.cuda.HalfTensor)

 报错RuntimeError: Input type (torch.cuda.HalfTensor) and weight type (torch.cuda.FloatTensor) should be the same

解决办法:

这个是需要关掉混合精度amp,简单的方法,训练文件找到“ amp = check_amp(model)”下面加上“amp =False”就可以

还有打印不出来Gflops的和断点重训,见我之前的文章

修改yolov9的模型打印不出来Gflops的解决办法-CSDN博客

YOLOv9训练不中断,从断点处训练的方法_yolov9早停-CSDN博客

  • 16
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TracyGC

创作不易,需要花花~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值