AUTOMATIC1111/stable-diffusion-webui · critical · RuntimeError

Torch is not able to use GPU; add --skip-torch-cuda-test to

Error message

Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

What it means

During startup the launcher runs check_run_python('import torch; assert torch.cuda.is_available()'); if it returns falsey (assert failed) and --skip-torch-cuda-test is not set (and not --use-ipex), this RuntimeError aborts launch. Its purpose is to fail fast when torch was installed without working CUDA support.

Source

Thrown at modules/launch_utils.py:387

    startup_timer.record("checks")

    commit = commit_hash()
    tag = git_tag()
    startup_timer.record("git version info")

    print(f"Python {sys.version}")
    print(f"Version: {tag}")
    print(f"Commit hash: {commit}")

    if args.reinstall_torch or not is_installed("torch") or not is_installed("torchvision"):
        run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
        startup_timer.record("install torch")

    if args.use_ipex:
        args.skip_torch_cuda_test = True
    if not args.skip_torch_cuda_test and not check_run_python("import torch; assert torch.cuda.is_available()"):
        raise RuntimeError(
            'Torch is not able to use GPU; '
            'add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'
        )
    startup_timer.record("torch GPU test")

    if not is_installed("clip"):
        run_pip(f"install {clip_package}", "clip")
        startup_timer.record("install clip")

    if not is_installed("open_clip"):
        run_pip(f"install {openclip_package}", "open_clip")
        startup_timer.record("install open_clip")

    if (not is_installed("xformers") or args.reinstall_xformers) and args.xformers:
        run_pip(f"install -U -I --no-deps {xformers_package}", "xformers")
        startup_timer.record("install xformers")

    if not is_installed("ngrok") and args.ngrok:

View on GitHub (pinned to 82a973c043)

Solutions

  1. If you truly want CPU-only: add --skip-torch-cuda-test (and typically --precision full --no-half --use-cpu all) to COMMANDLINE_ARGS.
  2. Otherwise install the CUDA-enabled torch build matching your driver: set the TORCH_COMMAND / webui launch args to the cu121 (or appropriate) wheel index and reinstall.
  3. Run nvidia-smi to confirm the driver sees the GPU and its CUDA version; update drivers if needed.
  4. In Docker/WSL ensure GPU passthrough (nvidia-container-toolkit / WSL2 GPU support) is configured.

Example fix

# before (in webui-user.sh)
export COMMANDLINE_ARGS=""

# after (CPU-only)
export COMMANDLINE_ARGS="--skip-torch-cuda-test --precision full --no-half --use-cpu all"
Defensive patterns

Strategy: validation

Validate before calling

import torch

cuda_ok = torch.cuda.is_available()
if not cuda_ok:
    # decide before launch: either fix driver/torch build or pass --skip-torch-cuda-test
    print('CUDA unavailable; add --skip-torch-cuda-test for CPU-only mode')

Try / catch

try:
    prepare_environment()
except RuntimeError as e:
    if 'skip-torch-cuda-test' in str(e):
        print('GPU unusable; rerun with --skip-torch-cuda-test for CPU-only or install CUDA torch')
        sys.exit(1)
    raise

Prevention

When it happens

Trigger: Launching webui.py without --skip-torch-cuda-test on a machine where torch.cuda.is_available() is False: CPU-only torch wheel, missing/broken NVIDIA driver, CUDA runtime mismatch, or running inside a container without GPU passthrough.

Common situations: Default torch_command installed the CPU build; NVIDIA driver not installed or too old for the wheel's CUDA version; WSL2 without the nvidia driver linked; cloud instance without GPU assigned; intentionally running CPU-only without knowing the flag.

Related errors


AI-assisted analysis of AUTOMATIC1111/stable-diffusion-webui@82a973c043 (2026-08-14). Data as JSON: /api/errors/ad10d6d9a9faa98c. Report an issue: GitHub.