Comfy-Org / comfy-cli

Command Line Interface for Managing ComfyUI
https://docs.comfy.org/comfy-cli/getting-started
GNU General Public License v3.0
235 stars 37 forks source link

ERRO : "A module that was compiled using NumPy 1.x cannot be run" #163

Open Lilien86 opened 1 month ago

Lilien86 commented 1 month ago

When launching ComfyUI, the following error occurs:

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "D:\Comfyui\cli\comfyui_cli\main.py", line 83, in <module>
  import comfy.utils
File "D:\Comfyui\cli\comfyui_cli\comfy\utils.py", line 20, in <module>
  import torch
File "D:\Comfyui\cli\comfy-env\Lib\site-packages\torch\__init__.py", line 2120, in <module>
  from torch._higher_order_ops import cond
File "D:\Comfyui\cli\comfy-env\Lib\site-packages\torch\_higher_order_ops\__init__.py", line 1, in <module>
  from .cond import cond
File "D:\Comfyui\cli\comfy-env\Lib\site-packages\torch\_higher_order_ops\cond.py", line 5, in <module>
  import torch._subclasses.functional_tensor
File "D:\Comfyui\cli\comfy-env\Lib\site-packages\torch\_subclasses\functional_tensor.py", line 42, in <module>
  class FunctionalTensor(torch.Tensor):
File "D:\Comfyui\cli\comfy-env\Lib\site-packages\torch\_subclasses\functional_tensor.py", line 258, in FunctionalTensor
  cpu = _conversion_method_template(device=torch.device("cpu"))
D:\Comfyui\cli\comfy-env\Lib\site-packages\torch\_subclasses\functional_tensor.py:258: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\utils\tensor_numpy.cpp:84.)
  cpu = _conversion_method_template(device=torch.device("cpu"))
Total VRAM 8188 MB, total RAM 32472 MB

Explination :

This error indicates that the installed version of NumPy (2.1.0) is incompatible with modules that were compiled using NumPy 1.x. NumPy 2.x is not backward compatible with 1.x, leading to potential crashes or failures. The error message suggests downgrading to a NumPy version less than 2 or upgrading the affected modules.

Issue While Downgrading NumPy

When attempting to downgrade NumPy to version 1.23.5, the following error occurs:

(comfy-env) (base) PS D:\Comfyui\cli> pip install numpy==1.23.5
Collecting numpy==1.23.5
  Using cached numpy-1.23.5.tar.gz (10.7 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      Traceback (most recent call last):
        File "D:\Comfyui\cli\comfy-env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "D:\Comfyui\cli\comfy-env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "D:\Comfyui\cli\comfy-env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 112, in get_requires_for_build_wheel
          backend = _build_backend()
                    ^^^^^^^^^^^^^^^^
        File "D:\Comfyui\cli\comfy-env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 77, in _build_backend
          obj = import_module(mod_path)
                ^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\lilie\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
        File "<frozen importlib._bootstrap_external>", line 995, in exec_module
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "C:\Users\lilie\AppData\Local\Temp\pip-build-env-iqsqiz8o\overlay\Lib\site-packages\setuptools\__init__.py", line 16, in <module>
          import setuptools.version
        File "C:\Users\lilie\AppData\Local\Temp\pip-build-env-iqsqiz8o\overlay\Lib\site-packages\setuptools\version.py", line 1, in <module>
          import pkg_resources
        File "C:\Users\lilie\AppData\Local\Temp\pip-build-env-iqsqiz8o\overlay\Lib\site-packages\pkg_resources\__init__.py", line 2172, in <module>
          register_finder(pkgutil.ImpImporter, find_on_path)
                          ^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
jwvanderbeck commented 1 month ago

I went to 1.26.4 pip install numpy==1.26.4

But yeah the default environment setup by comfy-cli is invalid :(

robinjhuang commented 1 month ago

Reproduced on windows only. @telamonian found this issue that might be related:

https://github.com/pytorch/pytorch/issues/131668#issuecomment-2307447045

robinjhuang commented 1 month ago

@Lilien86 Can you update to the latest and try now? @telamonian did a patch for windows.

Should work with --fast-deps

comfy install --fast-deps

https://github.com/Comfy-Org/comfy-cli/releases/tag/v1.1.6

Lilien86 commented 1 month ago

I will try ! But I don't understand how to download comfy-cli with the .zip folder, can you explain please ?

robinjhuang commented 2 weeks ago

@Lilien86 To update, run pip install --upgrade comfy-cli

robinjhuang commented 2 weeks ago

Then run comfy -v to confirm the new version.

Then reinstall comfy install --fast-deps --restore to reinstall all of the ComfyUI dependencies as well.