VectorSpaceLab / OmniGen

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

How to deal with "Numpy is not available" #61

Open freemank1224 opened 2 weeks ago

freemank1224 commented 2 weeks ago

After following the installation instruction, when I am running the example file "inference.ipynb", it can successfully fetched the files (Fetching 10 files: 100%|██████████| 10/10 [00:00<00:00, 20097.29it/s]). BUT, then, it show some error message:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[6], [line 7](vscode-notebook-cell:?execution_count=6&line=7)
      [1](vscode-notebook-cell:?execution_count=6&line=1) # import os
      [2](vscode-notebook-cell:?execution_count=6&line=2) # os.environ['CUDA_VISIBLE_DEVICES'] = '0'  # select a gpu to run OmniGen
      [3](vscode-notebook-cell:?execution_count=6&line=3) # os.environ['HF_HUB_CACHE'] = 'path_to_save_downloaded_model'
      [5](vscode-notebook-cell:?execution_count=6&line=5) from OmniGen import OmniGenPipeline
----> [7](vscode-notebook-cell:?execution_count=6&line=7) pipe = OmniGenPipeline.from_pretrained("Shitao/OmniGen-v1")

File c:\Users\dyson\Documents\OmniGen\OmniGen\pipeline.py:82, in OmniGenPipeline.from_pretrained(cls, model_name, vae_path)
     [78](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/pipeline.py:78)     model_name = snapshot_download(repo_id=model_name,
     [79](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/pipeline.py:79)                                    cache_dir=cache_folder,
     [80](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/pipeline.py:80)                                    ignore_patterns=['flax_model.msgpack', 'rust_model.ot', 'tf_model.h5', 'model.pt'])
     [81](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/pipeline.py:81)     logger.info(f"Downloaded model to {model_name}")
---> [82](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/pipeline.py:82) model = OmniGen.from_pretrained(model_name)
     [83](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/pipeline.py:83) processor = OmniGenProcessor.from_pretrained(model_name)
     [85](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/pipeline.py:85) if os.path.exists(os.path.join(model_name, "vae")):

File c:\Users\dyson\Documents\OmniGen\OmniGen\model.py:197, in OmniGen.from_pretrained(cls, model_name)
    [193](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/model.py:193)     model_name = snapshot_download(repo_id=model_name,
    [194](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/model.py:194)                                    cache_dir=cache_folder,
    [195](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/model.py:195)                                    ignore_patterns=['flax_model.msgpack', 'rust_model.ot', 'tf_model.h5'])
    [196](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/model.py:196) config = Phi3Config.from_pretrained(model_name)
--> [197](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/model.py:197) model = cls(config)
    [198](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/model.py:198) if os.path.exists(os.path.join(model_name, 'model.safetensors')):
...
--> [180](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/model.py:180) self.register_buffer("pos_embed", torch.from_numpy(pos_embed).float().unsqueeze(0), persistent=True)
    [182](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/model.py:182) self.final_layer = FinalLayer(hidden_size, patch_size, self.out_channels)
    [184](file:///C:/Users/dyson/Documents/OmniGen/OmniGen/model.py:184) self.initialize_weights()

RuntimeError: Numpy is not available
staoxiao commented 1 week ago

That's a very strange issue. @freemank1224, did you check if the NumPy library is installed?

yuezewang commented 1 week ago

You can first try to confirm whether numpy is installed and used correctly in your environment, and tell us your numpy version (Perhaps there is already an incompatible version of numpy in your environment)

rzoun commented 1 week ago

I have a similar issue, when running 'python app.py', I get the same runtimeerror. I have numpy 2.1.2 installed in my environment. I tried downgrading to 1.10.0 and 1.3.0. Both did not work either.

freemank1224 commented 1 week ago

I have a similar issue, when running 'python app.py', I get the same runtimeerror. I have numpy 2.1.2 installed in my environment. I tried downgrading to 1.10.0 and 1.3.0. Both did not work either.

After deleting the original virtual env and recreate a new one, I have solved this issue.

freemank1224 commented 1 week ago

That's a very strange issue. @freemank1224, did you check if the NumPy library is installed?

After deleting the original virtual env and recreate a new one, I have solved this issue.

andresdelcampo commented 3 days ago

Similar error for me. It helped to run pip install numpy==1.24.1 which saw it uninstalled 2.1.3 and installed 1.24.1 then it worked.