VectorSpaceLab / OmniGen

OmniGen: Unified Image Generation. https://arxiv.org/pdf/2409.11340
MIT License
1.48k stars 76 forks source link

app.py gives RuntimeError: Numpy is not available #75

Open rzoun opened 5 hours ago

rzoun commented 5 hours ago

Doing a clean install:

But when running 'python app.py' I get RuntimeError: Numpy is not available. Even though I can import numpy and see with numpy.version.version that I have version 2.1.2 is installed.

Full output: (omnigen) D:\OmniGen>python app.py

A module that was compiled using NumPy 1.x cannot be run in NumPy 2.1.2 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:\OmniGen\app.py", line 7, in from OmniGen import OmniGenPipeline File "D:\OmniGen\OmniGen__init.py", line 1, in from .model import OmniGen File "D:\OmniGen\OmniGen\model.py", line 10, in from timm.models.vision_transformer import PatchEmbed, Attention, Mlp File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\timm__init.py", line 2, in from .layers import is_scriptable, is_exportable, set_scriptable, set_exportable File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\timm\layers__init.py", line 8, in from .classifier import create_classifier, ClassifierHead, NormMlpClassifierHead, ClNormMlpClassifierHead File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\timm\layers\classifier.py", line 15, in from .create_norm import get_norm_layer File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\timm\layers\create_norm.py", line 14, in from torchvision.ops.misc import FrozenBatchNorm2d File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchvision__init.py", line 6, in from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchvision\models\init.py", line 2, in from .convnext import * File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchvision\models\convnext.py", line 8, in from ..ops.misc import Conv2dNormActivation, Permute File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchvision\ops\init__.py", line 23, in from .poolers import MultiScaleRoIAlign File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchvision\ops\poolers.py", line 10, in from .roi_align import roi_align File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchvision\ops\roi_align.py", line 4, in import torch._dynamo File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch_dynamo\init__.py", line 64, in torch.manual_seed = disable(torch.manual_seed) File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch_dynamo\decorators.py", line 50, in disable return DisableContext()(fn) File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch_dynamo\eval_frame.py", line 410, in call__ (filename is None or trace_rules.check(fn)) File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch_dynamo\trace_rules.py", line 3378, in check return check_verbose(obj, is_inlined_call).skipped File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch_dynamo\trace_rules.py", line 3361, in check_verbose rule = torch._dynamo.trace_rules.lookup_inner( File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch_dynamo\trace_rules.py", line 3442, in lookup_inner rule = get_torch_obj_rule_map().get(obj, None) File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch_dynamo\trace_rules.py", line 2782, in get_torch_obj_rule_map obj = load_object(k) File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch_dynamo\trace_rules.py", line 2811, in load_object val = _load_obj_from_str(x[0]) File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch_dynamo\trace_rules.py", line 2795, in _load_obj_from_str return getattr(importlib.import_module(module), obj_name) File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\importlib\init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nested_internal\nested_tensor.py", line 417, in values=torch.randn(3, 3, device="meta"), C:\Users\Rikkert\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nested_internal\nested_tensor.py:417: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:84.) values=torch.randn(3, 3, device="meta"), Fetching 10 files: 100%|███████████████████████████████████████████████████████████████████████| 10/10 [00:00<?, ?it/s] Traceback (most recent call last): File "D:\OmniGen\app.py", line 9, in pipe = OmniGenPipeline.from_pretrained( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\OmniGen\OmniGen\pipeline.py", line 82, in from_pretrained model = OmniGen.from_pretrained(model_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\OmniGen\OmniGen\model.py", line 197, in from_pretrained model = cls(config) ^^^^^^^^^^^ File "D:\OmniGen\OmniGen\model.py", line 180, in init__ self.register_buffer("pos_embed", torch.from_numpy(pos_embed).float().unsqueeze(0), persistent=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: Numpy is not available

Manda69-bit commented 5 hours ago

remove it and do numpy==1.26.3 If that wasn't the issue it is the different version of other modules , check requirement's file for tested versions.

rzoun commented 1 hour ago

Thanks so much for the fast reply! That did get me further. I ended up with a different error though. Then I tried installing all dependencies with: pip install -r requirements.txt

But the error remained. It says: NameError: name 'is_torch_npu_available' is not defined. Did you mean: 'is_torch_xla_available'?

I searched for solutions for that. Solved it using info in: https://github.com/VectorSpaceLab/OmniGen/issues/73

It works now, thanks!