question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error cannot find -ltorch and ltorchvision in building PyTorch Backend along with Triton Server in Oracle Linux 7.9

See original GitHub issue

Description I am trying to build Triton Server with pytorch backend I am getting this error:

[100%] Linking CXX shared library libtriton_pytorch.so
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/triton-pytorch-backend.dir/link.txt --verbose=0
/usr/bin/ld: cannot find -ltorch
/usr/bin/ld: cannot find -ltorchvision
collect2: error: ld returned 1 exit status
make[2]: *** [libtriton_pytorch.so] Error 1
make[2]: Leaving directory `/tmp/citritonbuild/pytorch/build'
make[1]: *** [CMakeFiles/triton-pytorch-backend.dir/all] Error 2
make[1]: Leaving directory `/tmp/citritonbuild/pytorch/build'
make: *** [all] Error 2
error: make install failed

I am using this command:

./build.py --cmake-dir=/home/git/server/build --build-dir=/tmp/citritonbuild --no-container-build --endpoint=http --endpoint=grpc --repo-tag=common:r21.04 --repo-tag=core:r21.04 --repo-tag=backend:r21.04 --repo-tag=thirdparty:r21.04 --backend=pytorch:r21.04 --enable-logging --enable-stats --enable-tracing

Triton Information What version of Triton are you using?

Are you using the Triton container or did you build it yourself? Yes. I am building it myself. I am using r21.04 release

To Reproduce Steps to reproduce the behavior. Use oracle linux 7.9 or centos 7.9 for build.

Describe the models (framework, inputs, outputs), ideally include the model configuration file (if using an ensemble include the model configuration file for that as well).

Expected behavior A clear and concise description of what you expected to happen.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
hit-lancecommented, Jul 9, 2021

I was able to solve this problem.

Go to this directory: /tmp/citritonbuild/pytorch/build/CMakeFiles/triton-pytorch-backend.dir Open this file: vim link.txt My file looks like this: /usr/local/bin/c++ -fPIC -O3 -DNDEBUG -Wl,--no-as-needed,--version-script libtriton_pytorch.ldscript -shared -Wl,-soname,libtriton_pytorch.so -o libtriton_pytorch.so CMakeFiles/triton-pytorch-backend.dir/src/libtorch.cc.o CMakeFiles/triton-pytorch-backend.dir/src/libtorch_utils.cc.o -Wl,-rpath,"\${ORIGIN}" _deps/repo-core-build/libtritonserver_stub.so _deps/repo-backend-build/libtritonbackendutils.a -L/tmp/citritonbuild/pytorch/build -ltorch -ltorchvision Why I am adding path of library -L/path-of-library? - https://stackoverflow.com/questions/16710047/usr-bin-ld-cannot-find-lnameofthelibrary Come back to build directory: cd /tmp/citritonbuild/pytorch/build Run make install

I found a more elegant solution. modifying CMakeLists.txt line 276-279 to set(TRITON_PYTORCH_LDFLAGS “-L${CMAKE_CURRENT_BINARY_DIR}”) will solve the problem.

0reactions
chandrameenamohancommented, Jul 2, 2021

Error says - tritonserver is not able to find the libtrititon_pytorch library. Copy the install binaries of pytorch to tritonserver directory go to directory: cd /tmp/citritonbuild/pytorch/install Then copy backends, lib and lib64 to /opt/tritonserver

cp -r backends /opt/tritonserver/backends
cp -r include /opt/tritonserver/include
cp -r lib64 /opt/tritonserver/lib64
Read more comments on GitHub >

github_iconTop Results From Across the Web

Build failure when building PyTorch CPU tritonserver ... - GitHub
Description I'm building a cpu-only PyTorch container with the ... find -ltorch /usr/bin/ld: cannot find -ltorchvision collect2: error: ld ...
Read more >
Issues with building libtorch on linux - C++ - PyTorch Forums
So I am trying to build libtorch on my linux machine using cmake and the instructions ... The core of pytorch does not...
Read more >
Error in cmake while setting up libtorch - C++ - PyTorch Forums
Hello all, I have been trying to set up libtorch on centos8 as instructed on the installation guide provided by Pytorch.
Read more >
Failed to build Pytorch audio from source
Hi @jiapei100, it seems like the kaldi submodule is missing. Could you try the following command to see if it works? python setup.py...
Read more >
Libtorch C++ build 'Could NOT find Torch (missing
Libtorch C++ build 'Could NOT find Torch (missing: TORCH_LIBRARY)' ... for pthread_create - found -- Found Threads: TRUE CMake Error at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found