[DOCS] WSL2 with AMD ROCm Guide
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 155
Description
Hi, I was showing my non-tech-industry friend your project and they were eager to try it out, they were very sad about the lack of pre-packaged AMD support on Windows and as they have no idea what `git clone` is I offered to guide them through the manual installation so they could use it with their graphics card, despite my lack of recent Windows experience (hadn't even touched Windows 11 until today).
The official manual installation guide suggests AMD is available for Windows, but there were problems with the recommended PyTorch libraries (which are actually the PyTorch nightly builds that aren't recommended by AMD). After some research, I found a solution using WSL officially with more stable ROCM libraries from AMD. I adapted the installation process for WSL and was able to get it working (I also adapted AMDs steps to use the latest versions I could find and included torchaudio as a requirement for ComfyUI).
I think this workaround would be helpful for others who encounter similar issues, especially those with no experience of GitHub or the technical side as it is very intimidating for folks not in the industry and not very forgiving or friendly for those who just want to use the tool to play around with diffusion and AMD.
I'd like to offer my updated process as a community contribution (even if it isn't officially endorsed). However, please feel free to refine it to make the solution more robust with venv or conda best practices as I definitely did some janky things with pip installations and the order of installation to make it work quickly on my friends PC (I am not a python guy, so can't promise any best practices, I just know enough python from my sysadmin days to be dangerous).
Please note these instructions were written on the 11th January 2025, so some of the compatibilities and versions could be out of date if you read this later, I included some supplemental advice on updating packages at the end:
### Stage 1: Setting Up WSL and Git:
>[!note]
>PreReq - Have a Github Acct
1. Install WSL in Powershell
```
wsl --install
```
2. Get Ubuntu 22.04 from Microsoft Store
3. Log into the 22.04 version
>[!note]
>Your username can be anything, your password will be typed even if it isn't visible so bear that in mind!
5. Create your SSH Key (you can hit enter on every option, this isn't best practice but it is doable)
```
ssh-keygen
```
6. Get your public key
```
cat .ssh/id_rsa.pub
```
> [!note]
> If id_rsa.pub doesn't exist it could instead be id_e25519.pub - you always want the .pub file which can be public basically, the other non-.pub should never be shared as it is private and needed for security!
7. On the Github webpage, navigate to your Account Settings, then GPG and SSH Keys, in there you can add a 'New SSH Key' give it a name and paste the output from Step 6 in it's entirety (not the command, just the output).
### Stage 2: Installing ROCm with AMD Radeon for WSL:
1. On your Windows machine check your drivers are compatible (as of writing AMD Adrenaline v24.12.1)
2. In WSL Ubuntu 22.04 - Get the amdgpu installer
```bash
sudo apt update
wget https://repo.radeon.com/amdgpu-install/6.2.3/ubuntu/jammy/amdgpu-install_6.2.60203-1_all.deb
sudo apt install ./amdgpu-install_6.2.60203-1_all.deb
```
3. Check the installer exists and lists use cases:
```bash
sudo amdgpu-install --list-usecase
```
4. Install amdgpu with the WSL and ROCm usecase:
```bash
amdgpu-install -y --usecase=wsl,rocm --no-dkms
```
5. Verify the Installation:
```bash
rocminfo
```
You should expect to see this in the output somewhere:
```bash
...
Marketing Name: [Your Graphics Card Model]
...
```
### Stage 3: Installing ComfyUI with AMD Official ROCm Dependencies
1. Clone the ComfyUI Repo from Github:
```bash
git clone git@github.com:comfyanonymous/ComfyUI.git
```
2. Upgrade PIP beyond 22.02 (Ubuntu 22.04 ships with this version and there is a bug that cancels out when you have too many python dependencies - and ComfyUI has a lot):
```bash
pip3 install --upgrade pip
```
3. Install the official Python Dependencies for ComfyUI (we will be changing some of these in the next step but if we do this first it means we should get everything we need and in the next steps we only need to change 3-4 others)
```bash
cd ComfyUI && pip3 install -r requirements.txt && cd ~
```
4. Download and then install the ROCm specific PyTorch libraries to replace the ComfyUI default ones (These versions are the latest as of writing (binaries available since 7th January 2025):
```bash
wget https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/torch-2.4.0%2Brocm6.3.1-cp310-cp310-linux_x86_64.whl
wget https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/torchvision-0.19.0%2Brocm6.3.1-cp310-cp310-linux_x86_64.whl
wget https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/pytorch_triton_rocm-3.0.0%2Brocm6.3.1.75cc27c26a-cp310-cp310-linux_x86_64.whl
wget https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/torchaudio-2.4.0%2Brocm6.3.1-cp310-cp310-linux_x86_64.whl
pip3 uninstall torch torchvision pytorch-triton-rocm torchaudio
pip3 install torch-2.4.0+rocm6.3.1-cp310-cp310-linux_x86_64.whl torchvision-0.19.0+rocm6.3.1-cp310-cp310-linux_x86_64.whl pytorch_triton_rocm-3.0.0+rocm6.3.1.75cc27c26a-cp310-cp310-linux_x86_64.whl torchaudio-2.4.0+rocm6.3.1-cp310-cp310-linux_x86_64.whl
```
5. Update the Torch library to be WSL compatible:
```bash
location=`pip show torch | grep Location | awk -F ": " '{print $2}'`
cd ${location}/torch/lib/
rm libhsa-runtime64.so*
cp /opt/rocm/lib/libhsa-runtime64.so.1.2 libhsa-runtime64.so
cd ~
```
6. Verify PyTorch is working and recognises your graphics card:
Test 1 - See if the torch dependency works:
```bash
python3 -c 'import torch' 2> /dev/null && echo 'Success' || echo 'Failure'
```
Expected Result:
```bash
Success
```
Test 2 - See if torch can access CUDA for Graphics Cards:
```bash
python3 -c 'import torch; print(torch.cuda.is_available())'
```
Expected Result
```bash
True
```
Test 3 - See if torch can see your graphics card
```bash
python3 -c "import torch; print(f'device name [0]:', torch.cuda.get_device_name(0))"
```
Expected Result:
```bash
device name [0]:
```
>[!note]
> You may see an error before printing the GPU, in my testing this error hasn't meant any actual issues with Comfy UI in practice.
Test 4 - Gather all of your env details:
```bash
python3 -m torch.utils.collect_env
```
Expected Result:
```bash
PyTorch version
ROCM used to build PyTorch
OS
Is CUDA available
GPU model and configuration
HIP runtime version
MIOpen runtime version
```
You should now have everything installed and setup!
### Stage 4: Starting ComfyUI (If you have done Stages 1-3 then just do this from now on)
1. Start the ComfyUI Application (finally!)
```bash
cd ComfyUI && python3 main.py
```
Once it is started it will prompt you that it is being served, probably from an address that looks like this:
```bash
http://127.0.0.1:8818
```
2. You can copy this whole url and paste it into your browser; Happy Diffusing!!
3. To stop it running when you are done you can use Ctrl+C on your WSL window which will stop the running service, just use step 1 of this stage to start it again!
### Post-Installation Notes
**Updating Torch:**
AMD Official Torch packages can be found [here](https://repo.radeon.com/rocm/manylinux/)
To update libraries the Torch installation commands you need to update the component versions, the rocm versions, and for the triton package the hash/string of characters in the middle all of which you can find above if you click in.
Always pick the cp310-cp310 packages for WSL, not sure why, but a community blog suggested these were the ones built for WSL.
**Updating Radeon Software in WSL:**
AMD recommends uninstalling the old one before installing the new one as there are no in-place upgrades currently - not sure how to discover new ones.
**Adding Models to ComfyUI:**
You can download models from [CivitAI](https://civitai.com) - once downloaded in your file explorer you can access your linux machine directly in the sidebar and navigate to ComfyUI -> Models to put them in from your Windows machine.
**Seeing Outputs:**
Similar to Models, Output images can be found going to the Linux section of your File Explorer, the ComfyUI folder and then 'Outputs'.
**Accessing from other devices remotely:**
ComfyUI by default is only available on the machine it gets installed on, but it is possible to use Tailscale, an excellent easy to setup private VPN, on both your devices and your ComfyUI machine to expose it. Tailscale's docs have examples of how to do this and install, you just need to type in your ComfyUI machine's IP address found in the Tailscale Admin Console instead of '127.0.0.1' from your other device's browser when they are connected.
**Making ComfyUI starting easier:**
If you want to have an easier time of starting the server after the initial setup:
```bash
cd ~
touch start_server
vim start_server
```
In VIM (a text editor for the command line) press 'a' to start editing the file and add:
```bash
cd ComfyUI && python3 main.py
```
After you are done press the escape key, and then type `:wq` and enter
You should be back in your prompt, to make your new file executable use:
```bash
chmod +x start_server
```
And from now on you can just use:
```bash
./start_server
```
### Sources:
[Comfy UI Manual Installation](https://docs.comfy.org/get_started/manual_install)
[AMD Radeon in WSL Guide](https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/wsl/install-radeon.html)
[AMD PyTorch in WSL installation](https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/wsl/install-pytorch.html)
[Slightly Outdated: AMD Community Blog on PyTorch WSL w/ Screenshots of Comfy UI](https://community.amd.com/t5/ai/how-to-run-amd-rocm-software-in-windows-11/ba-p/696336)
Contributor guide
Assessment
This issue has not been assessed yet.