stable-diffusion-webui-forge icon indicating copy to clipboard operation
stable-diffusion-webui-forge copied to clipboard

Issue with Numpy when starting webui

Open GeorgeMonkey1 opened this issue 5 months ago • 21 comments

Hello,

I have Forge for one year, and I never had any problem, but for no particular reason, today it's not starting anymore, here is the issue :

I suppose it's linked with Numpy, I went on powershell and tried "pip install --force-reinstall -v "numpy==1.26.4" and also tried 1.26.2 but it seems like the program doesn't see it, I also tried deleting venv and rerunning but it didn't do anything special. Maybe there is another issue behind this ? do someone have an idea about the problem ? It's probably something simple but I'm getting out of ideas... Thanks !

`venv "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: f0.0.17v1.8.0rc-previous
Commit hash: bfee03d8d9415a925616f40ede030fe7a51cbcfd
Installing requirements
Installing forge_legacy_preprocessor requirement: changing opencv-python version from 4.11.0.86 to 4.8.0
Installing sd-forge-controlnet requirement: changing opencv-python version from 4.12.0.88 to 4.8.0
Launching Web UI with arguments: --theme dark

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.2.6 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 "E:\Programmes\Forge\stable-diffusion-webui-forge\launch.py", line 51, in <module>
    main()
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\launch.py", line 47, in main
    start()
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\modules\launch_utils.py", line 541, in start
    import webui
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\webui.py", line 17, in <module>
    initialize_forge()
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\modules_forge\initialization.py", line 50, in initialize_forge
    import ldm_patched.modules.model_management as model_management
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\ldm_patched\modules\model_management.py", line 9, in <module>
    from modules_forge import stream
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\modules_forge\stream.py", line 3, in <module>
    import torch
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\__init__.py", line 1382, in <module>
    from .functional import *  # noqa: F403
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\functional.py", line 7, in <module>
    import torch.nn.functional as F
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\nn\__init__.py", line 1, in <module>
    from .modules import *  # noqa: F403
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\__init__.py", line 35, in <module>
    from .transformer import TransformerEncoder, TransformerDecoder, \
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\transformer.py", line 20, in <module>
    device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\nn\modules\transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:84.)
  device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
Total VRAM 12282 MB, total RAM 32694 MB
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 4070 SUPER : native
Hint: your device supports --pin-shared-memory for potential speed improvements.
Hint: your device supports --cuda-malloc for potential speed improvements.
Hint: your device supports --cuda-stream for potential speed improvements.
VAE dtype: torch.bfloat16
CUDA Stream Activated:  False

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.2.6 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 "E:\Programmes\Forge\stable-diffusion-webui-forge\launch.py", line 51, in <module>
    main()
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\launch.py", line 47, in main
    start()
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\modules\launch_utils.py", line 541, in start
    import webui
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\webui.py", line 19, in <module>
    initialize.imports()
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\modules\initialize.py", line 29, in imports
    import pytorch_lightning  # noqa: F401
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\__init__.py", line 35, in <module>
    from pytorch_lightning.callbacks import Callback  # noqa: E402
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\callbacks\__init__.py", line 28, in <module>
    from pytorch_lightning.callbacks.pruning import ModelPruning
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\callbacks\pruning.py", line 31, in <module>
    from pytorch_lightning.core.module import LightningModule
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\core\__init__.py", line 16, in <module>
    from pytorch_lightning.core.module import LightningModule
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\core\module.py", line 48, in <module>
    from pytorch_lightning.trainer.connectors.logger_connector.fx_validator import _FxValidator
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\trainer\__init__.py", line 17, in <module>
    from pytorch_lightning.trainer.trainer import Trainer
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 58, in <module>
    from pytorch_lightning.loops import PredictionLoop, TrainingEpochLoop
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\loops\__init__.py", line 15, in <module>
    from pytorch_lightning.loops.batch import TrainingBatchLoop  # noqa: F401
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\loops\batch\__init__.py", line 15, in <module>
    from pytorch_lightning.loops.batch.training_batch_loop import TrainingBatchLoop  # noqa: F401
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\loops\batch\training_batch_loop.py", line 20, in <module>
    from pytorch_lightning.loops.optimization.manual_loop import _OUTPUTS_TYPE as _MANUAL_LOOP_OUTPUTS_TYPE
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\loops\optimization\__init__.py", line 15, in <module>
    from pytorch_lightning.loops.optimization.manual_loop import ManualOptimization  # noqa: F401
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\loops\optimization\manual_loop.py", line 23, in <module>
    from pytorch_lightning.loops.utilities import _build_training_step_kwargs, _extract_hiddens
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\loops\utilities.py", line 29, in <module>
    from pytorch_lightning.strategies.parallel import ParallelStrategy
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\strategies\__init__.py", line 15, in <module>
    from pytorch_lightning.strategies.bagua import BaguaStrategy  # noqa: F401
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\strategies\bagua.py", line 29, in <module>
    from pytorch_lightning.plugins.precision import PrecisionPlugin
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\plugins\__init__.py", line 7, in <module>
    from pytorch_lightning.plugins.precision.apex_amp import ApexMixedPrecisionPlugin
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\plugins\precision\__init__.py", line 18, in <module>
    from pytorch_lightning.plugins.precision.fsdp_native_native_amp import FullyShardedNativeNativeMixedPrecisionPlugin
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\pytorch_lightning\plugins\precision\fsdp_native_native_amp.py", line 24, in <module>
    from torch.distributed.fsdp.fully_sharded_data_parallel import MixedPrecision
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\distributed\fsdp\__init__.py", line 1, in <module>
    from .flat_param import FlatParameter
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\distributed\fsdp\flat_param.py", line 30, in <module>
    from torch.distributed.fsdp._common_utils import (
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\distributed\fsdp\_common_utils.py", line 31, in <module>
    from torch.distributed._tensor.device_mesh import DeviceMesh
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\distributed\_tensor\__init__.py", line 6, in <module>
    import torch.distributed._tensor.ops
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\distributed\_tensor\ops\__init__.py", line 2, in <module>
    from .embedding_ops import *  # noqa: F403
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\distributed\_tensor\ops\embedding_ops.py", line 5, in <module>
    from torch.distributed._tensor.op_schema import OpSchema, OutputSharding
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\distributed\_tensor\op_schema.py", line 5, in <module>
    from torch.distributed._tensor.placement_types import DTensorSpec
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\distributed\_tensor\placement_types.py", line 7, in <module>
    import torch.distributed._functional_collectives as funcol
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\distributed\_functional_collectives.py", line 20, in <module>
    from torch._dynamo.external_utils import is_compiling as is_torchdynamo_compiling
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\_dynamo\__init__.py", line 2, in <module>
    from . import allowed_functions, convert_frame, eval_frame, resume_execution
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\_dynamo\allowed_functions.py", line 26, in <module>
    from . import config
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\_dynamo\config.py", line 49, in <module>
    torch.onnx.is_in_onnx_export: False,
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\__init__.py", line 1831, in __getattr__
    return importlib.import_module(f".{name}", __name__)
  File "C:\Users\ds\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\onnx\__init__.py", line 57, in <module>
    from ._internal.onnxruntime import (
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\torch\onnx\_internal\onnxruntime.py", line 35, in <module>
    import onnxruntime  # type: ignore[import]
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\onnxruntime\__init__.py", line 23, in <module>
    from onnxruntime.capi._pybind_state import ExecutionMode  # noqa: F401
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\onnxruntime\capi\_pybind_state.py", line 32, in <module>
    from .onnxruntime_pybind11_state import *  # noqa
AttributeError: _ARRAY_API not found
Traceback (most recent call last):
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\launch.py", line 51, in <module>
    main()
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\launch.py", line 47, in main
    start()
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\modules\launch_utils.py", line 541, in start
    import webui
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\webui.py", line 19, in <module>
    initialize.imports()
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\modules\initialize.py", line 53, in imports
    from modules import processing, gradio_extensons, ui  # noqa: F401
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\modules\processing.py", line 15, in <module>
    from skimage import exposure
  File "E:\Programmes\Forge\stable-diffusion-webui-forge\venv\lib\site-packages\skimage\__init__.py", line 122, in <module>
    from ._shared import geometry
  File "geometry.pyx", line 1, in init skimage._shared.geometry
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject`

GeorgeMonkey1 avatar Jul 08 '25 00:07 GeorgeMonkey1

Want to add that I am having the same situation and same issue here

My limited understanding from Googling is to find a requirements.txt with "numpy" and change it to "numpy<2". Of all the requirements.txt files, there is only one with "numpy" (webui\requirements.txt), which I added "<2", but I still encountered the same issue after changing it

Edit: Phew, managed to fix it. Thanks to Glaudeo and bkrew for the additional information to help my understanding

  1. Something in SD Forge is causing numpy 2.2.6 to be installed against our wishes
  2. The command "pip install numpy 1.26.4" installs it in "C:\Users\[YourName]\AppData\Local\Programs\Python\Python310\Lib\site-packages" (this directory will be referred to below as "AppData directory")
  3. However, SD Forge uses the two directories of "[SD forge installation directory]\system\python\Lib\site-packages" and "[SD forge installation directory]\webui\venv\Lib\site-packages" instead (the two directories will be referred to below as "SD Forge's directories" for simplicity)

What I've done:

  1. Run "pip install numpy 1.26.4" to install it in AppData directory. If you run "pip uninstall numpy" afterwards it will confirm to you the version and location
  2. Delete the file "numpy-2.2.6-cp310-cp310-win_amd64.whl" and folder "numpy-2.2.6.dist-info" from both of SD Forge's directories
  3. Copy the three folders of "numpy", "numpy.libs", and "numpy-1.26.4.dist-info", and the file "numpy-1.26.4-cp310-cp310-win_amd64.whl" from AppData directory to both of SD Forge's directories
  4. Change "webui-user.bat" in "webui" folder to add "--skip-install" to "set COMMANDLINE_ARGS=". This will prevent whatever is causing this issue to overwrite the numpy 1.26.4 we manually copied/pasted with 2.2.6 again
  5. Run "run.bat" in SD Forge's root directory, and pray hard

BlitzAceSamy avatar Jul 08 '25 09:07 BlitzAceSamy

I have the same problem. For some reason today it decided to install a numpy 2.2.6 instead of numpy 1.26.2 into it's virtual environment. Even if I replace it in \system\python\Lib\site-packages it still overrights old numpy with a newer version

Glaudeo avatar Jul 08 '25 09:07 Glaudeo

Add --skip-install arg in the start-ui.bat as an arg. This should prevent overwriting customization.

bkrew avatar Jul 08 '25 10:07 bkrew

I have the same problem. For some reason today it decided to install a numpy 2.2.6 instead of numpy 1.26.2 into it's virtual environment. Even if I replace it in \system\python\Lib\site-packages it still overrights old numpy with a newer version

Fyi I've solved the issue thanks to your and bkrew's help! I've updated my comment above with detailed information

BlitzAceSamy avatar Jul 08 '25 10:07 BlitzAceSamy

Just running pip install numpy<2 was not enough. I was able to fix it as follows:

From the forge directory run:

./venv/Scripts/pip.exe install "numpy<2"

Then edit webui-user.bat and add the skip install flag:

set COMMANDLINE_ARGS=--skip-install

aiartsy77 avatar Jul 08 '25 16:07 aiartsy77

Hello,

Thanks for all the answers, I'm happy to see that it wasn't only me !

After trying what was offered in the answers, the Numpy issue went out... only to have another issue haha I don't know what happened, but basically everything seems bugged. (After the numpy, it was simpy failing, then I had another error "no packaging found", and so on... so I gave up)

I resorted to simply reinstalling everything, and something weird still happened :

You see, on my last version (I mean the version I used when I wrote this post), I didn't have the "Run.bat" nor "Update.bat", probably because I used the "git remote add forge https://github.com/lllyasviel/stable-diffusion-webui-forge" way of installing. (I don't really remember but that was probably it)

Here, I tried with the package, I went for update.bat, then run.bat, and the webui started correctly. I then imported my settings, my models, and actually, when I start it with webui-user.bat, I get the exact same problem that I had yesterday, but when I start it with run.bat, it works, even though run.bat simply calls webui-user.bat... So I'm completely lost. I don't understand what's wrong... (Also, for some reason, even though I moved all models to the new folder, the VAE still tries to call the "older folder", and the adetailer wasn't working either, I had to copy paste from older forge folder to the new one.)

I mean, this works, (the new version), but there is something really weird going on there, can you guys tell me if you all have the run.bat, and if yes, can you try running webui-user.bat and see if this works ? Thanks all !

GeorgeMonkey1 avatar Jul 08 '25 18:07 GeorgeMonkey1

even though run.bat simply calls webui-user.bat...

Nope. run.bat - with virtual environment. webui-user.bat - outside virtual environment. My advise - never execute webui-user.bat

Juqowel avatar Jul 08 '25 22:07 Juqowel

I was using the "previous" tag when building my custom docker image (built 6+ months ago) and was surprised today to find my new container does not start properly due to the issue in question.

The fix:

  • after install (running webui.sh) with the following webui-user.sh option: COMMANDLINE_ARGS="--exit --skip-torch-cuda-test"
  • pip install xformers==0.0.23.post1 'numpy<2'
  • edit webui-user.sh, adding the --skip-install option to COMMANDLINE_ARGS
  • start with webui.sh as usual

I was not able to locate where exactly numpy 2.2.6 came from. I suspect a file is downloaded from the Internet somewhere in the code, in which file the numpy requirement was bumped.

Last deployment of my image was 20 days ago and the software was running without any issues. If you already have running, working version - save your hustle and add "--skip-install" to your COMMANDLINE_ARGS or after restart you most probably will be surprised.

georgitsenov avatar Jul 09 '25 14:07 georgitsenov

I have the same issue, but unfortunately, I have already tried all the solutions mentioned above, and none of them have helped me resolve this problem

yoshihirosakamoto avatar Jul 09 '25 17:07 yoshihirosakamoto

after trying solutions mentioned here I faced a different problem:

Traceback (most recent call last):
  File "C:\Program Files\11\webui_forge\webui\launch.py", line 54, in <module>
    main()
  File "C:\Program Files\11\webui_forge\webui\launch.py", line 50, in main
    start()
  File "C:\Program Files\11\webui_forge\webui\modules\launch_utils.py", line 546, in start
    import webui
  File "C:\Program Files\11\webui_forge\webui\webui.py", line 23, in <module>
    initialize.imports()
  File "C:\Program Files\11\webui_forge\webui\modules\initialize.py", line 16, in imports
    import pytorch_lightning  # noqa: F401
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\pytorch_lightning\__init__.py", line 35, in <module>
    from pytorch_lightning.callbacks import Callback  # noqa: E402
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\pytorch_lightning\callbacks\__init__.py", line 14, in <module>
    from pytorch_lightning.callbacks.batch_size_finder import BatchSizeFinder
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\pytorch_lightning\callbacks\batch_size_finder.py", line 24, in <module>
    from pytorch_lightning.callbacks.callback import Callback
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\pytorch_lightning\callbacks\callback.py", line 25, in <module>
    from pytorch_lightning.utilities.types import STEP_OUTPUT
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\pytorch_lightning\utilities\types.py", line 27, in <module>
    from torchmetrics import Metric
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\torchmetrics\__init__.py", line 31, in <module>
    import scipy.signal
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\scipy\signal\__init__.py", line 293, in <module>
    from . import _sigtools, windows
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\scipy\signal\windows\__init__.py", line 42, in <module>
    from ._windows import *
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\scipy\signal\windows\_windows.py", line 7, in <module>
    from scipy import linalg, special, fft as sp_fft
  File "<frozen importlib._bootstrap>", line 1075, in _handle_fromlist
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\scipy\__init__.py", line 146, in __getattr__
    return _importlib.import_module(f'scipy.{name}')
  File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\scipy\special\__init__.py", line 826, in <module>
    from . import _basic
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\scipy\special\_basic.py", line 22, in <module>
    from ._multiufuncs import (assoc_legendre_p_all,
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\scipy\special\_multiufuncs.py", line 142, in <module>
    sph_legendre_p = MultiUFunc(
  File "C:\Program Files\11\webui_forge\webui\venv\lib\site-packages\scipy\special\_multiufuncs.py", line 41, in __init__
    raise ValueError("All ufuncs must have type `numpy.ufunc`."
ValueError: All ufuncs must have type `numpy.ufunc`. Received (<ufunc 'sph_legendre_p'>, <ufunc 'sph_legendre_p'>, <ufunc 'sph_legendre_p'>)

gleverstein avatar Jul 09 '25 22:07 gleverstein

Want to add that I am having the same situation and same issue here

My limited understanding from Googling is to find a requirements.txt with "numpy" and change it to "numpy<2". Of all the requirements.txt files, there is only one with "numpy" (webui\requirements.txt), which I added "<2", but I still encountered the same issue after changing it

Edit: Phew, managed to fix it. Thanks to Glaudeo and bkrew for the additional information to help my understanding

1. Something in SD Forge is causing numpy 2.2.6 to be installed against our wishes

2. The command "pip install numpy 1.26.4" installs it in "C:\Users\[YourName]\AppData\Local\Programs\Python\Python310\Lib\site-packages" (this directory will be referred to below as "AppData directory")

3. However, SD Forge uses the two directories of "[SD forge installation directory]\system\python\Lib\site-packages" and "[SD forge installation directory]\webui\venv\Lib\site-packages" instead (the two directories will be referred to below as "SD Forge's directories" for simplicity)

What I've done:

1. Run "pip install numpy 1.26.4" to install it in AppData directory. If you run "pip uninstall numpy" afterwards it will confirm to you the version and location

2. Delete the file "numpy-2.2.6-cp310-cp310-win_amd64.whl" and folder "numpy-2.2.6.dist-info" from both of SD Forge's directories

3. Copy the three folders of "numpy", "numpy.libs", and "numpy-1.26.4.dist-info", and the file "numpy-1.26.4-cp310-cp310-win_amd64.whl" from AppData directory to both of SD Forge's directories

4. Change "webui-user.bat" in "webui" folder to add "--skip-install" to "set COMMANDLINE_ARGS=". This will prevent whatever is causing this issue to overwrite the numpy 1.26.4 we manually copied/pasted with 2.2.6 again

5. Run "run.bat" in SD Forge's root directory, and pray hard

i got this : Traceback (most recent call last): File "E:\AI WOEK\forge\webui\launch.py", line 51, in main() File "E:\AI WOEK\forge\webui\launch.py", line 39, in main prepare_environment() File "E:\AI WOEK\forge\webui\modules\launch_utils.py", line 431, in prepare_environment raise RuntimeError( RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check Press any key to continue . . .

getlone avatar Jul 10 '25 02:07 getlone

Want to add that I am having the same situation and same issue here My limited understanding from Googling is to find a requirements.txt with "numpy" and change it to "numpy<2". Of all the requirements.txt files, there is only one with "numpy" (webui\requirements.txt), which I added "<2", but I still encountered the same issue after changing it Edit: Phew, managed to fix it. Thanks to Glaudeo and bkrew for the additional information to help my understanding

1. Something in SD Forge is causing numpy 2.2.6 to be installed against our wishes

2. The command "pip install numpy 1.26.4" installs it in "C:\Users\[YourName]\AppData\Local\Programs\Python\Python310\Lib\site-packages" (this directory will be referred to below as "AppData directory")

3. However, SD Forge uses the two directories of "[SD forge installation directory]\system\python\Lib\site-packages" and "[SD forge installation directory]\webui\venv\Lib\site-packages" instead (the two directories will be referred to below as "SD Forge's directories" for simplicity)

What I've done:

1. Run "pip install numpy 1.26.4" to install it in AppData directory. If you run "pip uninstall numpy" afterwards it will confirm to you the version and location

2. Delete the file "numpy-2.2.6-cp310-cp310-win_amd64.whl" and folder "numpy-2.2.6.dist-info" from both of SD Forge's directories

3. Copy the three folders of "numpy", "numpy.libs", and "numpy-1.26.4.dist-info", and the file "numpy-1.26.4-cp310-cp310-win_amd64.whl" from AppData directory to both of SD Forge's directories

4. Change "webui-user.bat" in "webui" folder to add "--skip-install" to "set COMMANDLINE_ARGS=". This will prevent whatever is causing this issue to overwrite the numpy 1.26.4 we manually copied/pasted with 2.2.6 again

5. Run "run.bat" in SD Forge's root directory, and pray hard

i got this : Traceback (most recent call last): File "E:\AI WOEK\forge\webui\launch.py", line 51, in main() File "E:\AI WOEK\forge\webui\launch.py", line 39, in main prepare_environment() File "E:\AI WOEK\forge\webui\modules\launch_utils.py", line 431, in prepare_environment raise RuntimeError( RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check Press any key to continue . . .

me 2 , I hope someone fix a solution, thanks

yoshihirosakamoto avatar Jul 10 '25 03:07 yoshihirosakamoto

Guys, I finally found a solution for my case (the premise is that you must have a previously functional backup):

First, you must ensure that both your Python installation and the numpy version in stable-diffusion-forge are the same: 1.26.4.

First, run pip uninstall numpy for both Python and stable-diffusion-forge to remove them. After that, delete any numpy-related files, such as numpy, numpy.libs, and numpy-1.26.4.dist-info, to ensure that numpy won't cause any further issues.

Finally, run pip install numpy==1.26.4

For both to reinstall.

Go to your backup and find the "system" folder in the root of your stable-diffusion-webui-forge. In your stable-diffusion-webui-forge, rename your "system" folder to something else for backup. Copy the "system" folder from your backup to your stable-diffusion-webui-forge. Go to the "webui" folder and edit your "webui-user.bat," adding "--skip-install" to the end of the line for set COMMANDLINE_ARGS=. Enjoy your stable-diffusion-webui-forge!

You must be wondering: why don't I just use the backup version? The reason is that the updates to stable-diffusion-webui-forge have broken the entire setup, especially since many files in the 'system' directory have been modified. As for what has changed, there are too many alterations to list, so I decided to replace it with the backup 'system' folder and stop their updates.

I hope this can help friends like me who, despite following the above solution, still cannot resolve the issue.

yoshihirosakamoto avatar Jul 10 '25 04:07 yoshihirosakamoto

I've solved the problem with this post: https://github.com/Panchovix/stable-diffusion-webui-reForge/issues/47 The following is a quoted solution about 2 built-in extensions: sd_forge_controlnet and forge_legacy_preprocessor

_Additional information

Suggested fix (from https://github.com/Mikubill/sd-webui-controlnet/issues/2961): edit stable-diffusion-webui-reForge\webui\extensions-builtin\sd_forge_controlnet\install.py and change line 16:

def comparable_version(version: str) -> Tuple: #return tuple(version.split(".")) # existing line 16 commented out return tuple(map(int, version.split("."))) # fixed line_

wslake avatar Jul 10 '25 14:07 wslake

I know I said I fixed the issue in my comment above, but then I realized ADetailer is not compatible with the workaround listed in my comment above and absolutely refuses to work, so I'm sitting down and trying to actually figure out what is going on and what happened

For now, what I can deduce is that:

  1. A lot of the Python libraries require NumPy 1.26.4, including SciPy 1.12.0 and matplotlib 3.8.2
  2. However, opencv-python 4.12.0.88 requires Numpy 2.2.6

The fact that this issue was reported by @GeorgeMonkey1 at 8 Jul 2025 midnight GMT, plus the fact that opencv-python 4.12.0.88 was released on 7 Jul 2025 (according to https://pypi.org/project/opencv-python/ ) strengthened my deduction. Plus there are these two lines in the logs copy-pasted by @GeorgeMonkey1

Installing forge_legacy_preprocessor requirement: changing opencv-python version from 4.11.0.86 to 4.8.0
Installing sd-forge-controlnet requirement: changing opencv-python version from 4.12.0.88 to 4.8.0

This does seem to imply that these two (forge_legacy_preprocessor and sd-forge-controlnet) stated their requirement to be, 4.8.0. And yet for some reason we can see it being installed from 4.11.0.86 to the latest version of 4.12.0.88 in the logs?

Anyway, these are currently the limit of what I've worked out. I'll go back in and take a closer look, and update (i.e., edit) this comment with any additional relevant information I've found

Edit: Forgot to mention that this is all from a fresh re-install of webui_forge_cu121_torch21_f0017, by the way

Edit 2: Found it! These two requirements.txt files

  1. [SD forge installation directory]\webui\extensions-builtin\forge_legacy_preprocessors\requirements.txt
  2. [SD forge installation directory]\webui\extensions-builtin\sd_forge_controlnet\requirements.txt

have the following item opencv-python>=4.8.0 meaning they want to install a version of opencv-python that is 4.8.0 or after, and will prioritize a later version. opencv-python 4.12.0.88 released six days ago, demanded to have numpy 2.2.6, proceeded to install it, and wrecked havoc throughout all the other libraries that wanted numpy 1.26.4

Change the line stated above in the two files listed above to opencv-python==4.11.0.86 so it installs 4.11.0.86 instead of 4.12.0.88, and problem solved

BlitzAceSamy avatar Jul 13 '25 07:07 BlitzAceSamy

Add --skip-install arg in the start-ui.bat as an arg. This should prevent overwriting customization.

  1. Activate Your Virtual Environment
  2. pip uninstall scikit-image --yes
  3. pip uninstall numpy --yes
  4. pip install numpy==1.24.4
  5. pip install scikit-image
  6. Open Webui-user in Editor (Notepad)
  7. add --skip-install to command line args and save
  8. close all cmd windows
  9. run webui-user, enjoy

YoungBlackZeus avatar Jul 13 '25 08:07 YoungBlackZeus

I too had this problem. The simple solution from BlitzAceSamy above solved this issue quickly and easily..

**************** Edit 2: Found it! These two requirements.txt files

[SD forge installation directory]\webui\extensions-builtin\forge_legacy_preprocessors\requirements.txt [SD forge installation directory]\webui\extensions-builtin\sd_forge_controlnet\requirements.txt have the following item opencv-python>=4.8.0 meaning they want to install a version of opencv-python that is 4.8.0 or after, and will prioritize a later version. opencv-python 4.12.0.88 released six days ago, demanded to have numpy 2.2.6, proceeded to install it, and wrecked havoc throughout all the other libraries that wanted numpy 1.26.4

Change the line stated above in the two files listed above to opencv-python==4.11.0.86 so it installs 4.11.0.86 instead of 4.12.0.88, and problem solved **************

I have made backups of these two modified requirements files and also the modified webui-bat file where set COMMANDLINE_ARGS=--skip-install is added to prevent these requirement files being overwritten again.

There a good community on here that always helps out...

DIGITAL-SURFER avatar Jul 17 '25 19:07 DIGITAL-SURFER

Tried all this, got ForgeUI working but I could not get adetailer working after trying various things.

The stupid fix which i have got to work:

  1. have correct version of python installed normally and independently (I already had this from a1111)
  2. Make a new folder to install a fresh copy of forge
  3. in the new folder git clone the link provided for ForgeUI
  4. run the new webui-user.bat to completely reinstall venv (it will eventually stop running without opening forge as you have no models in place)
  5. move extensions, models and output over to the new forgeui.
  6. My ForgeUI now works completely normally, with everything it had before including adetailer.

Akkare avatar Jul 18 '25 15:07 Akkare

Has anyone figured out what was causing numpy 2.2.6 to be installed?

Is it opencv-python?

I'm running an older version of forge with few extensions(none have been updated) and did not update or add anything new, I'm not running a git pull build....

I fixed the error by adding

python -m pip install --force-reinstall numpy==1.26.4 pandas

To my webui-user.bat (right after @echo off)

Allowed forge to restart and reinstall numpy, and that fixed the issue without having to rebuild the venv or reinstall forge, added the -skipinstall flag and then commented out the line back in my webui-user.bat so it didn't reinstall every time I restarted forge.

DrUmranAli avatar Jul 29 '25 09:07 DrUmranAli

Summary of above and what I did:

Go to SD folder, search for requirements.txt, open them all, any mention of opencv-python > 4.11.0.86 make it ==4.11.0.86. Any mention of numpy make it numpy<2 (dont know if this is necessary, I'm guessing no due to above change)

Delete the three numpy folders and the whl file as well as the three scipy folders and whl file in the SD folders site-packages.

Open up a terminal and run pip install numpy<2, pip install scipy<1.13

Go to Python10 folder (appdata or C) and copy the 6 new folders and 2 new whl files for numpy and scipy into the SD folders site-packages.

run.bat

CrimsonHD avatar Aug 08 '25 16:08 CrimsonHD

For me i just did: rm -rf extensions/sd-webui-roop

I didn't use it anyway.

Requirement already satisfied: mpmath<1.4,>=1.1.0 in ./venv/lib/python3.11/site-packages (from sympy->onnxruntime==1.15.0->-r /mnt/code/imaging/forge_flux/extensions/sd-webui-roop/requirements.txt (line 3)) (1.3.0) Using cached opencv_python-4.7.0.72-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (61.8 MB) Using cached numpy-2.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB) Using cached protobuf-6.32.1-cp39-abi3-manylinux2014_x86_64.whl (322 kB) Using cached pydantic-2.11.9-py3-none-any.whl (444 kB) Using cached pydantic_core-2.33.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB) Installing collected packages: pydantic-core, protobuf, numpy, pydantic, opencv-python Attempting uninstall: pydantic-core Found existing installation: pydantic_core 2.20.1 Uninstalling pydantic_core-2.20.1: Successfully uninstalled pydantic_core-2.20.1 Attempting uninstall: protobuf Found existing installation: protobuf 3.20.0 Uninstalling protobuf-3.20.0: Successfully uninstalled protobuf-3.20.0 Attempting uninstall: numpy Found existing installation: numpy 1.26.2 Uninstalling numpy-1.26.2: Successfully uninstalled numpy-1.26.2 Attempting uninstall: pydantic Found existing installation: pydantic 2.8.2 Uninstalling pydantic-2.8.2: Successfully uninstalled pydantic-2.8.2 Attempting uninstall: opencv-python Found existing installation: opencv-python 4.11.0.86 Uninstalling opencv-python-4.11.0.86: Successfully uninstalled opencv-python-4.11.0.86

somenewaccountthen avatar Sep 16 '25 13:09 somenewaccountthen