Saturday, December 30, 2023

AMD GPU SD directml:RuntimeError: Torch is not able to use GPU

If you have an AMD GPU and encounter the following error message after attempting to install Stable Diffusion WebUI using DirectML 1.7.0 by running Webui-user.bat for the first time, with the last line indicating:

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

Here is the solution, involving modifications in two places:

  1. Locate the "requirements_versions" file, open it, and add the following command at the end before saving:
torch-directml
  1. Open Webui-user.bat, find the line with set COMMANDLINE_ARGS, and add the following command before saving:
set COMMANDLINE_ARGS= --use-directml

Note: You might have come across previous web content mentioning the parameter --backend directml, but this parameter is no longer valid and will result in an error.

Finally, run Webui-user.bat again, and the installation should proceed smoothly with the necessary environment and files. If you've encountered issues previously, you can delete the XENV folder and reinstall, or perform a fresh installation by removing all existing files and starting anew.