Unable to use my gpu for training data on yolov8 :says to cuda run out of memory

问题描述 投票:0回答:1

设备: Rtx 3050ti 笔记本电脑 gpu,i7 12 代 cpu 和 16 gb ram

使用它来运行代码

yolo task=detect mode=train epochs=10 data=data_custom.yaml model=yolov8l.pt device=0

每次都得到同样的错误

torch.cuda.OutOfMemoryError: CUDA out of memory. 
Tried to allocate 20.00 MiB (GPU 0; 3.80 GiB total capacity; 2.44 GiB already allocated; 23.38 MiB free; 2.47 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 

摆脱这个错误并在 gpu 本身上运行代码

python deep-learning pytorch yolo yolov8
1个回答
0
投票

您正在使用大型预训练模型,它需要大 GPU 和大量 RAM。 这里有一些你可以尝试的事情:

  1. 尝试减少批量大小。默认为 16,尝试 8 或更低。
  2. 尝试较小的型号,例如中型 (m)、小型 (s) 或纳米 (n) 型号,因为 RTX 3050Ti 是中低端 GPU。 (选择 S,然后是 M)
  3. 尝试增加分页大小,因为您有 16GB 的内存,这在将数据集加载到内存中时可能不够用。
  4. 在更强大的系统上训练模型,例如 Google Colab。
  5. 在 CPU 上训练模型。
© www.soinside.com 2019 - 2024. All rights reserved.