locuslab / SATNet

Bridging deep learning and logical reasoning using a differentiable satisfiability solver.
MIT License
401 stars 52 forks source link

Install error in both Colab and Ubuntu22.04 #17

Open aruiplex opened 5 months ago

aruiplex commented 5 months ago

Hi! I try to install your library, but I encounter the error:

In Ubuntu 22.04: satnet_cuda.cu(165): error: identifier "saturate" is undefined. I am using Python3.11, and Pytorch 2.2.2, CUDA 12.2.

In the colab: ModuleNotFoundError: No module named 'satnet._cpp'

Here is the details about the log:

In Ubuntu:

running develop
/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/command/develop.py:40: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` and ``easy_install``.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://github.com/pypa/setuptools/issues/917 for details.
        ********************************************************************************

!!
  easy_install.initialize_options(self)
/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
running egg_info
creating satnet.egg-info
writing satnet.egg-info/PKG-INFO
writing dependency_links to satnet.egg-info/dependency_links.txt
writing requirements to satnet.egg-info/requires.txt
writing top-level names to satnet.egg-info/top_level.txt
writing manifest file 'satnet.egg-info/SOURCES.txt'
reading manifest file 'satnet.egg-info/SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'satnet.egg-info/SOURCES.txt'
running build_ext
/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/utils/cpp_extension.py:415: UserWarning: The detected CUDA version (12.2) has a minor version mismatch with the version that was used to compile PyTorch (12.1). Most likely this shouldn't be a problem.
  warnings.warn(CUDA_MISMATCH_WARN.format(cuda_str_version, torch.version.cuda))
/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/utils/cpp_extension.py:425: UserWarning: There are no g++ version bounds defined for CUDA version 12.2
  warnings.warn(f'There are no {compiler_name} version bounds defined for CUDA version {cuda_str_version}')
building 'satnet._cpp' extension
creating /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build
creating /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311
creating /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src
Emitting ninja build file /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/2] c++ -MMD -MF /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet_cpu.o.d -pthread -B /data/Hypothesis/domain/ns/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /data/Hypothesis/domain/ns/include -fPIC -O2 -isystem /data/Hypothesis/domain/ns/include -fPIC -I./src -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/torch/csrc/api/include -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/TH -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/THC -I/data/Hypothesis/domain/ns/include/python3.11 -c -c /data/Hypothesis/lemma/NeuralSymbolic/SATNet/src/satnet_cpu.cpp -o /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet_cpu.o -fopenmp -msse4.1 -Wall -g -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_cpp -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++17
[2/2] c++ -MMD -MF /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet.o.d -pthread -B /data/Hypothesis/domain/ns/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /data/Hypothesis/domain/ns/include -fPIC -O2 -isystem /data/Hypothesis/domain/ns/include -fPIC -I./src -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/torch/csrc/api/include -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/TH -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/THC -I/data/Hypothesis/domain/ns/include/python3.11 -c -c /data/Hypothesis/lemma/NeuralSymbolic/SATNet/src/satnet.cpp -o /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet.o -fopenmp -msse4.1 -Wall -g -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_cpp -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++17
creating build/lib.linux-x86_64-cpython-311
creating build/lib.linux-x86_64-cpython-311/satnet
g++ -pthread -B /data/Hypothesis/domain/ns/compiler_compat -shared -Wl,-rpath,/data/Hypothesis/domain/ns/lib -Wl,-rpath-link,/data/Hypothesis/domain/ns/lib -L/data/Hypothesis/domain/ns/lib -Wl,-rpath,/data/Hypothesis/domain/ns/lib -Wl,-rpath-link,/data/Hypothesis/domain/ns/lib -L/data/Hypothesis/domain/ns/lib /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet.o /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet_cpu.o -L/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/lib -lc10 -ltorch -ltorch_cpu -ltorch_python -o build/lib.linux-x86_64-cpython-311/satnet/_cpp.cpython-311-x86_64-linux-gnu.so
building 'satnet._cuda' extension
Emitting ninja build file /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/2] /usr/local/cuda-12.2/bin/nvcc --generate-dependencies-with-compile --dependency-output /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet_cuda.o.d -I./src -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/torch/csrc/api/include -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/TH -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/THC -I/usr/local/cuda-12.2/include -I/data/Hypothesis/domain/ns/include/python3.11 -c -c /data/Hypothesis/lemma/NeuralSymbolic/SATNet/src/satnet_cuda.cu -o /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet_cuda.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -g -restrict -maxrregcount 32 -lineinfo -Xptxas=-v -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_89,code=compute_89 -gencode=arch=compute_89,code=sm_89 -std=c++17
FAILED: /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet_cuda.o 
/usr/local/cuda-12.2/bin/nvcc --generate-dependencies-with-compile --dependency-output /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet_cuda.o.d -I./src -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/torch/csrc/api/include -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/TH -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/THC -I/usr/local/cuda-12.2/include -I/data/Hypothesis/domain/ns/include/python3.11 -c -c /data/Hypothesis/lemma/NeuralSymbolic/SATNet/src/satnet_cuda.cu -o /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet_cuda.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -g -restrict -maxrregcount 32 -lineinfo -Xptxas=-v -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_89,code=compute_89 -gencode=arch=compute_89,code=sm_89 -std=c++17
/data/Hypothesis/lemma/NeuralSymbolic/SATNet/src/satnet_cuda.cu(165): error: identifier "saturate" is undefined
          zi = saturate((zi+1)/2)*2-1;
               ^

1 error detected in the compilation of "/data/Hypothesis/lemma/NeuralSymbolic/SATNet/src/satnet_cuda.cu".
[2/2] c++ -MMD -MF /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet.o.d -pthread -B /data/Hypothesis/domain/ns/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /data/Hypothesis/domain/ns/include -fPIC -O2 -isystem /data/Hypothesis/domain/ns/include -fPIC -I./src -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/torch/csrc/api/include -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/TH -I/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/include/THC -I/usr/local/cuda-12.2/include -I/data/Hypothesis/domain/ns/include/python3.11 -c -c /data/Hypothesis/lemma/NeuralSymbolic/SATNet/src/satnet.cpp -o /data/Hypothesis/lemma/NeuralSymbolic/SATNet/build/temp.linux-x86_64-cpython-311/src/satnet.o -DMIX_USE_GPU -g -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++17
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 2096, in _run_ninja_build
    subprocess.run(
  File "/data/Hypothesis/domain/ns/lib/python3.11/subprocess.py", line 571, 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 "/data/Hypothesis/lemma/NeuralSymbolic/SATNet/setup.py", line 48, in <module>
    setup(
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/__init__.py", line 103, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
    return run_commands(dist)
           ^^^^^^^^^^^^^^^^^^
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
    dist.run_commands()
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
    self.run_command(cmd)
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/dist.py", line 989, in run_command
    super().run_command(command)
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/command/develop.py", line 34, in run
    self.install_for_development()
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/command/develop.py", line 109, in install_for_development
    self.run_command('build_ext')
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
    self.distribution.run_command(command)
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/dist.py", line 989, in run_command
    super().run_command(command)
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 88, in run
    _build_ext.run(self)
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
    self.build_extensions()
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 871, in build_extensions
    build_ext.build_extensions(self)
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions
    self._build_extensions_serial()
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial
    self.build_extension(ext)
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 249, in build_extension
    _build_ext.build_extension(self, ext)
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 548, in build_extension
    objects = self.compiler.compile(
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 684, in unix_wrap_ninja_compile
    _write_ninja_file_and_compile_objects(
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 1774, in _write_ninja_file_and_compile_objects
    _run_ninja_build(
  File "/data/Hypothesis/domain/ns/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 2112, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension

In Colab:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-4-f115df1ae491>](https://localhost:8080/#) in <cell line: 1>()
----> 1 import satnet
      2 print('SATNet document\n', satnet.SATNet.__doc__)

1 frames
[/content/SATNet/satnet/models.py](https://localhost:8080/#) in <module>
      4 import torch.optim as optim
      5 
----> 6 import satnet._cpp
      7 if torch.cuda.is_available(): import satnet._cuda
      8 

ModuleNotFoundError: No module named 'satnet._cpp'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
xflash96 commented 5 months ago

Adding the saturate() function in the .cu should solve the problem. E.g., inline __device__ float saturate(float x) { return x - (x<0)*x + (x>1)*(1-x); } This is cause by libtorch's versioning.