{"record":{"id":"ad10d6d9a9faa98c","repo":"AUTOMATIC1111/stable-diffusion-webui","slug":"torch-is-not-able-to-use-gpu-add-skip-torch-cud","errorCode":null,"errorMessage":"Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check","messagePattern":"Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"modules/launch_utils.py","lineNumber":387,"sourceCode":"\r\n    startup_timer.record(\"checks\")\r\n\r\n    commit = commit_hash()\r\n    tag = git_tag()\r\n    startup_timer.record(\"git version info\")\r\n\r\n    print(f\"Python {sys.version}\")\r\n    print(f\"Version: {tag}\")\r\n    print(f\"Commit hash: {commit}\")\r\n\r\n    if args.reinstall_torch or not is_installed(\"torch\") or not is_installed(\"torchvision\"):\r\n        run(f'\"{python}\" -m {torch_command}', \"Installing torch and torchvision\", \"Couldn't install torch\", live=True)\r\n        startup_timer.record(\"install torch\")\r\n\r\n    if args.use_ipex:\r\n        args.skip_torch_cuda_test = True\r\n    if not args.skip_torch_cuda_test and not check_run_python(\"import torch; assert torch.cuda.is_available()\"):\r\n        raise RuntimeError(\r\n            'Torch is not able to use GPU; '\r\n            'add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'\r\n        )\r\n    startup_timer.record(\"torch GPU test\")\r\n\r\n    if not is_installed(\"clip\"):\r\n        run_pip(f\"install {clip_package}\", \"clip\")\r\n        startup_timer.record(\"install clip\")\r\n\r\n    if not is_installed(\"open_clip\"):\r\n        run_pip(f\"install {openclip_package}\", \"open_clip\")\r\n        startup_timer.record(\"install open_clip\")\r\n\r\n    if (not is_installed(\"xformers\") or args.reinstall_xformers) and args.xformers:\r\n        run_pip(f\"install -U -I --no-deps {xformers_package}\", \"xformers\")\r\n        startup_timer.record(\"install xformers\")\r\n\r\n    if not is_installed(\"ngrok\") and args.ngrok:\r","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/modules/launch_utils.py#L369-L405","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["If you truly want CPU-only: add --skip-torch-cuda-test (and typically --precision full --no-half --use-cpu all) to COMMANDLINE_ARGS.","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.","Run nvidia-smi to confirm the driver sees the GPU and its CUDA version; update drivers if needed.","In Docker/WSL ensure GPU passthrough (nvidia-container-toolkit / WSL2 GPU support) is configured."],"exampleFix":"# before (in webui-user.sh)\nexport COMMANDLINE_ARGS=\"\"\n\n# after (CPU-only)\nexport COMMANDLINE_ARGS=\"--skip-torch-cuda-test --precision full --no-half --use-cpu all\"","handlingStrategy":"validation","validationCode":"import torch\n\ncuda_ok = torch.cuda.is_available()\nif not cuda_ok:\n    # decide before launch: either fix driver/torch build or pass --skip-torch-cuda-test\n    print('CUDA unavailable; add --skip-torch-cuda-test for CPU-only mode')","typeGuard":null,"tryCatchPattern":"try:\n    prepare_environment()\nexcept RuntimeError as e:\n    if 'skip-torch-cuda-test' in str(e):\n        print('GPU unusable; rerun with --skip-torch-cuda-test for CPU-only or install CUDA torch')\n        sys.exit(1)\n    raise","preventionTips":["Run nvidia-smi before first launch to confirm driver + CUDA version.","Set TORCH_COMMAND to the wheel matching your driver (e.g. cu121 index URL).","For CPU-only deployments, always include --skip-torch-cuda-test plus --no-half flags."],"tags":["startup","cuda","gpu","torch","environment"],"backgroundTag":null,"analyzedSha":"82a973c04367123ae98bd9abdf80d9eda9b910e2","analyzedAt":"2026-08-14T16:46:43.225Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}