open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.23k stars 9.4k forks source link

Always have a bug when installing mmdet3.1.0 #10665

Open christiano12345 opened 1 year ago

christiano12345 commented 1 year ago

I followed the steps by https://mmdetection.readthedocs.io/en/latest/get_started.html to install mmdet3.1.0 using "pip install -v -e ." but always have the error shows "No module named torch", see below. My PyTorch version is 1.12.1+cu113, and mmsegmentation is successfully installed without problems. Really appreciate your help!

1

hhaAndroid commented 1 year ago

@christiano12345 I tried it and there was no issue, can you please try it again?

MZHI commented 1 year ago

Has the same error. Trying to install mmdetection version==2.28.2. Early I have already installed this version under virtual environment, but cannot repeat.

pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
pip install -U openmim==0.3.6
mim install mmcv==1.7.1
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
git checkout tags/v2.28.2
pip install -v -e .

Got the error:

Obtaining file:///home/mzhi/proj_src/frameworks/mmdetection
  Running command pip subprocess to install build dependencies
  Collecting setuptools>=40.8.0
    Obtaining dependency information for setuptools>=40.8.0 from https://files.pythonhosted.org/packages/c7/42/be1c7bbdd83e1bfb160c94b9cafd8e25efc7400346cf7ccdbdb452c467fa/setuptools-68.0.0-py3-none-any.whl.metadata
    Using cached setuptools-68.0.0-py3-none-any.whl.metadata (6.4 kB)
  Collecting wheel
    Obtaining dependency information for wheel from https://files.pythonhosted.org/packages/17/11/f139e25018ea2218aeedbedcf85cd0dd8abeed29a38ac1fda7f5a8889382/wheel-0.41.0-py3-none-any.whl.metadata
    Using cached wheel-0.41.0-py3-none-any.whl.metadata (2.2 kB)
  Using cached setuptools-68.0.0-py3-none-any.whl (804 kB)
  Using cached wheel-0.41.0-py3-none-any.whl (64 kB)
  Installing collected packages: wheel, setuptools
  Successfully installed setuptools-68.0.0 wheel-0.41.0
  Installing build dependencies ... done
  Running command Checking if build backend supports build_editable
  Checking if build backend supports build_editable ... done
  Running command Getting requirements to build editable
  Traceback (most recent call last):
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
      return hook(config_settings)
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 450, in get_requires_for_build_editable
      return self.get_requires_for_build_wheel(config_settings)
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
      exec(code, locals())
    File "<string>", line 11, in <module>
  ModuleNotFoundError: No module named 'torch'
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/mzhi/.venv/env_test/bin/python3 /home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py get_requires_for_build_editable /tmp/tmpv20uzxgb
  cwd: /home/mzhi/proj_src/frameworks/mmdetection
  Getting requirements to build editable ... error
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
MZHI commented 1 year ago

Has the same error. Trying to install mmdetection version==2.28.2. Early I have already installed this version under virtual environment, but cannot repeat.

pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
pip install -U openmim==0.3.6
mim install mmcv==1.7.1
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
git checkout tags/v2.28.2
pip install -v -e .

Got the error:

Obtaining file:///home/mzhi/proj_src/frameworks/mmdetection
  Running command pip subprocess to install build dependencies
  Collecting setuptools>=40.8.0
    Obtaining dependency information for setuptools>=40.8.0 from https://files.pythonhosted.org/packages/c7/42/be1c7bbdd83e1bfb160c94b9cafd8e25efc7400346cf7ccdbdb452c467fa/setuptools-68.0.0-py3-none-any.whl.metadata
    Using cached setuptools-68.0.0-py3-none-any.whl.metadata (6.4 kB)
  Collecting wheel
    Obtaining dependency information for wheel from https://files.pythonhosted.org/packages/17/11/f139e25018ea2218aeedbedcf85cd0dd8abeed29a38ac1fda7f5a8889382/wheel-0.41.0-py3-none-any.whl.metadata
    Using cached wheel-0.41.0-py3-none-any.whl.metadata (2.2 kB)
  Using cached setuptools-68.0.0-py3-none-any.whl (804 kB)
  Using cached wheel-0.41.0-py3-none-any.whl (64 kB)
  Installing collected packages: wheel, setuptools
  Successfully installed setuptools-68.0.0 wheel-0.41.0
  Installing build dependencies ... done
  Running command Checking if build backend supports build_editable
  Checking if build backend supports build_editable ... done
  Running command Getting requirements to build editable
  Traceback (most recent call last):
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
      return hook(config_settings)
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 450, in get_requires_for_build_editable
      return self.get_requires_for_build_wheel(config_settings)
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
      exec(code, locals())
    File "<string>", line 11, in <module>
  ModuleNotFoundError: No module named 'torch'
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/mzhi/.venv/env_test/bin/python3 /home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py get_requires_for_build_editable /tmp/tmpv20uzxgb
  cwd: /home/mzhi/proj_src/frameworks/mmdetection
  Getting requirements to build editable ... error
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

But I still can install mmdet using mim install mmdet=2.28.2

54wb commented 1 year ago

Has the same error. Trying to install mmdetection version==2.28.2. Early I have already installed this version under virtual environment, but cannot repeat.

pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
pip install -U openmim==0.3.6
mim install mmcv==1.7.1
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
git checkout tags/v2.28.2
pip install -v -e .

Got the error:

Obtaining file:///home/mzhi/proj_src/frameworks/mmdetection
  Running command pip subprocess to install build dependencies
  Collecting setuptools>=40.8.0
    Obtaining dependency information for setuptools>=40.8.0 from https://files.pythonhosted.org/packages/c7/42/be1c7bbdd83e1bfb160c94b9cafd8e25efc7400346cf7ccdbdb452c467fa/setuptools-68.0.0-py3-none-any.whl.metadata
    Using cached setuptools-68.0.0-py3-none-any.whl.metadata (6.4 kB)
  Collecting wheel
    Obtaining dependency information for wheel from https://files.pythonhosted.org/packages/17/11/f139e25018ea2218aeedbedcf85cd0dd8abeed29a38ac1fda7f5a8889382/wheel-0.41.0-py3-none-any.whl.metadata
    Using cached wheel-0.41.0-py3-none-any.whl.metadata (2.2 kB)
  Using cached setuptools-68.0.0-py3-none-any.whl (804 kB)
  Using cached wheel-0.41.0-py3-none-any.whl (64 kB)
  Installing collected packages: wheel, setuptools
  Successfully installed setuptools-68.0.0 wheel-0.41.0
  Installing build dependencies ... done
  Running command Checking if build backend supports build_editable
  Checking if build backend supports build_editable ... done
  Running command Getting requirements to build editable
  Traceback (most recent call last):
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
      return hook(config_settings)
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 450, in get_requires_for_build_editable
      return self.get_requires_for_build_wheel(config_settings)
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
      exec(code, locals())
    File "<string>", line 11, in <module>
  ModuleNotFoundError: No module named 'torch'
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/mzhi/.venv/env_test/bin/python3 /home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py get_requires_for_build_editable /tmp/tmpv20uzxgb
  cwd: /home/mzhi/proj_src/frameworks/mmdetection
  Getting requirements to build editable ... error
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

But I still can install mmdet using mim install mmdet=2.28.2 hi~, i have same error, do you solve this error? I need change some codes for mmdet, so I can't install mmdet directly

christiano12345 commented 1 year ago

I believe there must be some compatibility issues between PyTorch version and MMDet version...

MZHI commented 1 year ago

Has the same error. Trying to install mmdetection version==2.28.2. Early I have already installed this version under virtual environment, but cannot repeat.

pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
pip install -U openmim==0.3.6
mim install mmcv==1.7.1
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
git checkout tags/v2.28.2
pip install -v -e .

Got the error:

Obtaining file:///home/mzhi/proj_src/frameworks/mmdetection
  Running command pip subprocess to install build dependencies
  Collecting setuptools>=40.8.0
    Obtaining dependency information for setuptools>=40.8.0 from https://files.pythonhosted.org/packages/c7/42/be1c7bbdd83e1bfb160c94b9cafd8e25efc7400346cf7ccdbdb452c467fa/setuptools-68.0.0-py3-none-any.whl.metadata
    Using cached setuptools-68.0.0-py3-none-any.whl.metadata (6.4 kB)
  Collecting wheel
    Obtaining dependency information for wheel from https://files.pythonhosted.org/packages/17/11/f139e25018ea2218aeedbedcf85cd0dd8abeed29a38ac1fda7f5a8889382/wheel-0.41.0-py3-none-any.whl.metadata
    Using cached wheel-0.41.0-py3-none-any.whl.metadata (2.2 kB)
  Using cached setuptools-68.0.0-py3-none-any.whl (804 kB)
  Using cached wheel-0.41.0-py3-none-any.whl (64 kB)
  Installing collected packages: wheel, setuptools
  Successfully installed setuptools-68.0.0 wheel-0.41.0
  Installing build dependencies ... done
  Running command Checking if build backend supports build_editable
  Checking if build backend supports build_editable ... done
  Running command Getting requirements to build editable
  Traceback (most recent call last):
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
      return hook(config_settings)
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 450, in get_requires_for_build_editable
      return self.get_requires_for_build_wheel(config_settings)
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/tmp/pip-build-env-hfpo43b2/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
      exec(code, locals())
    File "<string>", line 11, in <module>
  ModuleNotFoundError: No module named 'torch'
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/mzhi/.venv/env_test/bin/python3 /home/mzhi/.venv/env_test/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py get_requires_for_build_editable /tmp/tmpv20uzxgb
  cwd: /home/mzhi/proj_src/frameworks/mmdetection
  Getting requirements to build editable ... error
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

But I still can install mmdet using mim install mmdet=2.28.2 hi~, i have same error, do you solve this error? I need change some codes for mmdet, so I can't install mmdet directly

Yes. I think, I was confused in packages versions.

My working pipeline: 1) install nvidia drivers

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install -y ubuntu-drivers-common
sudo apt install -y nvidia-driver-535
sudo reboot

2) install CUDA toolkit 11.7

wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda_11.7.0_515.43.04_linux.run
chmod +x cuda_11.7.0_515.43.04_linux.run
sudo ./cuda_11.7.0_515.43.04_linux.run
echo 'export PATH=/usr/local/cuda/bin:$PATH\nexport LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc

3) install and activate virtual environment

sudo apt install python3.10-dev
sudo apt install python3.10-venv
python3 -m venv env_test

4) Install pytorch pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116

5) Install openmim and mmlab packages

pip install -U openmim==0.3.6
mim install mmcv-full==1.7.1
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
git checkout tags/v2.28.2
pip install -v -e .
yutakawabe-sss commented 11 months ago

I had the same problem. For me, this was pip or setuptools problem, build isolation may have been happend.

Work around is, install wheel. This works for me.

pip install wheel
pip install -e .

When wheel is installed, setup.py develop is called, and build isolation will not be happened.

When the wheel package is not installed, pip now uses the default build backend instead of setup.py install and setup.py develop for project without pyproject.toml. (#8559)

https://pip.pypa.io/en/stable/news/#v23-1

stbnps commented 11 months ago

I had the same problem. For me, this was pip or setuptools problem, build isolation may have been happend.

Work around is, install wheel. This works for me.

pip install wheel
pip install -e .

When wheel is installed, setup.py develop is called, and build isolation will not be happened.

When the wheel package is not installed, pip now uses the default build backend instead of setup.py install and setup.py develop for project without pyproject.toml. (#8559) https://pip.pypa.io/en/stable/news/#v23-1

This solved it for me

edwardwterry commented 9 months ago

Me too. I was using mmdet==v3.2.0 and following the default installation instructions.

PoTsui99 commented 7 months ago

I had the same problem. For me, this was pip or setuptools problem, build isolation may have been happend.

Work around is, install wheel. This works for me.

pip install wheel
pip install -e .

When wheel is installed, setup.py develop is called, and build isolation will not be happened.

When the wheel package is not installed, pip now uses the default build backend instead of setup.py install and setup.py develop for project without pyproject.toml. (#8559) https://pip.pypa.io/en/stable/news/#v23-1

Awesome! This solution also works for me.