deepfakes/faceswap · error · FaceswapError
You do not have enough GPU memory available to run detection
Error message
You do not have enough GPU memory available to run detection at the selected batch size. Youcan try a number of things: 1) Close any other application that is using your GPU (web browsers are particularly bad for this). 2) Try again. Sometimes this can be a transient issue when you are close to VRAM capacity. 3) Lower the batch size (the amount of images fed into the model) by editing the plugin settings (GUI: Settings > Configure extract settings, CLI: Edit the file faceswap/config/extract.ini). 4) Use lighter weight plugins. 5) Enable fewer plugins.
What it means
FaceswapError wrapping a framework OutOfMemoryError raised inside plugin.process during detection/inference. The handler pads undersized batches to the plugin's configured batch size before predicting, so VRAM consumption tracks the configured batch size; when it exceeds available GPU memory this user-facing OOM_MESSAGE is raised with remediation steps.
Source
Thrown at lib/infer/handler.py:180
The prediction from the model
Raises
------
FaceswapError
If an OOM occurs
"""
feed_size = feed.shape[0]
is_padded = self.do_compile and feed_size < self.plugin.batch_size
batch_feed = feed
if is_padded: # Prevent model re-compile on undersized batch
batch_feed = np.empty((self.plugin.batch_size, *feed.shape[1:]), dtype=feed.dtype)
logger.debug("[%s.process] Padding undersized batch of shape %s to %s",
self.plugin.name, feed.shape, batch_feed.shape)
batch_feed[:feed_size] = feed
try:
retval = self.plugin.process(batch_feed)
except OutOfMemoryError as err:
raise FaceswapError(OOM_MESSAGE) from err
if is_padded and retval.dtype == "object":
out = np.empty(retval.shape, dtype="object")
out[:] = [x[:feed_size] for x in retval]
retval = out
elif is_padded:
retval = retval[:feed_size]
return retval
def _format_images(self, images: npt.NDArray[np.uint8]) -> np.ndarray:
"""Format the incoming UINT8 0-255 images to the format specified by the plugin
Parameters
----------
images
The batch of UINT8 images to format
Returns
-------View on GitHub (pinned to f530cb7508)
Solutions
- Lower the batch size in plugin settings (GUI: Settings > Configure extract settings; CLI: edit faceswap/config/extract.ini).
- Close other GPU consumers (browsers, other ML jobs) and retry — transient when near capacity.
- Switch to lighter-weight or fewer plugins.
- If persistent, use a smaller model or a GPU with more VRAM.
Example fix
# faceswap/config/extract.ini # before detect.batch_size = 64 # after detect.batch_size = 8
Defensive patterns
Strategy: fallback
Validate before calling
# Before a long run, verify free VRAM vs batch size heuristic
import subprocess
free_mib = int(subprocess.run(
['nvidia-smi', '--query-gpu=memory.free', '--format=csv,noheader,nounits'],
capture_output=True, text=True).stdout.split()[0])
batches_per_gpu = max(1, min(configured_batch, free_mib // 150)) # ~150MB/batch-item heuristic Try / catch
try:
detect(batch=batch_size)
except FaceswapError as err:
if 'GPU memory' in str(err):
batch_size //= 2
detect(batch=batch_size)
else:
raise Prevention
- Start with batch_size 4-8 and increase after observing VRAM headroom.
- Close browsers and other GPU apps before extraction/training.
- Monitor with nvidia-smi during the first minutes of a run.
When it happens
Trigger: Running detect/extract plugins with a batch size too large for the GPU; another process (browser, another training job) occupying VRAM; VRAM fragmentation when close to capacity.
Common situations: New users defaulting to high batch sizes on small GPUs (2-4GB); running extraction while a model trains; driver/browser compositing eating several hundred MB.
Related errors
- You do not have enough GPU memory available to train the sel
- Hex color codes should start with a '#' and be 6 characters
- An unhandled exception occurred initializing the device via
- There was an error reading from the Nvidia Machine Learning
AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15).
Data as JSON: /api/errors/1d5ac0244b9e0de3.
Report an issue: GitHub.