Skip to content

[Bug]: ImportError: numpy.core.multiarray failed to import #4167

Description

@praveenjadhav1510

Checklist

  • The issue has not been resolved by following the troubleshooting guide
  • The issue exists on a clean installation of Fooocus
  • The issue exists in the current version of Fooocus
  • The issue has not been reported before recently
  • The issue has been reported before but has not been fixed yet

What happened?

ImportError: numpy.core.multiarray failed to import
→ Failed to import CuPy

Steps to reproduce the problem

  1. Launch environment (Google Colab / Linux with Python 3.12)
  2. Clone Fooocus repo
  3. Run: python entry_with_update.py --share --always-high-vram
  4. Let dependencies install automatically
  5. Crash occurs during startup when importing rembg → pymatting → cupy

What should have happened?

Fooocus should start successfully and launch the web UI without crashing during dependency import.

What browsers do you use to access Fooocus?

No response

Where are you running Fooocus?

None

What operating system are you using?

No response

Console logs

Requirement already satisfied: pygit2==1.15.1 in /usr/local/lib/python3.12/dist-packages (1.15.1)
Requirement already satisfied: cffi>=1.16.0 in /usr/local/lib/python3.12/dist-packages (from pygit2==1.15.1) (2.0.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.12/dist-packages (from cffi>=1.16.0->pygit2==1.15.1) (3.0)
/content
fatal: destination path 'Fooocus' already exists and is not an empty directory.
/content/Fooocus
Already up-to-date
Update succeeded.
[System ARGV] ['entry_with_update.py', '--share', '--always-high-vram']
Python 3.12.13 (main, Mar  4 2026, 09:23:07) [GCC 11.4.0]
Fooocus version: 2.5.5
[Cleanup] Attempting to delete content of temp dir /tmp/fooocus
[Cleanup] Cleanup successful
Total VRAM 14913 MB, total RAM 12976 MB
Set vram state to: HIGH_VRAM
Always offload VRAM
Device: cuda:0 Tesla T4 : native
VAE dtype: torch.float32
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/cupy/__init__.py", line 18, in <module>
    from cupy import _core  # NOQA
    ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/cupy/_core/__init__.py", line 5, in <module>
    from cupy._core import core  # NOQA
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "cupy/_core/core.pyx", line 1, in init cupy._core.core
  File "/usr/local/lib/python3.12/dist-packages/cupy/cuda/__init__.py", line 13, in <module>
    from cupy.cuda import compiler  # NOQA
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/cupy/cuda/compiler.py", line 16, in <module>
    from cupy.cuda import function
  File "cupy/cuda/function.pyx", line 1, in init cupy.cuda.function
  File "cupy/_core/_scalar.pyx", line 1, in init cupy._core._scalar
ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use '<void>numpy._import_array' to disable if you are certain you don't need it).

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/content/Fooocus/entry_with_update.py", line 46, in <module>
    from launch import *
  File "/content/Fooocus/launch.py", line 152, in <module>
    from webui import *
  File "/content/Fooocus/webui.py", line 10, in <module>
    import modules.async_worker as worker
  File "/content/Fooocus/modules/async_worker.py", line 3, in <module>
    from extras.inpaint_mask import generate_mask_from_image, SAMOptions
  File "/content/Fooocus/extras/inpaint_mask.py", line 8, in <module>
    from rembg import remove, new_session
  File "/usr/local/lib/python3.12/dist-packages/rembg/__init__.py", line 5, in <module>
    from .bg import remove
  File "/usr/local/lib/python3.12/dist-packages/rembg/bg.py", line 17, in <module>
    from pymatting.alpha.estimate_alpha_cf import estimate_alpha_cf
  File "/usr/local/lib/python3.12/dist-packages/pymatting/__init__.py", line 5, in <module>
    from pymatting.foreground import *
  File "/usr/local/lib/python3.12/dist-packages/pymatting/foreground/__init__.py", line 7, in <module>
    from pymatting.foreground.estimate_foreground_ml_cupy import estimate_foreground_ml_cupy
  File "/usr/local/lib/python3.12/dist-packages/pymatting/foreground/estimate_foreground_ml_cupy.py", line 2, in <module>
    import cupy as cp
  File "/usr/local/lib/python3.12/dist-packages/cupy/__init__.py", line 20, in <module>
    raise ImportError(f'''
ImportError: 
================================================================
Failed to import CuPy.

If you installed CuPy via wheels (cupy-cudaXXX or cupy-rocm-X-X), make sure that the package matches with the version of CUDA or ROCm installed.

On Linux, you may need to set LD_LIBRARY_PATH environment variable depending on how you installed CUDA/ROCm.
On Windows, try setting CUDA_PATH environment variable.

Check the Installation Guide for details:
  https://docs.cupy.dev/en/latest/install.html

Original error:
  ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use '<void>numpy._import_array' to disable if you are certain you don't need it).
================================================================

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageThis needs an (initial) review

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions