Is ComfyUI no longer compatible with Google Colab?
As of roughly 12 hours ago, something has broke on Google Cloud GPU site colab for Comfy. Even from a brand-new, fresh installation, I cannot get any custom nodes to import and I receive incompatibility errors, including a Pytorch CUDA error.
Logs below.
From Installation cell:
Mounting Google Drive... / Mounted at /content/drive /content/drive/MyDrive -= Initial setup ComfyUI =- Cloning into 'ComfyUI'... remote: Enumerating objects: 8871, done. remote: Counting objects: 100% (157/157), done. remote: Compressing objects: 100% (94/94), done. remote: Total 8871 (delta 78), reused 111 (delta 62), pack-reused 8714 Receiving objects: 100% (8871/8871), 3.60 MiB | 7.29 MiB/s, done. Resolving deltas: 100% (5938/5938), done. Updating files: 100% (253/253), done. /content/drive/MyDrive/ComfyUI -= Updating ComfyUI =- Already up to date. -= Install dependencies =- Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu121, https://download.pytorch.org/whl/cu118, https://download.pytorch.org/whl/cu117 Collecting xformers!=0.0.18 Downloading https://download.pytorch.org/whl/cu118/xformers-0.0.23%2Bcu118-cp310-cp310-manylinux2014_x86_64.whl (212.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 212.9/212.9 MB 6.1 MB/s eta 0:00:00 Requirement already satisfied: torch in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 1)) (2.1.0+cu118) Collecting torchsde (from -r requirements.txt (line 2)) Downloading torchsde-0.2.6-py3-none-any.whl (61 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 kB 2.2 MB/s eta 0:00:00 Collecting einops (from -r requirements.txt (line 3)) Downloading einops-0.7.0-py3-none-any.whl (44 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 44.6/44.6 kB 4.4 MB/s eta 0:00:00 Requirement already satisfied: transformers>=4.25.1 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 4)) (4.35.2) Requirement already satisfied: safetensors>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 5)) (0.4.1) Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 6)) (3.9.1) Collecting accelerate (from -r requirements.txt (line 7)) Downloading accelerate-0.25.0-py3-none-any.whl (265 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 265.7/265.7 kB 8.5 MB/s eta 0:00:00 Requirement already satisfied: pyyaml in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 8)) (6.0.1) Requirement already satisfied: Pillow in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 9)) (9.4.0) Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 10)) (1.11.4) Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 11)) (4.66.1) Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 12)) (5.9.5) Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from xformers!=0.0.18) (1.23.5) Collecting torch (from -r requirements.txt (line 1)) Downloading https://download.pytorch.org/whl/cu121/torch-2.1.1%2Bcu121-cp310-cp310-linux_x86_64.whl (2200.7 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.2/2.2 GB 536.6 kB/s eta 0:00:00 Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch->-r requirements.txt (line 1)) (3.13.1) Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from torch->-r requirements.txt (line 1)) (4.5.0) Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch->-r requirements.txt (line 1)) (1.12) Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch->-r requirements.txt (line 1)) (3.2.1) Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch->-r requirements.txt (line 1)) (3.1.2) Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from torch->-r requirements.txt (line 1)) (2023.6.0) Requirement already satisfied: triton==2.1.0 in /usr/local/lib/python3.10/dist-packages (from torch->-r requirements.txt (line 1)) (2.1.0) Collecting trampoline>=0.1.2 (from torchsde->-r requirements.txt (line 2)) Downloading trampoline-0.1.2-py3-none-any.whl (5.2 kB) Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /usr/local/lib/python3.10/dist-packages (from transformers>=4.25.1->-r requirements.txt (line 4)) (0.19.4) Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from transformers>=4.25.1->-r requirements.txt (line 4)) (23.2) Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers>=4.25.1->-r requirements.txt (line 4)) (2023.6.3) Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from transformers>=4.25.1->-r requirements.txt (line 4)) (2.31.0) Requirement already satisfied: tokenizers<0.19,>=0.14 in /usr/local/lib/python3.10/dist-packages (from transformers>=4.25.1->-r requirements.txt (line 4)) (0.15.0) Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->-r requirements.txt (line 6)) (23.1.0) Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->-r requirements.txt (line 6)) (6.0.4) Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->-r requirements.txt (line 6)) (1.9.3) Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->-r requirements.txt (line 6)) (1.4.0) Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->-r requirements.txt (line 6)) (1.3.1) Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->-r requirements.txt (line 6)) (4.0.3) Requirement already satisfied: idna>=2.0 in /usr/local/lib/python3.10/dist-packages (from yarl<2.0,>=1.0->aiohttp->-r requirements.txt (line 6)) (3.6) Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch->-r requirements.txt (line 1)) (2.1.3) Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->transformers>=4.25.1->-r requirements.txt (line 4)) (3.3.2) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->transformers>=4.25.1->-r requirements.txt (line 4)) (2.0.7) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->transformers>=4.25.1->-r requirements.txt (line 4)) (2023.11.17) Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch->-r requirements.txt (line 1)) (1.3.0) Installing collected packages: trampoline, einops, torch, xformers, torchsde, accelerate Attempting uninstall: torch Found existing installation: torch 2.1.0+cu118 Uninstalling torch-2.1.0+cu118: Successfully uninstalled torch-2.1.0+cu118 ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. torchaudio 2.1.0+cu118 requires torch==2.1.0, but you have torch 2.1.1+cu121 which is incompatible. torchdata 0.7.0 requires torch==2.1.0, but you have torch 2.1.1+cu121 which is incompatible. torchtext 0.16.0 requires torch==2.1.0, but you have torch 2.1.1+cu121 which is incompatible. torchvision 0.16.0+cu118 requires torch==2.1.0, but you have torch 2.1.1+cu121 which is incompatible. Successfully installed accelerate-0.25.0 einops-0.7.0 torch-2.1.1+cu121 torchsde-0.2.6 trampoline-0.1.2 xformers-0.0.23+cu118
From Run Comfy with Cloudflare cell:
--2023-12-07 00:56:24-- https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb Resolving github.com (github.com)... 140.82.112.4 Connecting to github.com (github.com)|140.82.112.4|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://github.com/cloudflare/cloudflared/releases/download/2023.10.0/cloudflared-linux-amd64.deb [following] --2023-12-07 00:56:24-- https://github.com/cloudflare/cloudflared/releases/download/2023.10.0/cloudflared-linux-amd64.deb Reusing existing connection to github.com:443. HTTP request sent, awaiting response... 302 Found Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/106867604/3908a9b9-b0ed-4e7f-9ab0-25185ca66e06?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20231207%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231207T005611Z&X-Amz-Expires=300&X-Amz-Signature=b04cdce7a8cc6a310eda2971c75c0b90ea075a5d54ec87b7452cb310a9df4161&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=106867604&response-content-disposition=attachment%3B%20filename%3Dcloudflared-linux-amd64.deb&response-content-type=application%2Foctet-stream [following] --2023-12-07 00:56:24-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/106867604/3908a9b9-b0ed-4e7f-9ab0-25185ca66e06?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20231207%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231207T005611Z&X-Amz-Expires=300&X-Amz-Signature=b04cdce7a8cc6a310eda2971c75c0b90ea075a5d54ec87b7452cb310a9df4161&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=106867604&response-content-disposition=attachment%3B%20filename%3Dcloudflared-linux-amd64.deb&response-content-type=application%2Foctet-stream Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ... Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 17717280 (17M) [application/octet-stream] Saving to: ‘cloudflared-linux-amd64.deb’
cloudflared-linux-a 100%[===================>] 16.90M 54.3MB/s in 0.3s
2023-12-07 00:56:25 (54.3 MB/s) - ‘cloudflared-linux-amd64.deb’ saved [17717280/17717280]
Selecting previously unselected package cloudflared. (Reading database ... 120899 files and directories currently installed.) Preparing to unpack cloudflared-linux-amd64.deb ... Unpacking cloudflared (2023.10.0) ... Setting up cloudflared (2023.10.0) ... Processing triggers for man-db (2.10.2-1) ... Total VRAM 15102 MB, total RAM 12979 MB xformers version: 0.0.23+cu118 Set vram state to: NORMAL_VRAM Device: cuda:0 Tesla T4 : cudaMallocAsync VAE dtype: torch.float32 Using xformers cross attention Traceback (most recent call last): File "/content/drive/MyDrive/ComfyUI/nodes.py", line 1800, in load_custom_node module_spec.loader.exec_module(module) File "
", line 883, in exec_module File " ", line 241, in _call_with_frames_removed File "/content/drive/MyDrive/ComfyUI/comfy_extras/nodes_upscale_model.py", line 2, in from comfy_extras.chainner_models import model_loading File "/content/drive/MyDrive/ComfyUI/comfy_extras/chainner_models/model_loading.py", line 8, in from .architecture.LaMa import LaMa File "/content/drive/MyDrive/ComfyUI/comfy_extras/chainner_models/architecture/LaMa.py", line 15, in from torchvision.transforms.functional import InterpolationMode, rotate File "/usr/local/lib/python3.10/dist-packages/torchvision/init.py", line 6, in from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils File "/usr/local/lib/python3.10/dist-packages/torchvision/_meta_registrations.py", line 7, in import torchvision.extension # noqa: F401 File "/usr/local/lib/python3.10/dist-packages/torchvision/extension.py", line 92, in _check_cuda_version() File "/usr/local/lib/python3.10/dist-packages/torchvision/extension.py", line 78, in _check_cuda_version raise RuntimeError( **RuntimeError: Detected that PyTorch and torchvision were compiled with different CUDA major versions. PyTorch has CUDA Version=12.1 and torchvision has CUDA Version=11.8. Please reinstall the torchvision that matches your PyTorch install. Cannot import /content/drive/MyDrive/ComfyUI/comfy_extras/nodes_upscale_model.py module for custom nodes: Detected that PyTorch and torchvision were compiled with different CUDA major versions. PyTorch has CUDA Version=12.1 and torchvision has CUDA Version=11.8. Please reinstall the torchvision that matches your PyTorch install.**
ComfyUI finished loading, trying to launch cloudflared (if it gets stuck here cloudflared is having issues)
ComfyUI will still launch after this, but I am unable to install any custom nodes at all. I don't see any release notes from Google on Pytorch updates either.
Trying to make sense of this and understand why it is no longer working right.
Figured out the issue. It was the conflicting CUDA install. Since the requirements.txt file only calls out torch for dependency download, it was uninstalling torch 2.1.0+cu118 and replacing it with torch 2.1.1+cu121. Modifying the requirements.txt file to call out the specific torch and cuda version solved it.
This also resolves the issue of certain custom nodes not importing, including ComfyUI-Manager.
hello can you please help me i have the same problem. How and where should i put the torch in the requirements.txt
@wordbrew Hi, can you help with this question? I have the same problem.
@Uemuet @daredevilhanzo just put the following code directly into the colab under the first installation cell. Click the little "+" that appears when you hang your cursor in the middle to "add code". Then paste this into the code space:
!pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
That should hopefully install the correct torch version without having to mess with the git repo's downloaded files directly. Just run that cell after you've run the first cell in the colab.
Alternatively, you can modify the requirements.txt file directly, but that might cause problems down the line if comfy updates their requirements.txt file. That file is found in the base comfy directory. And you just have to replace the first line in that file. It currently just installs whatever latest version of torch is available by using the "torch" command. So you can just change the first line from "torch" to "torch==2.1.0+cu118". Replace the original requirements.txt file on your google drive with the modified one.
Thank you! This worked for me.
!pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Suddenly, after using Colab for months this new error appeared, and stopped many of my regular custom nodes from loading.
PyTorch has CUDA Version=12.1 and torchvision has CUDA Version=11.8
Your fix, fixed this. Here's a screen grab that shows
Uninstalling torch-2.1.0+cu118:
Successfully uninstalled torch-2.1.0+cu118
And your fix reversing that...
Uninstalling torch-2.1.1+cu121:
Successfully uninstalled torch-2.1.1+cu121
Successfully installed torch-2.1.0+cu118
ComfyUI needs to sort your Torch version issues. When installing dependencies, it is pulling all sorts of conflicting versions that are resulting in half of people's installed custom node stacks to fail to import.
It's still doing it
Change this line in your notebook:
!pip install xformers!=0.0.18 -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121 --extra-index-url https://download.pytorch.org/whl/cu118 --extra-index-url https://download.pytorch.org/whl/cu117
to this:
!pip install xformers!=0.0.18 -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121
Thank you, you solved the problem for me! Much appreciated. I'm still chasing bugs though as it refuses to import the comfy controlnet preprocessors. It just doesn't seem to be reading the requirements.txt file, so having to pip install everything.
I really need to get back to learning python.
You might want to look into ComfyUI-Manager or pip install -r like a chad.