masadcv / FastGeodis

Fast Implementation of Generalised Geodesic Distance Transform for CPU (OpenMP) and GPU (CUDA)
https://fastgeodis.readthedocs.io
BSD 3-Clause "New" or "Revised" License
91 stars 14 forks source link

[BUG] install error with CUDA 11.6 #17

Closed jacobmerson closed 2 years ago

jacobmerson commented 2 years ago

Describe the bug Attempting to install on linux machine with cuda 11.6 is giving pytorch mismatch error

To Reproduce

$ pip install torch --pre --extra-index-url https://download.pytorch.org/whl/nightly/cu116 
$ cd FastGeodis
$ pip install -e .
Obtaining file:///lore/mersoj/FastGeodis
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Installing collected packages: FastGeodis
  Running setup.py develop for FastGeodis
    ERROR: Command errored out with exit status 1:
     command: /lore/mersoj/geodis/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/lore/mersoj/FastGeodis/setup.py'"'"'; __file__='"'"'/lore/mersoj/FastGeodis/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: /lore/mersoj/FastGeodis/
    Complete output (56 lines):
    setup.py with torch 1.12.0+cu102
    BUILD_CPP=True, BUILD_CUDA=True, TORCH_VERSION=11200.
    running develop
    /tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    /tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    running egg_info
    writing FastGeodis.egg-info/PKG-INFO
    writing dependency_links to FastGeodis.egg-info/dependency_links.txt
    writing top-level names to FastGeodis.egg-info/top_level.txt
    /tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/torch/utils/cpp_extension.py:411: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
      warnings.warn(msg.format('we could not find ninja.'))
    reading manifest file 'FastGeodis.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    adding license file 'LICENSE'
    writing manifest file 'FastGeodis.egg-info/SOURCES.txt'
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/lore/mersoj/FastGeodis/setup.py", line 123, in <module>
        setup(
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 87, in setup
        return distutils.core.setup(**attrs)
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 177, in setup
        return run_commands(dist)
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 193, in run_commands
        dist.run_commands()
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
        self.run_command(cmd)
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1217, in run_command
        super().run_command(command)
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/command/develop.py", line 34, in run
        self.install_for_development()
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/command/develop.py", line 114, in install_for_development
        self.run_command('build_ext')
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 317, in run_command
        self.distribution.run_command(command)
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1217, in run_command
        super().run_command(command)
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 79, in run
        _build_ext.run(self)
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 339, in run
        self.build_extensions()
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 434, in build_extensions
        self._check_cuda_version(compiler_name, compiler_version)
      File "/tmp/pip-build-env-wm8mya_7/overlay/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 812, in _check_cuda_version
        raise RuntimeError(CUDA_MISMATCH_MESSAGE.format(cuda_str_version, torch.version.cuda))
    RuntimeError:
    The detected CUDA version (11.6) mismatches the version that was used to compile
    PyTorch (10.2). Please make sure to use the same CUDA versions.

    ----------------------------------------
ERROR: Command errored out with exit status 1: /lore/mersoj/geodis/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/lore/mersoj/FastGeodis/setup.py'"'"'; __file__='"'"'/lore/mersoj/FastGeodis/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

Note: I can import python and pytorch and it runs GPU code without issue. I think this must be an installation with FastGeodis. However, I'm not sure since I don't have experience using pytorch.

Expected behavior FastGeodis installs

Desktop (please complete the following information):

jacobmerson commented 2 years ago

And here is something that makes it a bit more mysterious...

$ import torch
$ torch.version.cuda
'11.6'
masadcv commented 2 years ago

Hi, This looks similar to the poetry issues here: https://github.com/masadcv/FastGeodis/issues/6

Can you try installing with

pip install -e . --no-build-isolation

or

pip install FastGeodis --no-build-isolation

?

jacobmerson commented 2 years ago

@masadcv thanks for the suggestion! I used --no-build-isolation and then I had to install wheel. But then I could install from source on my linux workstation.

All of the tests are passing.

masadcv commented 2 years ago

Many thanks!

With --no-build-isolation we are skipping peotry dependencies for building the wheel, which includes wheel: https://github.com/masadcv/FastGeodis/blob/master/pyproject.toml