Reinstall Torch for the Stable Diffusion Web UI
Step-by-Step Guide
Locate the startup file: Navigate to your main Stable Diffusion Web UI installation folder. Find the file named webui-user.bat (for Windows) or webui.sh (for Linux/macOS).
Edit the file: Open the file in a text editor (like Notepad or VS Code).
Add the command-line argument: Locate the line that starts with set COMMANDLINE_ARGS= (on Windows). Add --reinstall-torch to the arguments line.
Windows example (webui-user.bat):
batch
set COMMANDLINE_ARGS=--reinstall-torch
Linux/macOS example (webui.sh):
bash
# Locate the "COMMANDLINE_ARGS=" line and modify it
COMMANDLINE_ARGS="--reinstall-torch"
If you have other arguments already there, simply add a space and then --reinstall-torch.
Save the file and close the text editor.
Run the web UI: Double-click the webui-user.bat (or run ./webui.sh in your terminal) file to start the application.
Wait for the process to complete: The UI will start, and the console will show messages indicating that it is installing Torch and torchvision. This process will download large files and may take some time.
Remove the flag (important!): Once the installation is complete and the web UI has loaded successfully, close the application. Re-open the webui-user.bat file in your text editor and remove the --reinstall-torch flag from the COMMANDLINE_ARGS line. If you do not remove it, it will reinstall Torch every time you launch the web UI.
Save the file again and restart your web UI as normal. The new Torch version should now be installed and active.
Note: This process installs the specific version of Torch that the web UI is tested to work with, which may not always be the absolute latest version available on the official PyTorch website.
