-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Open
Labels
module: abilibtorch C++ ABI related problemslibtorch C++ ABI related problemsmodule: binariesAnything related to official binaries that we release to usersAnything related to official binaries that we release to usersmodule: buildBuild system issuesBuild system issuestriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🐛 Describe the bug
When run the pytorch example: https://pytorch.org/cppdocs/installing.html
CMakeLists.txt files:
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(example-app)
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
# message("TORCH_CXX_FLAGS====: " ${TORCH_CXX_FLAGS})
# link_directories("/usr/local/cuda-11.2/targets/x86_64-linux/lib")
add_executable(example-app example-app.cpp)
target_link_libraries(example-app "${TORCH_LIBRARIES}")
message("TORCH_LIBRARIES:" "${TORCH_LIBRARIES}")
set_property(TARGET example-app PROPERTY CXX_STANDARD 14)
if (MSVC)
file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")
add_custom_command(TARGET example-app
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${TORCH_DLLS}
$<TARGET_FILE_DIR:example-app>)
endif (MSVC)
cpp:
#include <torch/torch.h>
#include <iostream>
int main() {
torch::Tensor tensor = torch::rand({2, 3});
std::cout << tensor << std::endl;
}
cmake command:
cmake -DCMAKE_PREFIX_PATH=/home/guangtong/project/libtorch ..
cmake --build . --config Release
will appears:
cmake --build . --config Release
[ 50%] Linking CXX executable example-app
/home/xxxxxx/project/libtorch/lib/libtorch_cuda_cpp.so: undefined reference to `cudaStreamUpdateCaptureDependencies@libcudart.so.11.0'
/home/xxxxxx/project/libtorch/lib/libtorch_cuda_cpp.so: undefined reference to `cudaStreamGetCaptureInfo_v2@libcudart.so.11.0'
/home/xxxxxx/project/libtorch/lib/libtorch_cuda_cpp.so: undefined reference to `cudaGraphRetainUserObject@libcudart.so.11.0'
/home/xxxxxx/project/libtorch/lib/libtorch_cuda_cpp.so: undefined reference to `cudaUserObjectCreate@libcudart.so.11.0'
collect2: error: ld returned 1 exit status
CMakeFiles/example-app.dir/build.make:110: recipe for target 'example-app' failed
make[2]: *** [example-app] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/example-app.dir/all' failed
make[1]: *** [CMakeFiles/example-app.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
but seems the file dependencies is ok:
ldd -r libtorch_cuda_cpp.so
linux-vdso.so.1 (0x00007ffe39818000)
libcudart-a7b20f20.so.11.0 (0x00007fba89fc1000)
libc10_cuda.so (0x00007fba89d5b000)
libnvToolsExt-24de1d56.so.1 (0x00007fba89b51000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fba89932000)
libc10.so (0x00007fba896ba000)
libtorch_cpu.so (0x00007fba726f1000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fba724ed000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fba722e5000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fba71f5c000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fba71bbe000)
libgomp-52f2fd74.so.1 (0x00007fba7198b000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fba71773000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fba71382000)
/lib64/ld-linux-x86-64.so.2 (0x00007fbafb5a3000)
Versions
libtorch version:
https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.10.2%2Bcu113.zip
os: Ubuntu 18.04
cmake version: 3.10.2
smetanadvorak, lynnliu030, SungHZ, Hermes777, duduscript and 1 moredhfromkorea
Metadata
Metadata
Assignees
Labels
module: abilibtorch C++ ABI related problemslibtorch C++ ABI related problemsmodule: binariesAnything related to official binaries that we release to usersAnything related to official binaries that we release to usersmodule: buildBuild system issuesBuild system issuestriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module