CUDA error: out of memory C/C++ Origin: Application & API OSI layer 7 · Application Last updated 2 Dec 2026

CUDA error: out of memory (cudaErrorMemoryAllocation)

A CUDA allocation failed because the GPU has no free memory for it.

Exact message you may see CUDA error: out of memoryout of memory cudaMalloc
Seen on: C/C++ CUDA

Meaning

cudaMalloc returns cudaErrorMemoryAllocation when device memory is exhausted. Other processes, leaks, fragmentation or too-large batches are typical.

Common causes

  • Batch or data too large for the GPU
  • Another process holds GPU memory
  • Memory leak (missing cudaFree)
  • Several contexts on one GPU

⚡ Quick fix

  1. Check usage with nvidia-smi
  2. Reduce batch size or use streaming/tiling
  3. Free memory with cudaFree and check for leaks

Detailed fix by platform

Linux

  1. nvidia-smi and fuser -v /dev/nvidia* to find the holders

How to diagnose

  1. Free — Memory left?
  2. Processes — Who uses the GPU?
  3. Leak — Allocations freed?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

0xC0000005 — The application was unable to start correctly (0xc0000005) / Exception code 0xc0000005 access violation (Windows)0xC0000005AddressSanitizer: heap-buffer-overflow — C/C++: ==ERROR: AddressSanitizer: heap-buffer-overflow on address — READ/WRITE of size N (C/C++)AddressSanitizer: hea…AddressSanitizer: heap-use-after-free — C/C++: ==ERROR: AddressSanitizer: heap-use-after-free on address — memory used after delete/free (C/C++)AddressSanitizer: hea…alloc-dealloc-mismatch — AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) (C/C++)alloc-dealloc-mismatchBus error — C/C++: Bus error (core dumped) — SIGBUS from misaligned access or a bad memory-mapped file (C/C++)Bus errorCannot allocate memory — fork: Cannot allocate memory / ENOMEM (Linux)Cannot allocate memorydouble free or corruption — C/C++: free(): double free detected / double free or corruption (out) — Aborted (core dumped) (C/C++)double free or corrup…Killed signal terminated program cc1plus — g++: fatal error: Killed signal terminated program cc1plus — compilation terminated (out of memory) (C/C++)Killed signal termina…CUDA erro…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.