Compiling Pytorch with C++14

Hello, I’m trying to compile Pytorch into C++14. I’m following the guideline on to build a minimal c++ application. I’m using Pytorch 1.7.0. (cuda 10.2, cxx11ABI) from
When the compilation (with cmake) is almost done, the following error messages pop up:

Scanning dependencies of target tmp
[ 50%] Building CXX object CMakeFiles/tmp.dir/tmp.cpp.o
[100%] Linking CXX executable tmp
/project/dilkina_438/taoanhua/LNS/libtorch/lib/ undefined reference to lgammaf@GLIBC_2.23' /project/dilkina_438/taoanhua/LNS/libtorch/lib/ undefined reference to lgamma@GLIBC_2.23’
collect2: error: ld returned 1 exit status
make[2]: *** [tmp] Error 1
make[1]: *** [CMakeFiles/tmp.dir/all] Error 2
make: *** [all] Error 2

I’m wondering if anyone has seen this before and know how to resolve it. Thanks!


I used the following build process:

module purge
module load usc
module load cuda/10.1.243 python/3.7.6 cmake/3.16.2 cudnn/8.0.2-10.1

mkdir run_pytorch; cd run_pytorch

mv ~/example-app.tgz ./

tar -xzvf example-app.tgz

cd example-app/

mkdir build; cd build

python3 -c 'import torch ; print(torch.utils.cmake_prefix_path)'

CC=gcc CXX=g++ cmake -DCMAKE_PREFIX_PATH='/spack/apps/linux-centos7-x86_64/gcc-8.3.0/python-3.7.6-dd2am3dyvlpovhd4rizwfzc45wnsajxf/lib/python3.7/site-packages/torch/share/cmake;/usr/lib64' . .

cmake --build . --config Release