ComfyUIの「Torch not compiled with CUDA enabled」の対処
ComfyUIで生成しようとすると、こう止まることがある。
AssertionError: Torch not compiled with CUDA enabledGPUで動かそうとしているのに、入っているのがCPU版のtorchだ、という意味だ。CUDA対応のtorchでないと、GPUは使えない。
まず入っているtorchを確認する
ComfyUIが使うPythonで確認する。
.\python_embeded\python.exe -c "import torch; print(torch.cuda.is_available(), torch.version.cuda)"False None のように出たら、それはCPU版だ。
CUDA対応のtorchに入れ直す
ComfyUIが使うPythonに、CUDA対応版を入れ直す。CUDAのバージョンは自分の環境に合わせて、pytorch.orgの指示に従う。
.\python_embeded\python.exe -m pip uninstall -y torch torchvision torchaudio.\python_embeded\python.exe -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121venv運用なら、activateしてから同じことをする。ポイントは、ComfyUIが実際に見ているPythonに入れること。別のPythonに入れても反映されない。
GPUが無い場合
そもそもCUDA対応GPUが無いなら、CPUモードで起動するしかない。遅いが動く。
.\python_embeded\python.exe -s ComfyUI\main.py --cpuまとめ
- 原因はCPU版のtorchが入っている
torch.cuda.is_available()がFalseなら入れ直し- ComfyUIが使うPythonに、CUDA対応torchを入れる
- 入れる先のPythonを取り違えない
- GPUが無ければ
--cpuで起動する