Hi,
After building the pre-abi libtorch from source using gcc 5.4.0,
using the following steps
conda activate pytorch-build

# Setup compiler gcc 5.4.0 
export CC=~/gcc-5.4.0/bin/gcc
export CXX=~/gcc-5.4.0/bin/g++
export LD_LIBRARY_PATH_BACKUP=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=~/gcc-5.4.0/lib64:$LD_LIBRARY_PATH

# Pytorch env variables
export BUILD_CAFFE2_MOBILE=OFF BUILD_TEST=OFF USE_OPENMP=0 USE_CUDA=0 USE_CUDNN=0 USE_MKLDNN=0 USE_MKL=0 USE_NNPACK=0 USE_QNNPACK=0 USE_DISTRIBUTED=0 USE_FFMPEG=0 USE_FBGEMM=0 USE_PYTORCH_QNNPACK=0
export PYTORCH_BUILD_VERSION=1.6.0 PYTORCH_BUILD_NUMBER=0
export _GLIBCXX_USE_CXX11_ABI=0

# Build libtorch
cd ~/Repos/pytorch
git checkout v1.6.0
python setup.py clean
mkdir -p build_libtorch && cd build_libtorch
python ../tools/build_libtorch.py

# Disable gcc 5.4.0 to use 4.8.2
unset CC && unset CXX && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH_BACKUP

Then after switching to an older gcc 4.8.2, the command ldd libtorch.so throws some errors :
build/lib/libtorch.so: /.../gcc/4.8.2/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /.../pytorch/build_libtorch/build/lib/libtorch_cpu.so)
build/lib/libtorch.so: /.../gcc/4.8.2/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /.../pytorch/build_libtorch/build/lib/libtorch_cpu.so)
build/lib/libtorch.so: /.../gcc/4.8.2/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /.../pytorch/build_libtorch/build/lib/libtorch_cpu.so)
build/lib/libtorch.so: /.../gcc/4.8.2/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /.../pytorch/build_libtorch/build/lib/libtorch_cpu.so)
build/lib/libtorch.so: /.../gcc/4.8.2/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /.../pytorch/build_libtorch/build/lib/libc10.so)
build/lib/libtorch.so: /.../gcc/4.8.2/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /.../pytorch/build_libtorch/build/lib/libc10.so)
build/lib/libtorch.so: /.../gcc/4.8.2/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /.../pytorch/build_libtorch/build/lib/libc10.so)

I also tried with no success to hardcode the value of D_GLIBCXX_USE_CXX11_ABI to 0 in the pytorch/CMakeLists.txt:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
# or
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)

OS used: Centos 7
The distribution pre-abi provided by pytorch: https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-1.6.0%2Bcpu.zip doesn’t have this issue.
Any idea how to solve this ?
Regards,