facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.81k stars 1.32k forks source link

Installation error under LINUX #1831

Open Razbolt opened 4 months ago

Razbolt commented 4 months ago

Hi guys, I am trying to install PyTorch3d; however, I received an error that prevented me from understanding the reasoning. I shared the logs in the attached image. Basically, I'm trying to follow the codes, and it gives me an error like No module named 'torch', which I uploaded already. I wonder if I am the only one who had the error under the Linux system.

I hope the question is clear.

Screenshot 2024-07-08 at 18 13 36
bottler commented 4 months ago

PyTorch is not installed in the environment in which you are installing pytorch3d. Can you share exactly the sequence of commands you are running?

Dead-Hand commented 4 months ago

I encountered the same issue a few minutes ago. Running python3.12 in a virtual environment with the following torch libraries installed (verified via pip list):

I then follow the instructions provided in the INSTALL.md for this repo. Specifically the following: git clone https://github.com/facebookresearch/pytorch3d.git && cd pytorch3d && pip install -e .

At which point I encounter the exact same issue as @Razbolt shows in his screenshot above.

So the "problem" for me was that I was doing this in python 3.12, and python 3.12 is not supported by pytorch3d yet. Just pointing this out in case someone else gets this issue and is trying to debug.

bottler commented 4 months ago

@Dead-Hand This is surprising. Python 3.12 should be fine. You should be able to run python -c "import torch" successfully before the pytorch3d install, and you then shouldn't get a "no module named torch" error from pytorch3d.

ColinKohler commented 4 months ago

Having the same issue as @Dead-Hand but on python 3.10 in a virtual env.

Can run python -c "import torch" successfully but get the same error as @Razbolt when attempting to install via pip install -e .

Happy to provide more information if it helps!

bottler commented 4 months ago

Could it be the wrong pip? Can you try python -m pip install -e . instead of pip install -e .?

ColinKohler commented 4 months ago

Its def. related to pip in some manner. python -m pip install -e . throws the same error but compiling manually w/o pip seems to work, i.e. python setup.py install.

Ryuukeisyou commented 4 months ago

Same here. Only python setup.py install work. I am using wsl and I also have to mannually set MAX_JOBS otherwise the compiler will be killed.

nbubis commented 2 months ago

Same issue here on Ubuntu 24.04. Install works with python 3.8 in clean virtual environment:

$ python3.8 -m venv .venv
$ source .venv/bin/activate
$ pip install torch==2.3.1
$ pip install "git+https://github.com/facebookresearch/pytorch3d.git@stable"

However, creating a new virtual environment with python 3.12 or 3.11 and running the same install leads to:

$ python3.11 -m venv .venv
$ source .venv/bin/activate
$ pip install torch==2.3.1
$ pip install "git+https://github.com/facebookresearch/pytorch3d.git@stable"

Collecting git+https://github.com/facebookresearch/pytorch3d.git@stable
  Cloning https://github.com/facebookresearch/pytorch3d.git (to revision stable) to /tmp/pip-req-build-zrn2yvub
  Running command git clone --filter=blob:none --quiet https://github.com/facebookresearch/pytorch3d.git /tmp/pip-req-build-zrn2yvub
  Running command git checkout -q 89653419d0973396f3eff1a381ba09a07fffc2ed
  Resolved https://github.com/facebookresearch/pytorch3d.git to commit 89653419d0973396f3eff1a381ba09a07fffc2ed
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "/tmp/test_pytorch3d/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/tmp/test_pytorch3d/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/test_pytorch3d/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-ntt0l37_/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-ntt0l37_/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-ntt0l37_/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 503, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-ntt0l37_/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 318, in run_setup
          exec(code, locals())
        File "<string>", line 15, in <module>
      ModuleNotFoundError: No module named 'torch'
      [end of output]

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

× Getting requirements to build wheel 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.

Needless to say, import torch works just fine.