Compiling Pytorch with C++14

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

Blockquote
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/libtorch_cpu.so: undefined reference to lgammaf@GLIBC_2.23' /project/dilkina_438/taoanhua/LNS/libtorch/lib/libtorch_cpu.so: 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!

Hello,

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

./example-app