Skip to content

Eventual compilation issue with recent versions of Pytorch/Google-glog #62

@HKervadec

Description

@HKervadec

I had issues compiling locally this package, with Glog complaining on how it was included, e.g.:

>>> python setup.py build
/home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/setup.py:8: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
setup.py with torch 2.5.1
BUILD_CPP=True, BUILD_CUDA=True, TORCH_VERSION=20501.
FastGeodis building version: 1.0.5
running build
running build_py
running build_ext
/usr/lib/python3.13/site-packages/torch/utils/cpp_extension.py:426: UserWarning: There are no g++ version bounds defined for CUDA version 12.6
  warnings.warn(f'There are no {compiler_name} version bounds defined for CUDA version {cuda_str_version}')
INFO: Disabling color, you really want to install colorlog.
Disabling color, you really want to install colorlog.
building 'FastGeodisCpp' extension
/usr/lib/python3.13/site-packages/torch/utils/cpp_extension.py:1964: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation.
If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST'].
  warnings.warn(
Emitting ninja build file /home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/build/temp.linux-x86_64-cpython-313/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/6] /opt/cuda/bin/nvcc --generate-dependencies-with-compile --dependency-output /home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/build/temp.linux-x86_64-cpython-313/FastGeodis/fastgeodis_cuda.o.d -DAT_PARALLEL_OPENMP=1 -DWITH_CUDA -IFastGeodis -I/usr/lib/python3.13/site-packages/torch/include -I/usr/lib/python3.13/site-packages/torch/include/torch/csrc/api/include -I/usr/lib/python3.13/site-packages/torch/include/TH -I/usr/lib/python3.13/site-packages/torch/include/THC -I/opt/cuda/include -I/home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/dependency -I/usr/include/python3.13 -c -c /home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/FastGeodis/fastgeodis_cuda.cu -o /home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/build/temp.linux-x86_64-cpython-313/FastGeodis/fastgeodis_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'"'"'' -DGLOG_NO_EXPORT -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1018"' -DTORCH_EXTENSION_NAME=FastGeodisCpp -D_GLIBCXX_USE_CXX11_ABI=1 -gencode=arch=compute_61,code=compute_61 -gencode=arch=compute_61,code=sm_61 -std=c++17
FAILED: /home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/build/temp.linux-x86_64-cpython-313/FastGeodis/fastgeodis_cuda.o
/opt/cuda/bin/nvcc --generate-dependencies-with-compile --dependency-output /home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/build/temp.linux-x86_64-cpython-313/FastGeodis/fastgeodis_cuda.o.d -DAT_PARALLEL_OPENMP=1 -DWITH_CUDA -IFastGeodis -I/usr/lib/python3.13/site-packages/torch/include -I/usr/lib/python3.13/site-packages/torch/include/torch/csrc/api/include -I/usr/lib/python3.13/site-packages/torch/include/TH -I/usr/lib/python3.13/site-packages/torch/include/THC -I/opt/cuda/include -I/home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/dependency -I/usr/include/python3.13 -c -c /home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/FastGeodis/fastgeodis_cuda.cu -o /home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/build/temp.linux-x86_64-cpython-313/FastGeodis/fastgeodis_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'"'"'' -DGLOG_NO_EXPORT -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1018"' -DTORCH_EXTENSION_NAME=FastGeodisCpp -D_GLIBCXX_USE_CXX11_ABI=1 -gencode=arch=compute_61,code=compute_61 -gencode=arch=compute_61,code=sm_61 -std=c++17
In file included from /usr/include/c10/util/logging_is_google_glog.h:50,
                 from /usr/include/c10/util/Logging.h:27,
                 from /usr/include/ATen/core/ivalue_inl.h:26,
                 from /usr/include/ATen/core/ivalue.h:1581,
                 from /usr/include/ATen/core/List_inl.h:4,
                 from /usr/include/ATen/core/List.h:488,
                 from /usr/include/ATen/core/IListRef_inl.h:3,
                 from /usr/include/ATen/core/IListRef.h:631,
                 from /usr/include/ATen/WrapDimUtils.h:3,
                 from /usr/include/ATen/TensorNames.h:3,
                 from /usr/include/ATen/NamedTensorUtils.h:3,
                 from /usr/include/torch/csrc/autograd/variable.h:11,
                 from /usr/include/torch/csrc/autograd/autograd.h:3,
                 from /usr/lib/python3.13/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3,
                 from /usr/lib/python3.13/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7,
                 from /usr/include/torch/extension.h:5,
                 from /home/hoel/build/python-fastgeodis/src/FastGeodis-1.0.5/FastGeodis/fastgeodis_cuda.cu:31:
/usr/include/glog/logging.h:60:4: error: #error <glog/logging.h> was not included correctly. See the documentation for how to consume the library.
   60 | #  error <glog/logging.h> was not included correctly. See the documentation for how to consume the library.
      |    ^~~~~

I am on a pretty cutting-edge (i.e., very recent packages for everything) setup, and from I gathered the issue arose through the inclusion of recent PyTorch versions:

>>> yay -Q python python-pytorch-opt-cuda google-glog
python 3.13.1-1
python-pytorch-opt-cuda 2.5.1-7
google-glog 0.7.1-1

Anyhow, adding extra compilation flags at line 95 of setup.py seems to fix the issue:

        extra_compile_args = {"cxx": ["-DGLOG_USE_GLOG_EXPORT"], "nvcc": ["-DGLOG_USE_GLOG_EXPORT"]}

Sharing it here now because I figure it may be an issue to others at some point in the future.

Great package anyway, thanks for making it available, cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions