diso icon indicating copy to clipboard operation
diso copied to clipboard

ModuleNotFoundError: No module named 'torch'

Open wgqkill opened this issue 11 months ago • 9 comments

I have installed torch, but it says it can't be found.

Traceback (most recent call last): File "G:\Python311\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in main() File "G:\Python311\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\Python311\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 118, in get_requires_for_build_wheel return hook(config_settings) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-1o2bwyef\overlay\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'torch'

1 (1)

wgqkill avatar Jan 02 '25 10:01 wgqkill

I got the same issue. I also have torch installed. OOOH. I think this only runs on NVIDIA cards.

jnolck avatar Jan 06 '25 04:01 jnolck

I have the same issue. Running the correct version of torch for the cuda version (12.6). Fedora 31. I have torch, torchaudio, and torchvision installed with pip. Exact same error as wgqkill.

Lincoln504 avatar Mar 26 '25 19:03 Lincoln504

Would running pip install diso --no-build-isolation produce a different effect? In some projects that use this library people say this helps them resolve the issue. Though it doesn't work in my case, perhaps it could be a useful piece of the puzzle.

ralienpp avatar Mar 27 '25 12:03 ralienpp

I am not exactly sure but seeing 'pyproject_hooks_in_process_in_process' in the error stack, this highly suggests this is due to the pyproject.toml stuff and PEP 517. In older setup.py scripts, the build is default to be in the current environment, but if new pip versions have enforced PEP 517 it is going to build in an isolated environment.

Unfortunately, the hatching build system that the PYPA is recommending now does really poorly on building CUDA extensions alongside python code. As a workaround I think pip install diso --no-build-isolation proposed by @ralienpp should work. You could also try pip install diso --no-build-isolation --no-use-pep517, while we look at what we can do to make CUDA builds aware of the local GPU type while still keeping the package supported by PEP 517.

eliphatfs avatar Apr 30 '25 22:04 eliphatfs

I have installed torch, but it says it can't be found.

Traceback (most recent call last): File "G:\Python311\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in main() File "G:\Python311\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\Python311\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 118, in get_requires_for_build_wheel return hook(config_settings) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-1o2bwyef\overlay\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'torch'

1 (1)

Hi, I encountered the same issue, have you solved this? Thanks.

zjudzl avatar May 28 '25 02:05 zjudzl

@zjudzl Please read my last comment https://github.com/SarahWeiii/diso/issues/14#issuecomment-2843467623

eliphatfs avatar May 28 '25 22:05 eliphatfs

This still produces an error in python3.11 or python 3.12:


pip install diso --no-build-isolation --no-use-pep517
Collecting diso
  Downloading diso-0.1.4.tar.gz (24 kB)
  Preparing metadata (setup.py) ... done
Collecting trimesh (from diso)
  Using cached trimesh-4.6.12-py3-none-any.whl.metadata (18 kB)
Requirement already satisfied: numpy>=1.20 in c:\users\\appdata\roaming\python\python311\site-packages (from trimesh->diso) (2.3.1)
Using cached trimesh-4.6.12-py3-none-any.whl (711 kB)
Building wheels for collected packages: diso
  DEPRECATION: Building 'diso' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'diso'. Discussion can be found at https://github.com/pypa/pip/issues/6334
  Building wheel for diso (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      sources: ['src\\pybind.cpp']
      usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: setup.py --help [cmd1 cmd2 ...]
         or: setup.py --help-commands
         or: setup.py cmd --help

      error: invalid command 'bdist_wheel'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for diso
  Running setup.py clean for diso
Failed to build diso
ERROR: Failed to build installable wheels for some pyproject.toml based projects (diso)

Edit: running pip install wheel fixed this, then had to install Microsoft Visual C++ via the Visual studio installer. Then install Cuda separately the running pip install diso --no-build-isolation

diegomoise1 avatar Jun 21 '25 14:06 diegomoise1

This still produces an error in python3.11 or python 3.12:


pip install diso --no-build-isolation --no-use-pep517
Collecting diso
  Downloading diso-0.1.4.tar.gz (24 kB)
  Preparing metadata (setup.py) ... done
Collecting trimesh (from diso)
  Using cached trimesh-4.6.12-py3-none-any.whl.metadata (18 kB)
Requirement already satisfied: numpy>=1.20 in c:\users\\appdata\roaming\python\python311\site-packages (from trimesh->diso) (2.3.1)
Using cached trimesh-4.6.12-py3-none-any.whl (711 kB)
Building wheels for collected packages: diso
  DEPRECATION: Building 'diso' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'diso'. Discussion can be found at https://github.com/pypa/pip/issues/6334
  Building wheel for diso (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      sources: ['src\\pybind.cpp']
      usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: setup.py --help [cmd1 cmd2 ...]
         or: setup.py --help-commands
         or: setup.py cmd --help

      error: invalid command 'bdist_wheel'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for diso
  Running setup.py clean for diso
Failed to build diso
ERROR: Failed to build installable wheels for some pyproject.toml based projects (diso)

Edit: running pip install wheel fixed this, then had to install Microsoft Visual C++ via the Visual studio installer. Then install Cuda separately the running pip install diso --no-build-isolation

This is another error; I don't reproduce on locally but I think you need to 'pip install wheel'.

eliphatfs avatar Jun 21 '25 16:06 eliphatfs

Sorry didn't see your last sentence. I am glad you have fixed it. It is required to have CUDA development kit installed separately on the machine (any torch CUDA extension would require that) and this is beyond our scope of this package.

eliphatfs avatar Jun 21 '25 16:06 eliphatfs