How to properly install ComfyUI / Stable Diffusion UI / Automatic1111 (including dependencies and requirements)
Certain ComfyUI or Automatic1111 extensions require different version of CUDA than the latest. You probably have 12.x installed, since it is the latest available. Unfortunately, the backwards compatibility is poor.
We'll be installing PyTorch for CUDA 11.8, independently, and we can change PyTorch versions without installing the full CUDA toolkit.
- Latest NVidia GPU Drivers installed
- Python 3.10.11 (at the time of writing this, the best version) - Optional, we can do this later
If Python is installed and on the system path:
python -c "import torch; print(torch.version); print(torch.version.cuda)"
you might see something like:
2.1.1+cu121 12.1
-
Install Python (you can download it from the official website)
-
Open PowerShell and navigate to your project directory
cd path\to\ComfyUI
-
Create a Virtual Environment:
python -m venv myenv
You can replace myenv with any name you want for your virtual environment.
-
Activate the Environment: Within the same directory, run the following command
.\myenv\Scripts\activate
Your command prompt should now indicate that you're in the virtual environment.
We can now install PyTorch built for the specific CUDA version we need to support our ComfyUI requirements. Run the following commands in the same Powershell window/directory:
.\myenv\Scripts\activate
-
Uninstall Current PyTorch Version: (skip this if first time setting up virtual environment)
pip uninstall torch torchvision torchaudio
-
Install PyTorch for CUDA 11.8:
pip install torch==2.1.1+cu118 torchvision==0.16.1+cu118 torchaudio==2.1.1+cu118 -f https://download.pytorch.org/whl/torch_stable.html
-
Verify PyTorch Installation:
python -c "import torch; print(torch.version); print(torch.version.cuda)"
If everything worked correctly, you should see the following print in the terminal window:
> 2.1.1+cu118
> 11.8
Finally, now that we have the right environment & dependencies, we can install onnxruntime-gpu:
> pip install onnxruntime-gpu
(or if you've installed the portable version ComfyUI)
> python_embeded\python.exe -m pip install onnxruntime-gpu
...and to verify everything is working correctly, run ComfyUI and observe the following terminal output:
> DWPose: Onnxruntime with acceleration providers detected
(Congratulations if you followed along and made it this far 🎉)
.\myenv\Scripts\activate python -m pip install --upgrade pip python -m pip -r requirements.txt
Supir requires Python 3.8, at the time of publishing this, but there are workarounds I figured out to install with Python 3.10.11:
- Clone repo
git clone https://github.com/Fanghua-Yu/SUPIR.git cd SUPIR Install dependent packages
- Modify requirements.txt
a. Comment or remove the following lines
"# fsspec==2023.4.0"
"# triton==2.1.0"
b. Edit the following line to: "fastapi==0.111.0"
- Create the virtual environment and install requirements
python -m venv myenv .\myenv\Scripts\activate python -m pip install --upgrade pip pip install -r requirements.txt pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 pip install onnxruntime-gpu