用指令python train.py --img 640 --batch 16 --epochs 5 --data ./data/voc2020.yaml --cfg ./models/yolov5x.yaml --device 0 --weights ''
报错RuntimeError: CUDA out of memory.Tried to allocate 32.00 MiB (GPU 0; 8.00 GiB total capacity; 5.98 GiB already allocated; 6.06 MiB free; 6.07 GiB reserved in total by PyTorch)
后来将--batch 16 改成--batch 4,将一次给的数据调小后,可以顺利运行,但是运行速度慢。
用的3070显卡,之前用yolov5s.yaml训练的时候,--batch 16没有问题的。
不知道你这个问题是否已经解决, 如果还没有解决的话:形如RuntimeError: CUDA out of memory. Tried to allocate 1.04 GiB (GPU 0; 4.00 GiB total capacity; 86.63 MiB already allocated; 2.52 GiB free; 94.00 MiB reserved in total by PyTorch)
显存不够,调小训练的batch-size,其他进程关掉点或者重启一下电脑