otaheri / chamfer_distance

Implementation of the Chamfer Distance as a module for PyTorch
MIT License
166 stars 20 forks source link

Unable to build on Windows and Ubuntu #8

Open sktistakis opened 2 years ago

sktistakis commented 2 years ago

Unfortunately I am not able to build the chamfer_distance.cuda on neither Windows 11 and Ubuntu 22.04 (same machine) when calling cd = load(name="cv" ...) for the first time. Both report similar error messages.

I use Python 3.10, PyTorch 1.11.0 with CUDA toolkit 11.6 on both Windows and Ubuntu. I run this in a conda virtual environment.

I already tried this but it did not help.

Here is the Traceback from Ubuntu:

Traceback (most recent call last):
  File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1740, in _run_ninja_build
    subprocess.run(
  File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/sktis/dev/python/GrabNet/grabnet/tests/grab_new_objects.py", line 24, in <module>
    from grabnet.tools.vis_tools import points_to_spheres
  File "/home/sktis/dev/python/GrabNet/./grabnet/tools/vis_tools.py", line 21, in <module>
    from grabnet.tools.train_tools import point2point_signed
  File "/home/sktis/dev/python/GrabNet/./grabnet/tools/train_tools.py", line 18, in <module>
    import chamfer_distance as chd
  File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/chamfer_distance/__init__.py", line 1, in <module>
    from .chamfer_distance import ChamferDistance
  File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/chamfer_distance/chamfer_distance.py", line 8, in <module>
    cd = load(name="cd",
  File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1144, in load
    return _jit_compile(
  File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1357, in _jit_compile
    _write_ninja_file_and_build_library(
  File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1469, in _write_ninja_file_and_build_library
    _run_ninja_build(
  File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1756, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'cd': [1/2] /usr/bin/nvcc  -DTORCH_EXTENSION_NAME=cd -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/TH -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/THC -isystem /home/sktis/anaconda3/envs/GrabNet/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --compiler-options '-fPIC' -std=c++14 -c /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/chamfer_distance/chamfer_distance.cu -o chamfer_distance.cuda.o 
FAILED: chamfer_distance.cuda.o 
/usr/bin/nvcc  -DTORCH_EXTENSION_NAME=cd -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/TH -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/THC -isystem /home/sktis/anaconda3/envs/GrabNet/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --compiler-options '-fPIC' -std=c++14 -c /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/chamfer_distance/chamfer_distance.cu -o chamfer_distance.cuda.o 
/usr/include/c++/11/bits/std_function.h:435:145: error: parameter packs not expanded with ‘...’:
  435 |         function(_Functor&& __f)
      |                                                                                                                                                 ^ 
/usr/include/c++/11/bits/std_function.h:435:145: note:         ‘_ArgTypes’
/usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘...’:
  530 |         operator=(_Functor&& __f)
      |                                                                                                                                                  ^ 
/usr/include/c++/11/bits/std_function.h:530:146: note:         ‘_ArgTypes’
ninja: build stopped: subcommand failed.
sktistakis commented 2 years ago

Ok, I was able to solve the issue by downgrading to gcc-10 from gcc-11 using those commands.

$ sudo apt install gcc-10 g++-10
$ export CC=/usr/bin/gcc-10
$ export CXX=/usr/bin/g++-10

This fixed the problem on Ubuntu but I have not tried on Windows yet.