CUDA error: out of memory (cudaErrorMemoryAllocation)
A CUDA allocation failed because the GPU has no free memory for it.
CUDA error: out of memoryout of memory cudaMalloc 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
- Check usage with
nvidia-smi - Reduce batch size or use streaming/tiling
- Free memory with
cudaFreeand check for leaks
Detailed fix by platform
Linux
nvidia-smiandfuser -v /dev/nvidia*to find the holders
How to diagnose
- Free — Memory left?
- Processes — Who uses the GPU?
- 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:
Similar errors
- 0xC0000005 The application was unable to start correctly (0xc0000005) / Exception code 0xc0000005 access violation
- AddressSanitizer: heap-buffer-overflow C/C++: ==ERROR: AddressSanitizer: heap-buffer-overflow on address — READ/WRITE of size N
- AddressSanitizer: heap-use-after-free C/C++: ==ERROR: AddressSanitizer: heap-use-after-free on address — memory used after delete/free
Most viewed in C/C++
- was not declared in this scope C++: error: 'x' was not declared in this scope (undeclared identifier)
- control reaches end of non-void function C/C++: warning: control reaches end of non-void function [-Wreturn-type]
- runtime error: C/C++: runtime error: signed integer overflow / null pointer / shift exponent too large (UndefinedBehaviorSanitizer)
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 2 Dec 2026