-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
47 lines (38 loc) · 1.37 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
# Custom settings for alex workstation to link libtorch and cuda
#set(CMAKE_CUDA_COMPILER "/usr/local/cuda/bin/nvcc")
#list(APPEND CMAKE_PREFIX_PATH "/opt/libtorch")
project(example_reduce CXX)
include(CheckLanguage)
check_language(CUDA)
if (CMAKE_CUDA_COMPILER)
enable_language(CUDA)
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(Torch REQUIRED)
add_library(reduce_cpp SHARED
src/reduce.cpp
src/bindings.cpp
src/reduce.hh
src/reduce_autograd.cpp
src/reduce_cpu.cpp
src/reduce_cuda.cu
)
target_link_libraries(reduce_cpp PUBLIC torch)
add_executable(example_reduce example_reduce.cpp)
target_link_libraries(example_reduce reduce_cpp)
add_executable(use-torch-model use-torch-model.cpp)
target_link_libraries(use-torch-model reduce_cpp)
# # The following code block is suggested to be used on Windows.
# # According to https://github.com/pytorch/pytorch/issues/25457,
# # the DLLs need to be copied to avoid memory errors.
# if (MSVC)
# file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")
# add_custom_command(TARGET example_reduce
# POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
# ${TORCH_DLLS}
# $<TARGET_FILE_DIR:example_reduce>)
# endif (MSVC)