Libtorch code integration failed with error "version `GOMP_4.5' not found"

Quentin_Munch: <p>Hi,<br>
We are currently deploying a Faster-RCNN model trained using Detectron2 in C++ code.<br>
Our code use the following libraries :</p>
<pre><code class="lang-auto">find_package(Torch REQUIRED REQUIRED PATHS /home/pps/libtorch-cxx11-abi-shared-with-deps-1.8.1+cu111/libtorch)
find_package(TorchVision REQUIRED)
find_package( realsense2 REQUIRED )
find_package( OpenCV REQUIRED )
find_package( PCL REQUIRED )
find_package(Boost COMPONENTS program_options)
</code></pre>
<p>Unfortunately after compiling the .cpp code (without any problem); I get the following error message at execution :</p>
<pre><code class="lang-auto">./ADVP: /home/pps/libtorch-cxx11-abi-shared-with-deps-1.8.1+cu111/libtorch/lib/libgomp-75eea7e8.so.1: version `GOMP_4.5' not found (required by /usr/local/lib/libpcl_features.so.1.11)
./ADVP: /home/pps/libtorch-cxx11-abi-shared-with-deps-1.8.1+cu111/libtorch/lib/libgomp-75eea7e8.so.1: version `GOMP_4.5' not found (required by /usr/local/lib/libpcl_common.so.1.11)
</code></pre>
<p>Libtorch seems to interfer with the PCL Library.<br>
Here is the CmakeFile I use to build my program :</p>
<pre><code class="lang-auto">cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

# project name
project(ADVP)

# look for all package needed
find_package(Torch REQUIRED REQUIRED PATHS /home/pps/libtorch-cxx11-abi-shared-with-deps-1.8.1+cu111/libtorch)
find_package(TorchVision REQUIRED)
find_package( realsense2 REQUIRED )
find_package( OpenCV REQUIRED )
find_package( PCL REQUIRED )
find_package(Boost COMPONENTS program_options)

# RUNNING AND LEARNING CODE
add_executable(ADVP src/ADVP.cpp include/RS-CV_helper_functions.hpp include/RS-PCL_helper_functions.hpp include/CV_helper_functions.hpp include/CV-PCL_helper_functions.hpp)

# target libs
target_link_libraries(ADVP ${TORCH_LIBRARIES})
target_link_libraries(ADVP ${DEPENDENCIES} ${realsense2_LIBRARY})
target_link_libraries(ADVP ${DEPENDENCIES} ${OpenCV_LIBS})
target_link_libraries(ADVP ${DEPENDENCIES} ${PCL_LIBRARIES})

# target property
set_property(TARGET ADVP PROPERTY CXX_STANDARD 14)

</code></pre>
<p>I want to precise that my code work without the Torch library but when I want to integrate it I get this error.</p>
<p>Here is my environment configuration :</p>
<pre><code class="lang-auto">PyTorch version: 1.8.1+cu111
Is debug build: False
CUDA used to build PyTorch: 11.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.2 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: version 3.16.3

Python version: 3.8 (64-bit runtime)
Is CUDA available: True
CUDA runtime version: 11.1.105
GPU models and configuration: GPU 0: GeForce GTX 1080
Nvidia driver version: 460.56
cuDNN version: Probably one of the following:
/usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn.so.8.1.1
/usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.1.1
/usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.1.1
/usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.1.1
/usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.1.1
/usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.1.1
/usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.1.1
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.5
[pip3] torch==1.8.1+cu111
[pip3] torchaudio==0.8.1
[pip3] torchvision==0.9.1+cu111
[conda] Could not collect
</code></pre>
<p>I use the current pre-compile version of libtorch for CUDA 11.1 Cxx11-ABI.</p>
<p>It’s been a week, and I tried everything to make it work.<br>
Does anyone have an idea ?<br>
Do I need to build Libtorch myself ?</p>
<p>Best regards,</p>
<p>Quentin.</p>

ptrblck: <p>You might be hitting <a href="https://github.com/pytorch/pytorch/issues/643">this older issue</a> which points towards an import issue for OpenMP.<br>
However, based on the discussion it should have been solved. In any way, a source build should not suffer from this issue, as your local OpenMP lib should be used.</p>

Quentin_Munch: <p>Hi, thanks for your answer.<br>
I already came across this issue on git.<br>
I will try to build the library myself ^^.</p>
<p>Best regards,</p>
<p>Quentin.</p>

raabuchanan: <p>Hi!<br>
I’m having the exact same issue. Was this resolved? It’s also not clear to me from the other thread what I should do in this case.</p>

Tumb1eweed: <p>You can copy your own libgomp in system to override the libgomp in libtorch, like<br>
cp -f /usr/lib/x86_64-linux-gnu/libgomp.so.1 /data/conan/data/libtorch/1.9.0/<em>/</em> /package/e4d18b8896cf7e386937542f05945808746bc8d2/lib/libgomp-75eea7e8.so.1</p>