I'm trying to build a C++ project that uses Libtorch on a new laptop and am keep getting the following error when I run Make:
/home/labuser/anaconda3/envs/Research/bin/../lib/gcc/x86_64-conda-linux-gnu/13.1.0/../../../../x86_64-conda-linux-gnu/bin/ld: /home/labuser/anaconda3/envs/Research/lib/python3.11/site-packages/torch/lib/libc10.so: undefined reference to `memcpy@GLIBC_2.14'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/learn.dir/build.make:101: learn] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/learn.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
For reference, my operating system is Fedora 38 with glibc 2.37, and I installed PyTorch/Libtorch and GXX using Conda. The project itself is build using CMake, and then running Make shows the above error.
This issue doesn't happen on my Fedora 37 desktop, where I have glibc 2.36 installed.
Things I've tried:
- Updated glibc using
dnf update glibc - Updated my PyTorch installation, etc. in Conda
- I also tried linking directly with Libtorch header files (both non-ABI and ABI) downloaded from the PyTorch website.
I'm rather confused on how to proceed from here.
One more thing: running CMakeList did throw a warning. It doesn't on my other Fedora computer.
-- Caffe2: Protobuf version 3.20.3
CMake Warning at /home/labuser/anaconda3/envs/Research/lib/python3.11/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:22 (message):
static library kineto_LIBRARY-NOTFOUND not found.
Call Stack (most recent call first):
/home/labuser/anaconda3/envs/Research/lib/python3.11/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:127 (append_torchlib_if_found)
CMakeLists.txt:8 (find_package)
How can I proceed? I found some advice on Stack Exchange for glibc when writing own code, but I am unsure how to work around the PyTorch/Libtorch one.
I updated PyTorch and GXX in my Conda install and updated glibc using DNF.
I found an answer to my issue, posting it here for people who are likely to have this issue as well.
It's anaconda. The newest Anaconda changes the default g++ and gcc to it's own, instead of using the system one.This is fine, except here it breaks on Fedora the ability to link to glibc via libtorch. Solution:
Doing so led to successful linking, even with Anaconda's own torch libraries.