forked from dnouri/cuda-convnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
97 lines (84 loc) · 2.45 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
cmake_minimum_required (VERSION 2.8)
project (cuda-convnet)
find_package (CUDA REQUIRED)
find_package (BLAS REQUIRED)
find_package (PythonLibs REQUIRED)
find_package (PythonInterp REQUIRED)
find_path(BLAS_INCLUDE_DIRS cblas.h)
find_path(CUDA_COMMON_INCLUDE_DIRS
helper_cuda.h
PATHS ${CUDA_SDK_SEARCH_PATH}
"/Developer/NVIDIA/CUDA-6.0"
"/usr/local/cuda"
PATH_SUFFIXES "samples/common/inc"
DOC "Location of helper_cuda.h"
NO_DEFAULT_PATH
)
if(APPLE)
LIST(APPEND CUDA_NVCC_FLAGS -ccbin /usr/bin/clang)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libstdc++")
endif(APPLE)
#list(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_20,code=sm_20)
list(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_30,code=sm_30)
#list(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_32,code=sm_32)
#list(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_35,code=sm_35)
#list(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_50,code=sm_50)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
list(APPEND CMAKE_CXX_FLAGS -fPIC)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import numpy as n; print(n.get_include());"
RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS
OUTPUT_VARIABLE _NUMPY_VALUES
ERROR_VARIABLE _NUMPY_ERROR_VALUE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(_NUMPY_SEARCH_SUCCESS MATCHES 0)
string(REGEX REPLACE ";" "\\\\;" _NUMPY_VALUES ${_NUMPY_VALUES})
string(REGEX REPLACE "\n" ";" _NUMPY_VALUES ${_NUMPY_VALUES})
list(GET _NUMPY_VALUES 0 NUMPY_INCLUDE_DIRS)
string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS})
else()
message(FATAL_ERROR "NumPy import failure:\n${_NUMPY_ERROR_VALUE}")
endif()
include_directories (
${BLAS_INCLUDE_DIRS}
${CUDA_INCLUDE_DIRS}
${CUDA_COMMON_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
${NUMPY_INCLUDE_DIRS}/numpy
include/common
include/nvmatrix
include/cudaconv2
include/
)
add_subdirectory (src/common)
add_subdirectory (src/nvmatrix)
add_subdirectory (src/cudaconv2)
CUDA_ADD_LIBRARY (convnet SHARED
src/convnet.cu
src/cost.cu
src/data.cu
src/layer.cu
src/layer_kernels.cu
src/neuron.cu
src/pyconvnet.cu
src/util.cu
src/weights.cu
src/worker.cu
)
set_target_properties (convnet
PROPERTIES
PREFIX ""
SUFFIX "_.so"
)
TARGET_LINK_LIBRARIES (convnet
common
nvmatrix
cudaconv2
${PYTHON_LIBRARIES}
${BLAS_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
)
CUDA_BUILD_CLEAN_TARGET()