Pytorch RuntimeError: CUDA out of memory with a huge amount of free memory

We Are Going To Discuss About Pytorch RuntimeError: CUDA out of memory with a huge amount of free memory. So lets Start this Python Article.

Pytorch RuntimeError: CUDA out of memory with a huge amount of free memory

  1. How to solve Pytorch RuntimeError: CUDA out of memory with a huge amount of free memory

    Your problem may be due to fragmentation of your GPU memory.You may want to empty your cached memory used by caching allocator.
    import torch torch.cuda.empty_cache()

  2. Pytorch RuntimeError: CUDA out of memory with a huge amount of free memory

    Your problem may be due to fragmentation of your GPU memory.You may want to empty your cached memory used by caching allocator.
    import torch torch.cuda.empty_cache()

Solution 1

Your problem may be due to fragmentation of your GPU memory.You may want to empty your cached memory used by caching allocator.

 import torch
 torch.cuda.empty_cache()

Original Author Erol Gelbul Of This Content

Solution 2

I was trying this command:

python3 val.py --weights ./weights/yolov5l-xs-1.pt --img 1996 --data ./data/VisDrone.yaml

and I have a 24G Titan video Card.

Then I reduced the image size and worked for me. to:

python3 val.py --weights ./weights/yolov5l-xs-1.pt --img 1280  --data ./data/VisDrone.yaml

Results:

Class     Images     Labels          P          R     [email protected] [email protected]:.95: 100%|████████████████████████████████| 18/18 [00:50<00:00,  2.79s/it]
                 all        548      38759      0.653      0.537      0.584      0.375
          pedestrian        548       8844       0.74      0.631      0.708      0.375
              people        548       5125      0.677      0.506      0.574      0.258
             bicycle        548       1287      0.541      0.377       0.41      0.213
                 car        548      14064      0.828      0.868      0.904      0.681
                 van        548       1975      0.636      0.566      0.601      0.453
               truck        548        750      0.595      0.516      0.538      0.388
            tricycle        548       1045      0.601      0.416      0.457      0.288
     awning-tricycle        548        532      0.387      0.242      0.245      0.173
                 bus        548        251      0.782      0.653      0.725      0.565
               motor        548       4886      0.744      0.598      0.674      0.355

Original Author Oscar Rangel Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment