salesforce / LAVIS

LAVIS - A One-stop Library for Language-Vision Intelligence
BSD 3-Clause "New" or "Revised" License
9.91k stars 972 forks source link

ImportError: numpy.core.multiarray failed to import #762

Open lvilaca16 opened 2 weeks ago

lvilaca16 commented 2 weeks ago

I am currently using salesforce-lavis to use BLIP-2. I am getting errors regarding incompatibilities between numpy and opencv. Despite multiple warnings, I updated both packages and it worked, thus I am listing this issue for registration purposes.

Current environment:

name: blip2
channels:
  - defaults
dependencies:
  - python=3.11
  - pip
  - pip:
    - salesforce-lavis

It installs the following versions:

changliu98 commented 2 weeks ago

Sams issue with Python 3.9.20 and numpy 2.0.2. I solved it by use Conda to create a Python 3.11 env with pip installed numpy 2.1.2, pip installed salesforce-lavis==1.0.2 and conda installed opencv, which should be 4.10.0 without specifying version number UPDATE when run models still got runtime error due to numpy or opencv

xyling2023 commented 1 week ago

Sams issue with Python 3.9.20 and numpy 2.0.2. I solved it by use Conda to create a Python 3.11 env with pip installed numpy 2.1.2, pip installed salesforce-lavis==1.0.2 and conda installed opencv, which should be 4.10.0 without specifying version number

I encountered the same issue. Following your method for installation:

conda create -n lavis python=3.11
conda activate lavis
pip install numpy==2.1.2
pip install salesforce-lavis==1.0.2
conda install opencv

Then, using from lavis.models import model_zoo raises an error indicating that some packages are missing. I installed the following packages: pip install torchaudio moviepy peft easydict diffusers

However, when I continue using from lavis.models import model_zoo, I still get the error:

RuntimeError: Failed to import diffusers.models.autoencoders.autoencoder_kl because of the following error (look up to see its traceback):
Failed to import diffusers.schedulers.scheduling_dpmsolver_multistep because of the following error (look up to see its traceback):
maximum recursion depth exceeded

Have you encountered such a problem? Thank you for your help!

changliu98 commented 1 week ago
Only installs, but sill have runtime error When you run ``` pip install salesforce-lavis==1.0.2 ``` pip will uninstall numpy then install `numpy 2.0.2` for you, just run `pip install numpy==2.1.2` and install 2.1.2 ignoring the dependency error, I tested on my machine and it works (though i think the they need to update the dependencies). My steps is listed here: ``` conda create -n lavis python=3.11 conda activate lavis pip install salesforce-lavis==1.0.2 pip install numpy==2.1.2 conda install opencv ``` and ``` Python 3.11.10 (main, Oct 3 2024, 07:29:13) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from lavis.models import model_zoo /home/hello/anaconda3/envs/lavis/lib/python3.11/site-packages/fairscale/experimental/nn/offload.py:19: FutureWarning: `torch.cuda.amp.custom_fwd(args...)` is deprecated. Please use `torch.amp.custom_fwd(args..., device_type='cuda')` instead. return torch.cuda.amp.custom_fwd(orig_func) # type: ignore /home/hello/anaconda3/envs/lavis/lib/python3.11/site-packages/fairscale/experimental/nn/offload.py:30: FutureWarning: `torch.cuda.amp.custom_bwd(args...)` is deprecated. Please use `torch.amp.custom_bwd(args..., device_type='cuda')` instead. return torch.cuda.amp.custom_bwd(orig_func) # type: ignore >>> ```

When generates output still outputs runtime error due to incompatible numpy ver

xyling2023 commented 1 week ago

Only installs, but sill have runtime error When generates output still outputs runtime error due to incompatible numpy ver

To resolve version compatibility issues between diffusers and huggingface_hub, as well as between numpy and lavis, I applied the following fixes, and now the demo runs successfully:

pip install diffusers==0.16.0
pip install huggingface_hub==0.24.6
pip install spacy==3.6.0
pip install numpy==1.24.0
cqray1990 commented 1 day ago

Only installs, but sill have runtime error When generates output still outputs runtime error due to incompatible numpy ver

To resolve version compatibility issues between diffusers and huggingface_hub, as well as between numpy and lavis, I applied the following fixes, and now the demo runs successfully:

pip install diffusers==0.16.0
pip install huggingface_hub==0.24.6
pip install spacy==3.6.0
pip install numpy==1.24.0

where mode zoo models can be downloaded?

fgy624 commented 22 hours ago

You can try to install opencv-python! I solve this problem by doing this pip install opencv-python