Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import error - libopencv_impgproc missing #346

Open
GooseIt opened this issue Aug 18, 2023 · 9 comments
Open

Import error - libopencv_impgproc missing #346

GooseIt opened this issue Aug 18, 2023 · 9 comments

Comments

@GooseIt
Copy link

GooseIt commented Aug 18, 2023

I've installed ffcv library and I get the following error on line import ffcv:


  import ffcv
File "/home/vlad/anaconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/__init__.py", line 1, in <module>
  from .loader import Loader
File "/home/vlad/anaconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/loader/__init__.py", line 1, in <module>
  from .loader import Loader, OrderOption
File "/home/vlad/anaconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/loader/loader.py", line 14, in <module>
  from ffcv.fields.base import Field
File "/home/vlad/anaconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/fields/__init__.py", line 1, in <module>
  from .base import Field
File "/home/vlad/anaconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/fields/base.py", line 6, in <module>
  from ..pipeline.operation import Operation
File "/home/vlad/anaconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/pipeline/__init__.py", line 2, in <module>
  from .pipeline_spec import PipelineSpec
File "/home/vlad/anaconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/pipeline/pipeline_spec.py", line 5, in <module>
  from ..transforms.module import ModuleWrapper
File "/home/vlad/anaconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/transforms/__init__.py", line 5, in <module>
  from .random_resized_crop import RandomResizedCrop
File "/home/vlad/anaconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/transforms/random_resized_crop.py", line 5, in <module>
  from .utils import fast_crop
File "/home/vlad/anaconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/transforms/utils/fast_crop.py", line 4, in <module>
  from ...libffcv import ctypes_resize
File "/home/vlad/anaconda3/envs/ffcv/lib/python3.9/site-packages/ffcv/libffcv.py", line 6, in <module>
  import ffcv._libffcv
ImportError: libopencv_imgproc.so.408: cannot open shared object file: No such file or directory

I've tried running conda remove opencv && conda install opencv and pip install -U ffcv.

I've also tried solutions suggested here - #329 (comment).

Nothing changed. Please help fixing the issue.

It seems there was an issue like mine - #136. However, it was solved by Slack in February 2022, and ffcv Slack server does not hold messages more than 90 days of age. If you know which solution worked there, I'm happy to hear it.

@andrewilyas
Copy link
Contributor

Hi @GooseIt ! Can you try instaling opencv 4.5.2 instead of the latest version?

@SerezD
Copy link

SerezD commented Jan 31, 2024

Hi there,

@GooseIt did you manage to solve the issue?

I was able to solve it by installing numba==0.56.2.

Here is my full environment.yaml file:

name: torch-ffcv
channels:
  - pytorch
  - nvidia
  - conda-forge
dependencies:
  - pytorch
  - torchvision
  - torchaudio
  - pytorch-cuda==12.1
  - cupy
  - pkg-config
  - libjpeg-turbo>=2.1.4
  - opencv
  - numba==0.56.2
  - pip
  - pip:
      - tqdm
      - ffcv

@andrewilyas I also tried with opencv==4.5.2 but it did not work. Do you have any clues on what is causing the error ?

Thank you

@richardrl
Copy link

I am running into this issue today with latest build:
ImportError: libopencv_imgproc.so.407: cannot open shared object file: No such file or directory

@arnaghosh
Copy link

I am running into this issue as well.
Degrading opencv or numba versions did not help solve the issue.
Side note: Degrading numba to 0.56.2 also degraded pytorch version to 1.12. Does that happen to you as well @SerezD?

Any suggestions for fix @andrewilyas?
Thanks in advance.

@SerezD
Copy link

SerezD commented May 16, 2024

Degrading opencv or numba versions did not help solve the issue. Side note: Degrading numba to 0.56.2 also degraded pytorch version to 1.12. Does that happen to you as well @SerezD?

Hi @arnaghosh. No, it does not happen in my case.
Note that I install the previously posted environment from conda as:

conda env create -f environment.yaml

using libmamba for faster solving: https://www.anaconda.com/blog/a-faster-conda-for-a-growing-community

I tried installing the environment on different machines and it always worked for me. Unfortunately, I still have no idea about the cause of the error, so I can't help on that.

@arnaghosh
Copy link

Hi @SerezD,

Thank you so much. Can I ask you which pytorch version you are using?
I was hoping to use pytorch 2.1.2. Just wondering if the pytorch version conflicts with the numba version.

@SerezD
Copy link

SerezD commented May 16, 2024

Hi @SerezD,

Thank you so much. Can I ask you which pytorch version you are using? I was hoping to use pytorch 2.1.2. Just wondering if the pytorch version conflicts with the numba version.

Without further indications in the environment file, it will attempt to install the latest version of pytorch. For example, in one of my local environments it installed pytorch 2.2.0 and numba 0.56.2.

@arnaghosh
Copy link

Thanks again @SerezD.
I tried installing my env from scratch, and this time it did not degrade pytorch (as you predicted). However, importing ffcv still doesn't work, i.e. I still get the same error:
ImportError: libopencv_imgproc.so.407: cannot open shared object file: No such file or directory

@arnaghosh
Copy link

arnaghosh commented May 16, 2024

Update: The solution proposed by @SerezD worked for me! 🎉 Thanks a lot!
I was using a cached version of ffcv. Using pip install ffcv --no-cache-dir in worked! :)

These are the steps that worked for me, in case anyone else finds this list helpful:

conda create --prefix <env_location>/<env_name> -y python=3.9 conda conda-libmamba-solver -c conda-forge
conda activate <env_location>/<env_name>

export CONDA_EXE="$(hash -r; which conda)"
conda config --set solver libmamba
conda config --set channel_priority flexible

conda install -y cupy pkg-config compilers libjpeg-turbo opencv pytorch=2.1.2 torchvision=0.16.2 pytorch-cuda=12.1 torchmetrics numba=0.56.2 terminaltables matplotlib scikit-learn pandas assertpy pytz -c pytorch -c nvidia -c conda-forge

pip install ffcv --no-cache-dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants