TROUBLESHOOTING · NVIDIA GPU

Fix SadTalker CUDA out of memory.

Free up VRAM, reduce generation settings, and check that your next video finishes. Start with the simplest fixes before investigating the allocator.

Try the quick fix

If SadTalker stops during generation with an error such as:

torch.cuda.OutOfMemoryError: CUDA out of memory

your GPU has run out of usable VRAM for the current operation.

This usually does not mean SadTalker is installed incorrectly. In most cases, the GPU either does not have enough free memory, another program is already using part of the VRAM, or the current SadTalker settings require more memory than is available.

Start with the low-VRAM settings below, then verify the result on your own GPU. These steps are based on upstream documentation and public reports; they are not a locally reproduced OOM recovery test.

Quick Fix

Try these changes in this order:

  1. Close other applications using your NVIDIA GPU.
  2. Restart SadTalker or its Python process.
  3. Set SadTalker batch size to 1.
  4. Use the 256 face model instead of 512.
  5. Turn off GFPGAN Face Enhancer.
  6. Turn off the background enhancer if enabled.
  7. Run SadTalker again while monitoring VRAM with nvidia-smi.

Run this from your SadTalker folder with its Python environment active. Replace input.wav and input.png with your own file paths. The multiline examples use Bash; in Windows PowerShell or Command Prompt, put the command on one line:

Quick Fix · Terminal
python inference.py \
  --driven_audio input.wav \
  --source_image input.png \
  --size 256 \
  --batch_size 1

What Does CUDA Out of Memory Mean?

SadTalker uses PyTorch to run neural-network operations on an NVIDIA GPU.

The GPU has its own memory called VRAM. When PyTorch requests another block of GPU memory and enough usable VRAM is not available, generation can stop with a CUDA out-of-memory error.

A typical error begins with:

torch.cuda.OutOfMemoryError: CUDA out of memory

The rest of the message may tell you how much memory PyTorch attempted to allocate, how much VRAM the GPU contains, and how much memory remained free.

The exact numbers will be different on every system.

First Check Your GPU Memory

Open another terminal while SadTalker is running:

First Check Your GPU Memory · Terminal
nvidia-smi

Look for:

Memory-Usage

For example:

8000 MiB / 12288 MiB

This illustrative reading means about 7.8 GiB of a 12 GiB GPU is occupied; it is not a measurement from our test.

Also inspect the Processes section at the bottom of nvidia-smi.

You may find another Python process, AI application, Stable Diffusion instance, browser workload, or another GPU program already consuming VRAM.

Monitor VRAM Continuously on Linux

Use:

First Check Your GPU Memory · Terminal
watch -n 1 nvidia-smi

This refreshes GPU usage every second.

Press:

Ctrl+C

to stop monitoring.

Fix 1: Close Other GPU Processes

This is the first fix I recommend.

Run:

Fix 1: Close Other GPU Processes · Terminal
nvidia-smi

Check which processes are using GPU memory.

If another program that belongs to you is consuming several gigabytes of VRAM, close it before starting SadTalker.

On Linux you can also inspect Python processes:

Fix 1: Close Other GPU Processes · Terminal
ps -ef | grep python

Do not terminate random processes on a shared GPU server. Only stop a process when you know it belongs to your own workload.

After closing the unwanted process, run:

Fix 1: Close Other GPU Processes · Terminal
nvidia-smi

again.

Make sure the GPU now has substantially more free memory.

Then retry SadTalker.

Fix 2: Reduce SadTalker Batch Size

SadTalker's command-line interface uses:

--batch_size

for face rendering.

The default is 2.

Try:

Fix 2: Reduce SadTalker Batch Size · Terminal
--batch_size 1

Example:

Fix 2: Reduce SadTalker Batch Size · Terminal
python inference.py \
  --driven_audio input.wav \
  --source_image input.png \
  --batch_size 1

If you use the SadTalker WebUI, reduce the batch size in generation setting to:

1

A smaller batch generally requires less GPU memory.

Fix 3: Use 256 Instead of 512

SadTalker supports 256 and 512 face-render resolutions.

If you are running:

Fix 3: Use 256 Instead of 512 · Terminal
--size 512

change it to:

Fix 3: Use 256 Instead of 512 · Terminal
--size 256

Example:

Fix 3: Use 256 Instead of 512 · Terminal
python inference.py \
  --driven_audio input.wav \
  --source_image input.png \
  --size 256 \
  --batch_size 1

SadTalker's default CLI resolution is already 256, making this a sensible setting for GPUs with limited VRAM.

In the WebUI, select:

256

for the face model resolution.

Fix 4: Disable GFPGAN Face Enhancement

SadTalker can optionally run a face-restoration model after generating the animation.

You may see:

--enhancer gfpgan

in your command.

Try removing it.

Instead of:

Fix 4: Disable GFPGAN Face Enhancement · Terminal
python inference.py \
  --driven_audio input.wav \
  --source_image input.png \
  --enhancer gfpgan

run:

Fix 4: Disable GFPGAN Face Enhancement · Terminal
python inference.py \
  --driven_audio input.wav \
  --source_image input.png

If you're using WebUI, turn off:

GFPGAN as Face enhancer

This isolates the additional restoration stage so you can check whether basic generation completes first.

Fix 5: Disable Background Enhancement

SadTalker also supports:

--background_enhancer realesrgan

If you enabled it, remove the option while troubleshooting.

Start with basic generation first.

Once basic SadTalker generation works reliably, you can test optional enhancement separately.

Fix 6: Restart SadTalker

PyTorch uses a CUDA caching allocator.

This means GPU memory shown by nvidia-smi can sometimes remain reserved while a Python process is still alive.

Stop SadTalker completely and start it again.

Then check:

Fix 6: Restart SadTalker · Terminal
nvidia-smi

before generating another video.

If an old Python process remains active, identify it with:

Fix 6: Restart SadTalker · Terminal
ps -ef | grep python

and stop only the process you own and recognize.

Does torch.cuda.empty_cache() Fix CUDA OOM?

You may see this command recommended online:

Does torch.cuda.empty_cache() Fix CUDA OOM? · Python
torch.cuda.empty_cache()

It can release unused cached memory so that memory becomes available to other GPU applications.

However, it does not free GPU memory that is still being used by active PyTorch tensors.

For a normal SadTalker user, completely restarting the failed Python/SadTalker process is usually easier than modifying SadTalker's code to call empty_cache().

What About PYTORCH_CUDA_ALLOC_CONF?

Some CUDA OOM messages mention:

PYTORCH_CUDA_ALLOC_CONF

Use the documentation for your installed PyTorch version. Current PyTorch documents PYTORCH_ALLOC_CONF, with PYTORCH_CUDA_ALLOC_CONF retained as a compatibility alias; older SadTalker environments commonly use the latter.

Allocator tuning can sometimes help when memory fragmentation is the actual problem.

However, PyTorch describes options such as max_split_size_mb as a last-resort setting for workloads that fail because of allocator fragmentation.

I would not use allocator settings as the first SadTalker fix.

First try:

  • freeing VRAM,
  • batch size 1,
  • resolution 256,
  • disabling GFPGAN,
  • disabling background enhancement,
  • restarting SadTalker.

Only investigate allocator configuration if the error specifically suggests that reserved but unused memory is unusually large.

Check PyTorch GPU Memory Directly

You can verify your CUDA GPU from the SadTalker environment with:

Check PyTorch GPU Memory Directly · Terminal
python -c "import torch; ok=torch.cuda.is_available(); print(ok); print(torch.cuda.get_device_name(0) if ok else 'CUDA unavailable')"

A healthy NVIDIA setup should return something similar to:

True
NVIDIA GeForce RTX 3060

If CUDA is available, inspect free and total GPU memory. This checks device-wide availability in a separate process; it does not measure SadTalker’s peak allocation:

Check PyTorch GPU Memory Directly · Terminal
python -c "import torch; free,total=torch.cuda.mem_get_info(); print('Free:',round(free/1024**3,2),'GiB'); print('Total:',round(total/1024**3,2),'GiB')"

CUDA OOM vs CUDA Driver Errors

Do not confuse a CUDA OOM with a CUDA initialization problem.

A genuine memory error usually contains:

CUDA out of memory

Errors such as:

Failed to initialize NVML

or:

Driver/library version mismatch

are different problems.

Likewise, CUDA initialization errors should be fixed at the NVIDIA driver/CUDA level rather than by lowering SadTalker's batch size.

How to Verify the Fix

After applying a change, first run:

How to Verify the Fix · Terminal
nvidia-smi

Record the free VRAM.

Then run SadTalker:

How to Verify the Fix · Terminal
python inference.py \
  --driven_audio input.wav \
  --source_image input.png \
  --result_dir results \
  --size 256 \
  --batch_size 1

While generation is running, monitor:

How to Verify the Fix · Terminal
watch -n 1 nvidia-smi

The fix is verified when:

  • SadTalker completes without a CUDA OOM,
  • an MP4 is created in the results directory,
  • the MP4 opens and plays with the expected audio,
  • and the process releases its GPU allocations when it exits (other programs may still occupy VRAM).

My Suggested Troubleshooting Order

If you want the shortest path, use this order:

Suggested troubleshooting order
StepChange
1Run nvidia-smi
2Close your unused GPU processes
3Restart SadTalker
4Set batch size to 1
5Set resolution to 256
6Disable GFPGAN
7Disable background enhancement
8Retest and monitor VRAM
9Investigate allocator fragmentation only if the error points to it
10Use CPU or a GPU with more VRAM if the workload still cannot fit

Can SadTalker Run on a 4 GB GPU?

There is no single VRAM requirement that guarantees every SadTalker configuration will work.

A user in SadTalker discussion #457 reported an OOM on a 4 GB NVIDIA laptop GPU. That report is evidence of a failure, not a verified recovery or a universal minimum-VRAM requirement.

Available VRAM also depends on other GPU processes and the options enabled during inference.

If you're working with limited VRAM, start with:

256 resolution
batch size 1
no GFPGAN
no background enhancer

Can I Run SadTalker on CPU Instead?

SadTalker's CLI includes a CPU option.

You can try:

Can I Run SadTalker on CPU Instead? · Terminal
python inference.py \
  --driven_audio input.wav \
  --source_image input.png \
  --cpu

CPU inference will normally be significantly slower than NVIDIA GPU inference, so I would treat this as a fallback rather than the first solution.

FAQ

Why does SadTalker say CUDA out of memory?

The GPU does not have enough usable VRAM for the current operation. Another GPU process, higher rendering settings, batch size, or optional enhancement can contribute to the problem.

What batch size should I use?

For troubleshooting low VRAM, start with:

batch size = 1

Should I use SadTalker 256 or 512?

Try 256 first when GPU memory is limited.

Does GFPGAN require additional resources?

GFPGAN runs an additional face-restoration stage. If SadTalker fails during or around enhancement, disable GFPGAN and test basic generation first.

Will torch.cuda.empty_cache() solve every OOM?

No. It releases unused cached allocations, not memory occupied by active tensors.

How do I know another program is using my GPU?

Run:

FAQ · Terminal
nvidia-smi

and inspect the process list and GPU memory usage.

What if nvidia-smi itself fails?

Then you probably have a GPU driver or NVIDIA runtime problem rather than a normal SadTalker CUDA OOM. Fix the NVIDIA environment before troubleshooting SadTalker's memory settings.