saidwivedi / POCO

[3DV 2024] POCO: 3D Pose and Shape Estimation using Confidence
https://poco.is.tue.mpg.de
Other
58 stars 2 forks source link

[SOLVED] Broken installation due to (1) hanging conda command and (2) wrong OpenCV version #6

Open mcarletti opened 1 month ago

mcarletti commented 1 month ago

I had a few problems during the installation steps, specifically:

  1. ā³ First conda command hangs indefinitely due to impossibility to solve CUDA Toolkit references.
  2. šŸ„„ It's not possible to import cv2 module due to version mismatching. This prevents to run the demo.

I've solved each issue as following. Hope this helps. Cheers!


ā³ CUDA Toolkit installation hangs indefinitely The command conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge does hang indefinitely.

Fix 1 (naive solution) I removed the cudatoolkit=11.1 -c conda-forge part to let Pytorch install the requirements by itself.

Fix 2 (edit, as suggested here)
Avoid a direct reference to cudatoolkit by using a combined Pytorch+CUDA versioning: pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html


šŸ„„ OpenCV broken version

I wasn't able to run the demo, due to a broken cv2 import. This is the error:

Error processing line 1 of /home/marco/anaconda3/envs/poco/lib/python3.8/site-packages/distutils-precedence.pth:

  Traceback (most recent call last):
    File "/home/marco/anaconda3/envs/poco/lib/python3.8/site.py", line 177, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
  ModuleNotFoundError: No module named '_distutils_hack'

Remainder of file ignored
Traceback (most recent call last):
  File "demo.py", line 21, in <module>
    import cv2
  File "/home/marco/anaconda3/envs/poco/lib/python3.8/site-packages/cv2/__init__.py", line 190, in <module>
    bootstrap()
  File "/home/marco/anaconda3/envs/poco/lib/python3.8/site-packages/cv2/__init__.py", line 184, in bootstrap
    if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
  File "/home/marco/anaconda3/envs/poco/lib/python3.8/site-packages/cv2/__init__.py", line 37, in __load_extra_py_code_for_module
    py_module = importlib.import_module(module_name)
  File "/home/marco/anaconda3/envs/poco/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/marco/anaconda3/envs/poco/lib/python3.8/site-packages/cv2/typing/__init__.py", line 171, in <module>
    LayerId = cv2.dnn.DictValue
AttributeError: module 'cv2.dnn' has no attribute 'DictValue'

Fix
As mentioned in this issue, changing opencv-python version to opencv-python==4.8.0.74 fixed the problem.

saidwivedi commented 3 weeks ago

Thank you your interest :)

  1. If for some reason, conda indefinitely hangs for you, I would not recommend removing cudatoolkit=11.1 -c conda-forge, since it might install pytorch for different CUDA version. Instead, I would run this:

    pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
  2. As mentioned in the requirements.txt (see here), did you install the 4.5.5.64 version of opencv-python?

mcarletti commented 3 weeks ago

First of all, thanks for the hint on Pytorch+CUDA šŸ‘šŸ¼

I tried creating the enviroment a second time, however the process needs a little help because of the following issues:

  1. The installation of the required modules via requirements.txt updates Pytorch to 2.4.0+cu121. To fix this and keep 1.8.0+cu111, I need to re-run the updated conda command you mentioned, that is after pip. To me, this issue suggests untracked incompatibilities among the packages.

  2. Regarding opencv-python, I succesfully installed the correct module via the requirements file, and I confirm the version is the one written in the file, that is 4.5.5.64. This is the output of pip freeze | grep opencv:

Error processing line 1 of /home/marco/anaconda3/envs/poco2/lib/python3.8/site-packages/distutils-precedence.pth:

  Traceback (most recent call last):
    File "/home/marco/anaconda3/envs/poco2/lib/python3.8/site.py", line 177, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
  ModuleNotFoundError: No module named '_distutils_hack'

Remainder of file ignored
opencv-python==4.5.5.64
opencv-python-headless==4.10.0.84

As you can read, there is something weird happening when accessing the environment.

  1. The above error related to distutils appears every time I open a Python terminal in this "fixed" environment.

Despite the right version of the modules, the error mentioned in my initial message is still there and I'm not able to run your code, even after following your Pytorch+CUDA fix and (1) forcing the version of Pytorch šŸ¤·šŸ¼

As of now, updating Pytorch and CUDA to 2.4.0+cu121 and OpenCV to 4.8.0.74 solved the installation, at least for the demo script.