Before I begin, I’ve checked the topics similar to this one and they all have linking issues and PR’s that are outdated. I am attempting to compile the libtorch binaries and build pytorch from source with GLIBCXX_USE_CXX11_ABI=1
The reason for this, I am trying to build Open3d with ML bundle functionality including both Pytorch Ops and Tensorflow Ops. The status of Open3d support for CX11_ABI is it supports compilation with this setting. There are still open issues surrounding it. For example: https://github.com/isl-org/Open3D/pull/6288
During the build I see the CXX Flag is succesfully set:
--
-- ******** Summary ********
-- CMake version : 3.26.4
-- CMake command : $BUILD_PREFIX/bin/cmake
-- System : Linux
-- C++ compiler : /opt/rh/devtoolset-9/root/usr/bin/c++
-- C++ compiler version : 9.3.1
-- CXX flags : -D_GLIBCXX_USE_CXX11_ABI=1 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -Wnon-virtual-dtor
-- Build type : Release
-- Compile definitions : ONNX_ML=1;ONNXIFI_ENABLE_EXT=1;__STDC_FORMAT_MACROS
-- CMAKE_PREFIX_PATH : $PREFIX/lib/python3.10/site-packages;$PREFIX;/usr/local/cuda-12.1
-- CMAKE_INSTALL_PREFIX : $SRC_DIR/torch
-- CMAKE_MODULE_PATH : $SRC_DIR/cmake/Modules;$SRC_DIR/cmake/public/../Modules_CUDA_fix
--
-- ONNX version : 1.15.0rc2
-- ONNX NAMESPACE : onnx_torch
-- ONNX_USE_LITE_PROTO : OFF
-- USE_PROTOBUF_SHARED_LIBS : OFF
-- Protobuf_USE_STATIC_LIBS : ON
-- ONNX_DISABLE_EXCEPTIONS : OFF
-- ONNX_DISABLE_STATIC_REGISTRATION : OFF
-- ONNX_WERROR : OFF
-- ONNX_BUILD_TESTS : OFF
-- ONNX_BUILD_BENCHMARKS : OFF
-- ONNX_BUILD_SHARED_LIBS :
-- BUILD_SHARED_LIBS : OFF
--
-- Protobuf compiler :
-- Protobuf includes :
-- Protobuf libraries :
-- BUILD_ONNX_PYTHON : OFF
--
The build completes successfully and I am able to install the conda package in a blank py310 environment with required dependencies. The problem is that when I check for the cxx abi setting, it is False:
❯ python
Python 3.10.13 | packaged by conda-forge | (main, Oct 26 2023, 18:07:37) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch._C._GLIBCXX_USE_CXX11_ABI)
False
Anybody happen to know what I am not understanding?
I know you probably did, but I have to ask: Did you double-check that the PyTorch you’re running is the one you actually built?
When I’m building my PyTorch with setup.py bdist_wheel and then install the wheel, I’m getting C++11-ABI packages and I cannot remember that being different.
I have created a clean conda environment, using conda create -n test python=3.10
I then install the pytorch package from my local build output directory along with the necessary channels for dependencies. Here is the output of this command: