-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
62 lines (48 loc) · 1.95 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
cmake_minimum_required(VERSION 3.28)
# Set CUDA compiler before project() declaration
set(CMAKE_CUDA_COMPILER /usr/bin/nvcc)
# Enable CUDA first
enable_language(CUDA)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
# Then declare project with languages
project(DeepL LANGUAGES CXX CUDA)
# CUDA architecture settings
set(CMAKE_CUDA_ARCHITECTURES 75)
set(CMAKE_CXX_STANDARD 17)
# Make sure CUDA can find its headers
include_directories("/usr/local/cuda/include") # Add this line
set(PYTHON_MODULE_NAME deepl)
set(CPP_LIBRARY_NAME deepl_cpp)
set(CUDA_SOURCES src/tensor.cu)
set(CPP_SOURCES src/Graph.cpp src/Layer.cpp src/Loss.cpp src/Optimizer.cpp src/Utils.cpp src/GradMode.cpp)
list(APPEND CMAKE_PREFIX_PATH "/home/ak6913/miniconda3/envs/deeplnrn/lib/python3.12/site-packages/pybind11/share/cmake")
# Find required packages
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
find_package(pybind11 REQUIRED)
find_package(CUDAToolkit REQUIRED)
# Python module
pybind11_add_module(${PYTHON_MODULE_NAME} src/deeplearning.cpp ${CUDA_SOURCES} ${CPP_SOURCES})
set_target_properties(${PYTHON_MODULE_NAME} PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
POSITION_INDEPENDENT_CODE ON
)
# Add CUDA include directories explicitly
target_include_directories(${PYTHON_MODULE_NAME} PRIVATE
${Python3_INCLUDE_DIRS}
${pybind11_INCLUDE_DIRS}
${CUDAToolkit_INCLUDE_DIRS} # Add this line
${CMAKE_SOURCE_DIR}/src
)
target_link_libraries(${PYTHON_MODULE_NAME} PRIVATE CUDA::cudart CUDA::cuda_driver)
# C++ library
add_library(${CPP_LIBRARY_NAME} STATIC ${CUDA_SOURCES} ${CPP_SOURCES})
set_target_properties(${CPP_LIBRARY_NAME} PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
POSITION_INDEPENDENT_CODE ON
)
target_include_directories(${CPP_LIBRARY_NAME} PRIVATE
${CUDAToolkit_INCLUDE_DIRS} # Add this line
${CMAKE_SOURCE_DIR}/src
)
target_link_libraries(${CPP_LIBRARY_NAME} PRIVATE CUDA::cudart CUDA::cuda_driver)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)