Reorganising build.gradle for CUDA 12

Signed-off-by: brian <brian@brutex.de>
CUDA12
Brian Rosenberger 2023-08-29 15:18:45 +02:00
parent cbffab0a26
commit 68e778bed0
146 changed files with 22 additions and 35 deletions

View File

@ -53,6 +53,6 @@ public class LoadBackendTests {
@Test @Test
public void loadCudaDLL() { public void loadCudaDLL() {
System.load( System.load(
"C:\\Users\\brian\\_projects\\deeplearning4j\\cavis-native\\cavis-native-lib\\build\\generated\\sources\\javacpp\\cuda\\windows-x86_64-avx2\\jni_nd4jcuda.dll"); "C:\\Users\\brian\\_projects\\deeplearning4j\\cavis-native\\cavis-native-lib\\build\\generated\\sources\\javacpp\\cuda\\windows-x86_64-avx2\\jnind4jcuda.dll");
} }
} }

View File

@ -24,7 +24,9 @@ option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler" OF
set(FLATBUFFERS_BUILD_FLATC "OFF" CACHE STRING "Hack to disable flatc build" FORCE) set(FLATBUFFERS_BUILD_FLATC "OFF" CACHE STRING "Hack to disable flatc build" FORCE)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
set(THREADS_PREFER_PTHREAD_FLAG ON)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
#/////////////////////////////////////////////////////////////////////////////// #///////////////////////////////////////////////////////////////////////////////
@ -364,7 +366,7 @@ if(SD_BUILD_TESTS)
# tests are always compiled with all ops included # tests are always compiled with all ops included
set(SD_ALL_OPS true) set(SD_ALL_OPS true)
set(SD_BUILD_MINIFIER true) set(SD_BUILD_MINIFIER true)
add_subdirectory(tests_cpu) add_subdirectory(src/test/cpp/tests_cpu)
endif() endif()

View File

@ -251,7 +251,8 @@ chipList.each { String thisChip ->
'--chip-extension', avxExtension, '--chip-extension', avxExtension,
'-j', "${host_cores}", '-j', "${host_cores}",
// '--helper', 'mkldnn', // '--helper', 'mkldnn',
'--helper', 'cudnn'] '--helper', 'cudnn',
'--tests']
} else if (thisChip.equals('cuda') && osdetector.os.startsWith("linux")) { //cuDNN requires CUDA } else if (thisChip.equals('cuda') && osdetector.os.startsWith("linux")) { //cuDNN requires CUDA
it.buildCommand = ['bash', 'buildnativeoperations.sh', it.buildCommand = ['bash', 'buildnativeoperations.sh',
'-V', '-V',

View File

@ -216,32 +216,15 @@ if(SD_CUDA)
endif() endif()
endif() endif()
#
#string( TOLOWER "${COMPUTE}" COMPUTE_CMP )
# if ("${COMPUTE_CMP}" STREQUAL "all")
# CUDA_SELECT_NVCC_ARCH_FLAGS(CUDA_ARCH_FLAGS "Common")
# elseif("${COMPUTE_CMP}" STREQUAL "auto")
# CUDA_SELECT_NVCC_ARCH_FLAGS(CUDA_ARCH_FLAGS "Auto")
# elseif(COMPUTE_CMP MATCHES "^[0-9]+$")
# #matches USER COMPUTE old way
#set(CUDA_ARCH_FLAGS "-gencode arch=compute_${COMPUTE},code=sm_${COMPUTE} ")
# else()
# #matches numbers NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX
# #NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal
# #NUM: 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 et cetera
# CUDA_SELECT_NVCC_ARCH_FLAGS(CUDA_ARCH_FLAGS "${COMPUTE}")
# endif()
# list to spaces
#string (REPLACE ";" " " CUDA_ARCH_FLAGS "${CUDA_ARCH_FLAGS}")
#set(CMAKE_CUDA_FLAGS " ${CMAKE_CUDA_FLAGS} -DCUDA_VERSION_MAJOR=${CUDA_VERSION_MAJOR} ${EXPM} -w --cudart=static --expt-extended-lambda -Xfatbin -compress-all ") #set(CMAKE_CUDA_FLAGS " ${CMAKE_CUDA_FLAGS} -DCUDA_VERSION_MAJOR=${CUDA_VERSION_MAJOR} ${EXPM} -w --cudart=static --expt-extended-lambda -Xfatbin -compress-all ")
set(CMAKE_CUDA_ARCHITECTURES OFF) set(CMAKE_CUDA_ARCHITECTURES "all-major")
set(CMAKE_CUDA_RUNTIME_LIBRARY "shared")
#set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code \"arch=compute_53,code=[compute_53,sm_53]\" " ) #set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code \"arch=compute_53,code=[compute_53,sm_53]\" " )
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code \"arch=compute_61,code=[compute_61,sm_61]\" " ) #set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code \"arch=compute_61,code=[compute_61,sm_61]\" " )
#set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code \"arch=compute_75,code=[compute_75,sm_75]\" " ) #set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code \"arch=compute_75,code=[compute_75,sm_75]\" " )
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda ") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda ")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr ") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr ")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DCUDA_VERSION_MAJOR=12 -w --cudart=static -Xfatbin -compress-all") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DCUDA_VERSION_MAJOR=12 -w -Xfatbin -compress-all")
set(CUDAHOSTCXX "${CMAKE_CXX_COMPILER}") set(CUDAHOSTCXX "${CMAKE_CXX_COMPILER}")
if(WIN32) if(WIN32)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=/EHsc") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=/EHsc")

View File

@ -1,5 +1,5 @@
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) include_directories(../../../../../src/main/cpp/blas)
if(LINUX) if(LINUX)
link_directories(/usr/local/lib) link_directories(/usr/local/lib)
link_directories(/usr/lib) link_directories(/usr/lib)
@ -22,9 +22,13 @@ if(WIN32)
endif() endif()
if (SD_CUDA) if (SD_CUDA)
find_package(CUDA) find_package(CUDAToolkit 12.2 REQUIRED)
message("Tests CUDA include directory: ${CUDA_INCLUDE_DIRS}") enable_language(CUDA)
include_directories(${CUDA_INCLUDE_DIRS})
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CXX_STANDARD 14)
message("Tests CUDA include directory: ${CUDAToolkit_INCLUDE_DIRS}")
include_directories(${CUDAToolkit_INCLUDE_DIRS})
add_definitions(-D__CUDABLAS__=true) add_definitions(-D__CUDABLAS__=true)
if(WIN32) if(WIN32)
@ -34,17 +38,14 @@ if (SD_CUDA)
string( TOLOWER "${COMPUTE}" COMPUTE_CMP ) string( TOLOWER "${COMPUTE}" COMPUTE_CMP )
if ("${COMPUTE_CMP}" STREQUAL "all") if ("${COMPUTE_CMP}" STREQUAL "all")
CUDA_SELECT_NVCC_ARCH_FLAGS(CUDA_ARCH_FLAGS "Common") set(CMAKE_CUDA_ARCHITECTURES "all")
elseif("${COMPUTE_CMP}" STREQUAL "auto") elseif("${COMPUTE_CMP}" STREQUAL "auto")
CUDA_SELECT_NVCC_ARCH_FLAGS(CUDA_ARCH_FLAGS "Auto") set(CMAKE_CUDA_ARCHITECTURES "all-major")
elseif(COMPUTE_CMP MATCHES "^[0-9]+$")
#matches USER COMPUTE old way
set(CUDA_ARCH_FLAGS "-gencode arch=compute_${COMPUTE},code=sm_${COMPUTE} ")
else() else()
#matches numbers NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX #matches numbers NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX
#NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal #NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal
#NUM: 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 et cetera #NUM: 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 et cetera
CUDA_SELECT_NVCC_ARCH_FLAGS(CUDA_ARCH_FLAGS "${COMPUTE}") set(CMAKE_CUDA_ARCHITECTURES "all")
endif() endif()
# list to spaces # list to spaces
string (REPLACE ";" " " CUDA_ARCH_FLAGS "${CUDA_ARCH_FLAGS}") string (REPLACE ";" " " CUDA_ARCH_FLAGS "${CUDA_ARCH_FLAGS}")

Some files were not shown because too many files have changed in this diff Show More