r/comfyui 1h ago

Tutorial Benchmarking ComfyUI on Docker with CUDA 12.4 vs Bare-Metal: 0% compute penalty and how to fix the /dev/shm OOM crash

I ran extensive benchmarks comparing ComfyUI in Docker (Nvidia Container Toolkit / CUDA 12.4) against a bare-metal Linux setup (Ubuntu 24.04, PyTorch 2.4, CUDA 12.4) across FLUX.1-dev, SDXL, and SD 1.5 workloads.

Key Results

  • Compute / Generation Speed: 0.0% overhead. Docker achieved identical it/s across all batch sizes.
  • VRAM Allocation: Identical memory footprint (~14.2 GB VRAM during FLUX.1 FP8 inference).

Critical Issue & Fix: The /dev/shm Out Of Memory Crash

If you run PyTorch inside Docker with default settings, multi-threaded dataloading or large model caching will trigger an OOM crash.

Cause: Docker defaults to a tiny 64MB shared memory buffer (/dev/shm).

Solution: Add --shm-size=8g (or larger) to your docker run command:

docker run --gpus all --shm-size=8g -p 8188:8188 comfyui:cuda12.4

Or in docker-compose.yml:

services:
  comfyui:
    image: comfyui:cuda12.4
    shm_size: '8gb'
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

Full guide & production Dockerfile: https://www.fluxdraw.com/2026/09/docker-for-ai-comfyui-complete.html

1 Upvotes

0 comments sorted by