如何解决在本地机器上在 GPU 上训练的模型的 YOLOV8 模型内存不足的错误

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

你好我有这个剧本

import ultralytics
from ultralytics import YOLO

import torch
torch.cuda.is_available()
ultralytics.checks()
 
if __name__ == "__main__":
    
    # Load a model
    model = YOLO('yolov8n.pt')  # load a pretrained model (recommended for training)

    # Train the model
    model.train(data='data.yaml', epochs=2, imgsz=832, device=0)

    # Load our custom goat model
    model = YOLO("runs/detect/train/weights/best.pt")

为此,我将 NVIDIA-SMI 作为

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 511.69       Driver Version: 511.69       CUDA Version: 11.6     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0 Off |                  N/A |
| N/A   47C    P8     3W /  N/A |      0MiB /  4096MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

在运行上面的脚本之前,我运行了以下 2 个代码

conda create -n ENV_NAME python=3.7
conda activate ENV_NAME
pip install ultralytics

conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia
conda install cudatoolkit

但是当我运行这段代码时,出现以下错误

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\aftab\.conda\envs\pytorch_env\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\aftab\.conda\envs\pytorch_env\lib\multiprocessing\spawn.py", line 126, in _main
    self = reduction.pickle.load(from_parent)
MemoryError
raise err
OSError: [WinError 1455] The paging file is too small for this operation to complete. Error loading "C:\Users\aftab\.conda\envs\pytorch_env\lib\site-packages\torch\lib\cudnn_adv_infer64_8.dll" or one of its dependencies.

我还尝试将 PC 高级设置中的内存增加到 8092 MB。我还可以做些什么 是否可以调试此错误,因为我想在我的本地机器上运行 YOLOV8 模型

python-3.x deep-learning gpu nvidia yolov8
© www.soinside.com 2019 - 2024. All rights reserved.