Hi,
I am trying to build Libtorch from source using gcc 7.3.0, and then at runtime i am required to use a gcc 4.8.2.
Thus i face an error due to OpenMP library: libgomp.so.1: version `GOMP_4.0' not found ;
even after disabling OpenMP by USE_OPENMP=0.
Is there a way to solve this issue,

A way to use OPENMP 3.1 (compatible with gcc 4.8.2) ?
A way to effectively disable openmp (if it won’t affect dramatically the execution time)


Build (Centos 7):
conda activate pytorch-build-3
#devtoolset gcc
yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-gcc-gfortran devtoolset-7-binutils
export PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH
export LD_LIBRARY_PATH_BACKUP=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib:$LD_PRELOAD:$LD_LIBRARY_PATH

# pytorch env variables
export BUILD_CAFFE2_MOBILE=OFF BUILD_TEST=OFF USE_OPENMP=0 USE_CUDA=0
export BUILD_PYTHONLESS=1 LIBTORCH_VARIANT=shared-with-deps
export PYTORCH_BUILD_VERSION=1.6.0 PYTORCH_BUILD_NUMBER=0
export _GLIBCXX_USE_CXX11_ABI=0 # Disabling the new ABI

# Installing MKL
MKL_VERSION=2020.1
MKL_BUILD=217
mkdir -p ~/intel/lib
curl -fsSL https://anaconda.org/intel/mkl-static/${MKL_VERSION}/download/linux-64/mkl-static-${MKL_VERSION}-intel_${MKL_BUILD}.tar.bz2 | tar xjv
mv lib/* ~/intel/lib/
curl -fsSL https://anaconda.org/intel/mkl-include/${MKL_VERSION}/download/linux-64/mkl-include-${MKL_VERSION}-intel_${MKL_BUILD}.tar.bz2 | tar xjv
mv include ~/intel/

export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
export CMAKE_LIBRARY_PATH="~/intel/lib:/lib:$CMAKE_LIBRARY_PATH"
export CMAKE_INCLUDE_PATH="~/intel/include:$CMAKE_INCLUDE_PATH"

# Clone the repository
git clone https://github.com/pytorch/pytorch
cd ~/Repos/pytorch
git checkout v1.6.0
git submodule update --init --recursive

# Build libtorch
python setup.py clean

mkdir -p build_libtorch && cd build_libtorch 
python ../tools/build_libtorch.py

From the logs of the build:
-- MKL libraries: /.../intel/lib/libmkl_intel_lp64.a;/.../intel/lib/libmkl_gnu_thread.a;/.../intel/lib/libmkl_core.a;-fopenmp;/lib64/libpthread.so;/lib64/libm.so;/lib64/libdl.so
-- MKL include directory: /.../intel/include
-- MKL OpenMP type: GNU
-- MKL OpenMP library: -fopenmp

After switching to gcc 4.8.2, ldd libtorch.so
./libtorch.so: /.../gcc/4.8.2/lib64/libgomp.so.1: version 'GOMP_4.0' not found (required by /.../libtorch/lib/./libtorch_cpu.so)
	linux-vdso.so.1 =>  (0x00002aaaaaaae000)
	libtorch_cpu.so => /.../libtorch/lib/./libtorch_cpu.so (0x00002aaaaacc7000)
	libgcc_s.so.1 => /.../gcc/4.8.2/lib64/libgcc_s.so.1 (0x00002aaaba75f000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00002aaaba984000)
	libc.so.6 => /lib64/libc.so.6 (0x00002aaababa1000)
	libtensorpipe.so => /.../libtorch/lib/./libtensorpipe.so (0x00002aaabaf64000)
	librt.so.1 => /lib64/librt.so.1 (0x00002aaabb3f8000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00002aaabb601000)
	libm.so.6 => /lib64/libm.so.6 (0x00002aaabb805000)
	libc10.so => /.../libtorch/lib/./libc10.so (0x00002aaabbb07000)
	libstdc++.so.6 => /.../gcc/4.8.2/lib64/libstdc++.so.6 (0x00002aaabbd7c000)
	libgomp.so.1 => /.../gcc/4.8.2/lib64/libgomp.so.1 (0x00002aaabc085000)
	/lib64/ld-linux-x86-64.so.2 (0x0000555555554000)


Thanks,