comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
51.23k stars 5.39k forks source link

A few suggestions for updating repo instructions for new users (and xformers instructions for AI video projects) #3793

Open 311-code opened 3 months ago

311-code commented 3 months ago

I'll create a new pull request for the readme but just wanted to put this here in case anyone needs help.

My friend did not want to use the portable version of Comfyui. Because some extensions needing whl that didn't exist and requiring includes that aren't present in the portable package. He didn't want to mess with constantly changing windows path to python to match embedded comfyui when build a whl.

I was helping him with his new Windows gaming laptop and he kept getting this typical error which I knew how to fix: AssertionError: Torch not compiled with CUDA enabled

He said the repo instructions didn't help him. Don't ask me how he knows how to build a whl, but couldn't get past this..

I told him he needed to install cuda 12.1 from nvidia First. Then do the pip uninstall torch stuff, then run pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121 again, which would then download the correct whl because cuda toolkit 12.1 was now installed.

He mentioned he wanted to use Tooncrafter, So I told him it's best to use that with xformers for that, so it's 2.3.0 for xformers currently and this should work for him to install xformers and it did:

Edit: More context to get this going on Windows for non-portable without shortcuts:

python -m venv venv
cd venv
cd scripts
type 'activate' without the ' '
cd.. (press enter)
cd.. again (press enter)
pip install -r requirements.txt
python.exe -m pip install --upgrade pip
python main.py (to launch)

then follow the below when you get the error: (xformers part optional here)

pip uninstall torch

pip install torch==2.3.0+cu121 torchvision==0.18.0+cu121 torchaudio==2.3.0+cu121 --extra-index-url https://download.pytorch.org/whl/cu121

pip install xformers==0.0.26.post1 --no-deps

pip uninstall numpy
pip install numpy==1.26.4

And for portable version of xformers: python_embeded\python.exe -m pip install xformers --no-deps

Anyways, the only thing main page says for windows install is:

Troubleshooting

If you get the "Torch not compiled with CUDA enabled" error, uninstall torch with:

pip uninstall torch

And install it again with the command above.

So I would suggest this:

#### Troubleshooting

If you get the "Torch not compiled with CUDA enabled" error:

Install [Cuda Toolkit 12.1 for Windows, or current ComfyUI recommended version.](https://developer.nvidia.com/cuda-12-1-0-download-archive?target_os=Windows&target_arch=x86_64&target_version=11&target_type=exe_local)

```pip uninstall torch```

`pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121` again. (cu121 mean Cuda 12.1) It will download the correct WHL.

And for people that need xformers for AI video related things:

### Xformers

`xformers` is utilized to improve performance and memory efficiency for large models and long sequences. It is effective in projects requiring optimized spatiotemporal attention, such as:

Examples:
- *Tooncrafter*
- *Comfy-SVDTools Extension*

These example projects benefit from `xformers` through its efficient handling of attention mechanisms in extensive spatiotemporal data.

**Note:** ComfyUI does not include `xformers` by default. You will need to install it separately if you need this.

```pip uninstall torch```

```pip install torch==2.3.0+cu121 torchvision==0.18.0+cu121 torchaudio==2.3.0+cu121 --extra-index-url https://download.pytorch.org/whl/cu121```

```pip install xformers==0.0.26.post1 --no-deps```

```pip uninstall numpy```
```pip install numpy==1.26.4```

or for ComfyUI portable version ```python_embeded\python.exe -m pip install xformers --no-deps```

Also since Comfyui is very popular. I would also maybe suggest adding info on installing the Python Windows installer for new users, and for users that don't want to use portable, making sure tell them to ADD TO SYSTEM PATH CHECKED on the first screen, then doing python -m venv venv in ComfyUI folder after the git clone, or whatever, explaining this create a virtual environement. Typing activate in the scripts folder or the shortcut way to activate. pip install -r requirements.txt Installing Cuda Toolkit 12.1. etc. just to make the barrier to entry bit less for regular version.

The portable is good too though, but I also had some of those issues with certain extensions and trying to use cmake to build a whl and xformers did not work for me at all for portable. It gets complicated if the python embedded is different version than your windows environmental variables PATH of python when trying to build a whl for portable version.

Hope these suggestions help and make sense.

311-code commented 2 months ago

No problem!