Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: Torch not compiled with CUDA enabled #2427

Closed
lunatico67 opened this issue Jan 1, 2024 · 34 comments
Closed

AssertionError: Torch not compiled with CUDA enabled #2427

lunatico67 opened this issue Jan 1, 2024 · 34 comments

Comments

@lunatico67
Copy link

I just updated Comfyui and some custom nodes and cannot open Comfyui.

The last lines of the command :

File "C:\Users\Luna\Documents\ComfyUI_windows_portable\python_embeded\lib\site-packages\torch\cuda_init_.py", line 289, in _lazy_init
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

C:\Users\cebuk\Documents\ComfyUI_windows_portable>pause
Press any key to continue . . .

I press any key and the command window disappears.

@narukaze132
Copy link

It looks like you somehow ended up updating PyTorch automatically, which got you the default version. This version does not have CUDA support, meaning it has no GPU acceleration.

Assuming you have an Nvidia GPU, try running this command in that directory:

.\python_embeded\Scripts\pip install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118

This should install a CUDA-compatible version of PyTorch.

@lunatico67
Copy link
Author

Hi!
Thanks for the help narukazel.
Yes; I have a Nvidia GPU.
I must go to the Documents/ComfyUI_windows_portable/pythom_embeded folder and at the top of the window type cmd to open it in the command window and type: .\python_embeded install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118
?

@narukaze132
Copy link

Actually you need to run the pip program in the Scripts folder of that directory... though if the problem's solved I suppose it's not that important.

@sanmilano
Copy link

Thanks narukaze132! I had the same problem after updating ComfyUI and doing what you said solved the issue

@zboing
Copy link

zboing commented Jan 3, 2024

in my case worked only after running update_comfyui_and_python_dependencies.bat

@lunatico67
Copy link
Author

in my case worked only after running update_comfyui_and_python_dependencies.bat

Same for me

@moon47usaco
Copy link

in my case worked only after running update_comfyui_and_python_dependencies.bat

This worked for me as well... =]

@avviano
Copy link

avviano commented Mar 15, 2024

Worked for me!

@HydraBucket
Copy link

I am running comfyui through stability matrix. How would I fix this error?

@gonzalu
Copy link

gonzalu commented May 1, 2024

in my case worked only after running update_comfyui_and_python_dependencies.bat

This is the way... MANY THANKS!!!

@GrieverSY
Copy link

in my case worked only after running update_comfyui_and_python_dependencies.bat

Where is that bat file located? I can't find it in scripts.

@ghost
Copy link

ghost commented Jun 15, 2024

yes where are these update_comfyui_and_python_dependencies.bat hidden within ComfyUI_windows_portable ?

@ghost
Copy link

ghost commented Jun 15, 2024

yes where are these update_comfyui_and_python_dependencies.bat hidden within ComfyUI_windows_portable ?

ok I got it , they are within C:\ComfyUI_windows_portable\update

@raochinmay6
Copy link

hel me i try but nothing happen

ComfyUI-Manager: installing dependencies done.

[2024-06-30 23:35] ** ComfyUI startup time: 2024-06-30 23:35:54.490675
[2024-06-30 23:35] ** Platform: Windows
[2024-06-30 23:35] ** Python version: 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]
[2024-06-30 23:35] ** Python executable: E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\python_embeded\python.exe
[2024-06-30 23:35] ** ComfyUI Path: E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\main.py
[2024-06-30 23:35] ** Log path: E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\comfyui.log
[2024-06-30 23:35]
Prestartup times for custom nodes:
[2024-06-30 23:35] 0.0 seconds: E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\rgthree-comfy
[2024-06-30 23:35] 0.6 seconds: E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Manager
[2024-06-30 23:35]
Traceback (most recent call last):
[2024-06-30 23:35] File "E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\main.py", line 76, in
[2024-06-30 23:35] import execution
[2024-06-30 23:35] File "E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 11, in
[2024-06-30 23:35] import nodes
[2024-06-30 23:35] File "E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\nodes.py", line 21, in
[2024-06-30 23:35] import comfy.diffusers_load
[2024-06-30 23:35] File "E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\diffusers_load.py", line 3, in
[2024-06-30 23:35] import comfy.sd
[2024-06-30 23:35] File "E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\sd.py", line 5, in
[2024-06-30 23:35] from comfy import model_management
[2024-06-30 23:35] File "E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 119, in
[2024-06-30 23:35] total_vram = get_total_memory(get_torch_device()) / (1024 * 1024)
[2024-06-30 23:35] ^^^^^^^^^^^^^^^^^^
[2024-06-30 23:35] File "E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 88, in get_torch_device
[2024-06-30 23:35] return torch.device(torch.cuda.current_device())
[2024-06-30 23:35] ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2024-06-30 23:35] File "E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\cuda_init_.py", line 778, in current_device
[2024-06-30 23:35] lazy_init()
[2024-06-30 23:35] File "E:\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\cuda_init
.py", line 284, in _lazy_init
[2024-06-30 23:35] raise AssertionError("Torch not compiled with CUDA enabled")
[2024-06-30 23:35] AssertionError: Torch not compiled with CUDA enabled

@nothingness6
Copy link

in my case worked only after running update_comfyui_and_python_dependencies.bat

Great! It works for me when I tried it twice. It failed first time, but worked second time.
Thx!

@mcmonkey4eva
Copy link
Contributor

when running through matrix, you'll have to ask the matrix team how to deal with that, as they did not use the comfy standard install they did their own thing

@farizy4n
Copy link

farizy4n commented Aug 2, 2024

For proble worng path python like me,
**Fatal error in launcher: Unable to create process using '"D:\a\ComfyUI\python_embeded\python.exe" **
Cos idk how to remove path "D:\a.."
Please try

.\python_embeded\python.exe -s -m pip install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118

@rachelcenter
Copy link

Hi! Thanks for the help narukazel. Yes; I have a Nvidia GPU. I must go to the Documents/ComfyUI_windows_portable/pythom_embeded folder and at the top of the window type cmd to open it in the command window and type: .\python_embeded install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118 ?

D:\ComfyUI_windows_portable\python_embeded\Scripts>.\python_embeded install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118
'.\python_embeded' is not recognized as an internal or external command,
operable program or batch file.

@rachelcenter
Copy link

Actually you need to run the pip program in the Scripts folder of that directory... though if the problem's solved I suppose it's not that important.

how do i run the pip program there? I tried this:

D:\ComfyUI_windows_portable\python_embeded\Scripts>.\python_embeded install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118

RESULT:
'.\python_embeded' is not recognized as an internal or external command,
operable program or batch file.

@ltdrdata
Copy link
Collaborator

ltdrdata commented Aug 26, 2024

Actually you need to run the pip program in the Scripts folder of that directory... though if the problem's solved I suppose it's not that important.

how do i run the pip program there? I tried this:

D:\ComfyUI_windows_portable\python_embeded\Scripts>.\python_embeded install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118

RESULT: '.\python_embeded' is not recognized as an internal or external command, operable program or batch file.

You have to execute that command in D:\ComfyUI_windows_portable>

@rachelcenter
Copy link

Actually you need to run the pip program in the Scripts folder of that directory... though if the problem's solved I suppose it's not that important.

how do i run the pip program there? I tried this:
D:\ComfyUI_windows_portable\python_embeded\Scripts>.\python_embeded install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118
RESULT: '.\python_embeded' is not recognized as an internal or external command, operable program or batch file.

You have to execute that command in D:\ComfyUI_windows_portable>

D:\ComfyUI_windows_portable>.\python_embeded install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118
'.\python_embeded' is not recognized as an internal or external command,
operable program or batch file.

D:\ComfyUI_windows_portable>

@rachelcenter
Copy link

wait nvm i went to root of windows portable and pasted the following in and now its doing something: .\python_embeded\python.exe -s -m pip install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118

@ltdrdata
Copy link
Collaborator

ltdrdata commented Aug 26, 2024

Actually you need to run the pip program in the Scripts folder of that directory... though if the problem's solved I suppose it's not that important.

how do i run the pip program there? I tried this:
D:\ComfyUI_windows_portable\python_embeded\Scripts>.\python_embeded install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118
RESULT: '.\python_embeded' is not recognized as an internal or external command, operable program or batch file.

You have to execute that command in D:\ComfyUI_windows_portable>

D:\ComfyUI_windows_portable>.\python_embeded install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118 '.\python_embeded' is not recognized as an internal or external command, operable program or batch file.

D:\ComfyUI_windows_portable>

.\python_embeded\python.exe -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

Changing only the torch version causes compatibility issues with other packages, leading to problems.

Always get the commands from this site:
https://pytorch.org/

@rachelcenter
Copy link

rachelcenter commented Aug 26, 2024

now its stuck on: Installing collected packages: mpmath, typing-extensions, sympy, networkx, MarkupSafe, fsspec, filelock, jinja2, torch
Attempting uninstall: mpmath
Found existing installation: mpmath 1.3.0
Uninstalling mpmath-1.3.0:

and hasnt progressed past that. so while i wait i tried to double click the run_nvidia_gpu file and it all it says is:

D:\ComfyUI_windows_portable>.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build
[START] Security scan
WARNING: Ignoring invalid distribution ~pmath (D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages)
[DONE] Security scan

@rachelcenter
Copy link

D:\ComfyUI_windows_portable> .\python_embeded\python.exe -s -m pip install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118
WARNING: Ignoring invalid distribution ~pmath (D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages)
Looking in indexes: https://download.pytorch.org/whl/cu118
Collecting torch
Using cached https://download.pytorch.org/whl/cu118/torch-2.4.0%2Bcu118-cp311-cp311-win_amd64.whl (2692.5 MB)
Collecting filelock (from torch)
Using cached https://download.pytorch.org/whl/filelock-3.13.1-py3-none-any.whl (11 kB)
Collecting typing-extensions>=4.8.0 (from torch)
Using cached https://download.pytorch.org/whl/typing_extensions-4.9.0-py3-none-any.whl (32 kB)
Collecting sympy (from torch)
Using cached https://download.pytorch.org/whl/sympy-1.12-py3-none-any.whl (5.7 MB)
Collecting networkx (from torch)
Using cached https://download.pytorch.org/whl/networkx-3.2.1-py3-none-any.whl (1.6 MB)
Collecting jinja2 (from torch)
Using cached https://download.pytorch.org/whl/Jinja2-3.1.3-py3-none-any.whl (133 kB)
Collecting fsspec (from torch)
Using cached https://download.pytorch.org/whl/fsspec-2024.2.0-py3-none-any.whl (170 kB)
Collecting MarkupSafe>=2.0 (from jinja2->torch)
Using cached https://download.pytorch.org/whl/MarkupSafe-2.1.5-cp311-cp311-win_amd64.whl (17 kB)
Collecting mpmath>=0.19 (from sympy->torch)
Using cached https://download.pytorch.org/whl/mpmath-1.3.0-py3-none-any.whl (536 kB)
WARNING: Ignoring invalid distribution ~pmath (D:\ComfyUI_windows_portable\python_embeded\Lib\site-packages)
Installing collected packages: mpmath, typing-extensions, sympy, networkx, MarkupSafe, fsspec, filelock, jinja2, torch
Attempting uninstall: mpmath
Found existing installation: mpmath 1.3.0
Uninstalling mpmath-1.3.0:

@Agiltech-com-au
Copy link

Agiltech-com-au commented Sep 2, 2024

Actually you need to run the pip program in the Scripts folder of that directory... though if the problem's solved I suppose it's not that important.

Thanks. I don't know why i didn't see it earlier that it was just going to the folder first and would work for me even in the root folder of comyfui.

moving to CMD to ComfyUI_windows_portable\python_embeded\Scripts folder and just running: pip install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118
Works perfectly.

@serget2
Copy link

serget2 commented Nov 17, 2024

pip install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118

Did not work because it could not find cu118

@LukeG89
Copy link

LukeG89 commented Nov 17, 2024

@serget2 Why installing cu118 instead of cu124?

https://github.com/comfyanonymous/ComfyUI?tab=readme-ov-file#nvidia

@serget2
Copy link

serget2 commented Nov 17, 2024

That is what agitechs command said

@LukeG89
Copy link

LukeG89 commented Nov 17, 2024

@serget2 The cuda version is outdated, use this command instead:

pip install --force-reinstall torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu124

@serget2
Copy link

serget2 commented Nov 18, 2024

afbeelding

@serget2
Copy link

serget2 commented Nov 18, 2024

Got it for the portable version you need to put python.exe -m pip in front of your command, now it works

@blissiraDC
Copy link

It looks like you somehow ended up updating PyTorch automatically, which got you the default version. This version does not have CUDA support, meaning it has no GPU acceleration.

Assuming you have an Nvidia GPU, try running this command in that directory:

.\python_embeded\Scripts\pip install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118

This should install a CUDA-compatible version of PyTorch.

Absolute legend! Thanks!

@slopcop
Copy link

slopcop commented Feb 22, 2025

For Windows portable, go to the python_embeded (the spelling kills me every time) directory using command prompt, powershell or battletoads64. I use Win + R, then type CMD and I right click that ugly old icon and choose Run As Administrator to make sure it knows I mean business. I was kidding before about the battletoads.

For example, my directory is z:\com\com\python_embeded\ and I only want to mess with Torch for ComfyUI instead of screwing over my A1111, FaceFusion, etc etc.

Instead of using conda activate, I have to specifically use this python.exe file IN this folder, otherwise ComfyUI likely aint got time for dat.

  • (ɪ ʀᴇɴᴀᴍᴇᴅ ᴛʜᴇ ꜰɪʀꜱᴛ ᴄᴏᴍꜰʏ ꜰᴏʟᴅᴇʀꜱ ᴛᴡᴏ 'ᴄᴏᴍ' ʙᴇᴄᴀᴜꜱᴇ ᴛʜᴇ ᴘᴏʀᴛᴀʙʟᴇ ᴠᴇʀꜱɪᴏɴ'ꜱ ꜰᴏʟᴅᴇʀ ɴᴀᴍᴇ ɪꜱ ʟᴏɴɢᴇʀ ᴛʜᴀɴ ᴘᴀᴜʟ ʙᴜɴʏᴜɴ'ꜱ ᴍᴏꜱᴛ ʀᴇᴄᴇɴᴛ ɴᴜᴍʙᴇʀ ᴛᴡᴏ, ᴡʜɪᴄʜ ᴘʀᴏʙᴀʙʟʏ ɴᴇᴇᴅꜱ ᴀ ɢᴇᴇ, ᴘ.ᴜ! ꜰʟᴜꜱʜ.)

Magic Portable Version words to type in the Command Prompt in \python_embeded\

- For Cuda 11.8
python.exe -m pip install --force-reinstall torch --index-url https://download.pytorch.org/whl/cu118

- For Cuda 12.4 (arguably cuter)
python.exe -m pip install --force-reinstall torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121
I'm only including this because it was posted above, and shows how to adapt to your cuteness level. My cuteness level is 11.8, so you may be cuda

While your computer pips itself super hard, go outside and enjoy the marvelous sun.

What a beauty she is, right?

Careful not to burn those retinas!

  • I think it's time to test ComfyUI again. Should work.
  • 11.8 worked for me, and I'm actually using ComfyUI_windows_portable_nvidia_cu121_or_cpu , so who the gguf knows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests