Closed derekwin closed 2 weeks ago
works for me on hygon GPU
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(simple-tensor-operations)
set(CMAKE_CXX_STANDARD 17) # 设置 C++17
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
set(CMAKE_CXX_COMPILER "g++" CACHE STRING "C++ compiler" FORCE)
# 设置 amd_comgr 的路径
set(amd_comgr_DIR "/opt/dtk/lib64/cmake/amd_comgr" CACHE STRING "Path to amd_comgr")
# 设置 CMAKE_PREFIX_PATH
set(CMAKE_PREFIX_PATH "/opt/dtk/lib64/cmake/amd_comgr" ${CMAKE_PREFIX_PATH})
# 设置 torch.cmake 的路径
set(CMAKE_PREFIX_PATH "/home/sdu/miniforge3/envs/pytorch21/lib/python3.10/site-packages/torch/share/cmake/Torch" ${CMAKE_PREFIX_PATH})
# 设置 glog 的路径
set(TORCH_DIR "/home/sdu/miniforge3/envs/pytorch21/lib/python3.10/site-packages/torch/lib")
set(CMAKE_INSTALL_RPATH "${TORCH_DIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
find_package(Torch REQUIRED)
link_directories(${TORCH_DIR})
add_executable(simple-tensor-operations main.cpp)
target_link_libraries(simple-tensor-operations
${TORCH_LIBRARIES}
${GLOG_LIBRARY}
)
Somethings wrong while build torch_app with torch c++ api on hygon gpus (dtk).