torchac
torchac copied to clipboard
Ninja compilation fail: error <glog/logging.h> was not included correctly.
Hello, do you have any idea why this occurs when the torhac backend is compiled by ninja? The log is quite long but this is what I get:
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/2] c++ -MMD -MF torchac_backend.o.d -DTORCH_EXTENSION_NAME=torchac_backend -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1017\" -I/usr/lib/python3.11/site-packages/torch/include -I/usr/lib/python3.11/site-packages/torch/include/torch/csrc/api/include -I/usr/lib/python3.11/site-packages/torch/include/TH -I/usr/lib/python3.11/site-packages/torch/include/THC -I/usr/include/python3.11 -D_GLIBCXX_USE_CXX11_ABI=1 -fPIC -std=c++17 -c /usr/lib/python3.11/site-packages/torchac/backend/torchac_backend.cpp -o torchac_backend.o
FAILED: torchac_backend.o
c++ -MMD -MF torchac_backend.o.d -DTORCH_EXTENSION_NAME=torchac_backend -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1017\" -I/usr/lib/python3.11/site-packages/torch/include -I/usr/lib/python3.11/site-packages/torch/include/torch/csrc/api/include -I/usr/lib/python3.11/site-packages/torch/include/TH -I/usr/lib/python3.11/site-packages/torch/include/THC -I/usr/include/python3.11 -D_GLIBCXX_USE_CXX11_ABI=1 -fPIC -std=c++17 -c /usr/lib/python3.11/site-packages/torchac/backend/torchac_backend.cpp -o torchac_backend.o
In file included from /usr/include/c10/util/logging_is_google_glog.h:50,
from /usr/include/c10/util/Logging.h:26,
from /usr/include/ATen/core/ivalue_inl.h:25,
from /usr/include/ATen/core/ivalue.h:1551,
from /usr/include/ATen/core/List_inl.h:4,
from /usr/include/ATen/core/List.h:490,
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.11/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3,
from /usr/lib/python3.11/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7,
from /usr/include/torch/extension.h:5,
from /usr/lib/python3.11/site-packages/torchac/backend/torchac_backend.cpp:8:
/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.
| ^~~~~
In file included from /usr/include/glog/logging.h:63:
/usr/include/glog/flags.h:45:4: error: #error <glog/flags.h> was not included correctly. See the documentation for how to consume the library.
45 | # error <glog/flags.h> was not included correctly. See the documentation for how to consume the library.
| ^~~~~
...
Thanks for any help.
EDIT:
As a workaround I added
extra_cflags.append("-DGLOG_USE_GLOG_EXPORT")
to
/usr/lib/python3.11/site-packages/torch/utils/cpp_extension.py
here
# NOTE: Emitting a new ninja build file does not cause re-compilation if
# the sources did not change, so it's ok to re-emit (and it's fast).
extra_cflags.append("-DGLOG_USE_GLOG_EXPORT")
_write_ninja_file_to_build_library(