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

Torch requirement makes installing mmdet impossible ias part of a package #238

Open
picagrad opened this issue Feb 29, 2024 · 4 comments
Open

Comments

@picagrad
Copy link

Hi all, I've recently installed mmdet in a project I'm working on.
This project needds to be packed up as a package so it can be used in other projects.

The problem is, in order to make it into a package, you have to provide a build script (I am doing mine with Poetry, but this idea would be true regardless of which approach to making a package I might be using). The problem there is that the installation instructions for mmdet require using openmim, but openmim requires torch, which is not available in most default environements from which the package will be installed. This leads to a failure when building the environement with the classic ModuleNotFoundError: No module named 'torch'.

To clarify, torch is a requirement of the package of course, and it will be installed as part of the installation of the package, but it cannot be installed BEFORE the package, since requirements needs to be resolved with other requirements.

Here's the full output:

poetry install
Warning: Found deprecated priority 'secondary' for source 'private' in pyproject.toml. Consider changing the priority to one of the non-deprecated values: 'default', 'primary', 'supplemental', 'explicit'.
Installing dependencies from lock file

No dependencies to install or update

Preparing build environment with build-system requirements poetry-core>=1.0.0, openmim>=0.1.1
Traceback (most recent call last):
  File "/local-scratch2/aharell/CFM-Task-Models/src/split_utils/miminstaller.py", line 9, in <module>
    install_mmdet()
  File "/local-scratch2/aharell/CFM-Task-Models/src/split_utils/miminstaller.py", line 4, in install_mmdet
    install('mmengine')
  File "/tmp/tmpu0ao7bdo/.venv/lib/python3.9/site-packages/mim/commands/install.py", line 128, in install
    install_args += ['-f', get_mmcv_full_find_link(mmcv_base_url)]
  File "/tmp/tmpu0ao7bdo/.venv/lib/python3.9/site-packages/mim/commands/install.py", line 165, in get_mmcv_full_find_link
    torch_v, cuda_v = get_torch_cuda_version()
  File "/tmp/tmpu0ao7bdo/.venv/lib/python3.9/site-packages/mim/utils/utils.py", line 340, in get_torch_cuda_version
    raise err
  File "/tmp/tmpu0ao7bdo/.venv/lib/python3.9/site-packages/mim/utils/utils.py", line 338, in get_torch_cuda_version
    import torch
ModuleNotFoundError: No module named 'torch'

In short, I think that there is an urgent need to either remove torch as a requirement for openmim or to provide instructions on how to install mmdet (and other similar packages like mmseg etc.) without relying on openmim

@VINURIRODRIGO
Copy link

I am encountering the same error. Could you let me know if you managed to fix the issue?

@borgarpa
Copy link

Same problem here...

@VINURIRODRIGO
Copy link

I managed to fix this issue by downgrading my Python version to 3.8.19

@borgarpa
Copy link

I managed to fix this issue by downgrading my Python version to 3.8.19

It didn't work for me.... Instead, I had to install PyTorch and chardet before running mim install mmcv-full:

conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch
conda install -c conda-forge chardet

That did the trick for me.

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

3 participants