Replies: 1 comment
-
|
To add on to the above, libtorch works perfectly fine by itself (except for Failed to compute shorthash for libnvrtc.so warning) and i am able to use the library by using find_package(Torch REQUIRED) followed by setting the appropriate CXX_FLAGS as well as target_link_libraries. At first i tried to change the make install directory to another directory (next to libtorch) but using this method i cannot even get it to work (<torchscatter/scatter.h> not found unless i purposefully include_target_directories(...) to the path of the includes in the cmakelists.txt file). This prompted me to use the default install into usr/local Im not sure if there is something wrong with my base environment causing this to not work cleanly. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently my workflow requires for inference of pytorch geometric in C++ and I am having trouble getting the minimal example of PyG in C++ to work.
Using WSL2 Ubuntu-22.04 on Windows 11, I downloaded the following torch distribution: libtorch-shared-with-deps-2.8.0%2Bcu128.zip
Then I installed torch-scatter (https://github.com/rusty1s/pytorch_scatter#c-api) and torch-sparse (https://github.com/rusty1s/pytorch_sparse/#c-api) following the guide.
Built with:
cmake -DWITH_CUDA=on -DCMAKE_PREFIX_PATH="~/projects/my_playground/deps/libtorch" ..
make
make install
and both torch-scatter and torch-sparse installed to usr/local.
I did get a warning when configuring cmake with the above command (although i also get this warning when compiling a program with torch alone, not sure what is causing the issue):
CMake Warning at /home/jinyi/projects/my_playground/deps/libtorch/share/cmake/Caffe2/public/cuda.cmake:140 (message):
Failed to compute shorthash for libnvrtc.so
Call Stack (most recent call first):
/home/jinyi/projects/my_playground/deps/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:86 (include)
/home/jinyi/projects/my_playground/deps/libtorch/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
CMakeLists.txt:21 (find_package)
Otherwise everything compiled correctly and make make install ran successfully.
Checking the files in usr/local also confirms the existence of required files.
Using the exact same files from https://github.com/pyg-team/pytorch_geometric/blob/master/examples/cpp/README.md:
(I changed CXX_STANDARD 14 -> CXX_STANDARD 17, otherwise it will fail to compile)
Configuring the example using cmake -DCMAKE_PREFIX_PATH="~/projects/my_playground/deps/libtorch;/usr/local" .. And building using cmake --build . gives the hello-world executable
Running ./hello-world ../model.pt gives (model.pt was obtained by running save-model.py with a virtual environment with pytorch 2.8.0 cuda 12.8 and pytorch geometric)
I obtained the following error: ./hello-world: error while loading shared libraries: libc10_cuda.so: cannot open shared object file: No such file or directory
To make the libraries visible i ran: export LD_LIBRARY_PATH=~/projects/my_playground/deps/libtorch/lib:usr/local/lib:$LD_LIBRARY_PATH (im not too sure why the libraries arent visible)
Despite all that, I obtained the following error:
./hello-world ../model.pt
terminate called after throwing an instance of 'torch::jit::ErrorReport'
what():
Unknown builtin op: pyg::index_sort.
Could not find any similar ops to pyg::index_sort. This op may not exist or may not be currently supported in TorchScript.
I've tried many things and cant seem to reproduce a working minimal example.
Beta Was this translation helpful? Give feedback.
All reactions