当前位置:AIGC资讯 > AIGC > 正文

解决在Windows安装stable diffusion遇到“Torch is not able to use GPU”的问题

解决在Windows安装stable diffusion遇到“Torch is not able to use GPU”的问题

遇到的问题 解决方法 参考链接

遇到的问题

在Windows上安装stable diffusion的最后一步执行webui-user.bat时,提示了错误信息AssertionError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

具体错误代码如下:

venv "C:\Users\giray\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 67d011b
Traceback (most recent call last):
File "C:\Users\giray\stable-diffusion-webui\launch.py", line 110, in
run_python("import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'")
File "C:\Users\giray\stable-diffusion-webui\launch.py", line 60, in run_python
return run(f'"{python}" -c "{code}"', desc, errdesc)
File "C:\Users\giray\stable-diffusion-webui\launch.py", line 54, in run
raise RuntimeError(message)
RuntimeError: Error running command.
Command: "C:\Users\giray\stable-diffusion-webui\venv\Scripts\python.exe" -c "import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'"
Error code: 1
stdout:
stderr: Traceback (most recent call last):
File "", line 1, in
AssertionError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

解决方法

参考了github上的issue,需要修改webui-user.bat文件,具体更改如下:

COMMANDLINE_ARGS=
and change it to:
COMMANDLINE_ARGS= --lowvram --precision full --no-half --skip-torch-cuda-test

保存修改之后再次运行webui-user.bat就可以了。如果这个解决方法还没解决问题,可以查看同个issue下的其它回答,或者能找到解决方法。

参考链接

Torch is not able to use GPU How to install Stable Diffusion on Windows (AUTOMATIC1111)

更新时间 2023-11-09