From 3463b81d37e86b2dccc34ed68c76ab0398081e8f Mon Sep 17 00:00:00 2001 From: brian Date: Tue, 15 Aug 2023 14:50:59 +0200 Subject: [PATCH] Update to CUDA 12 Signed-off-by: brian --- .docker/Dockerfile | 2 +- .../ai/nd4j/tests/LoadBackendTests.java | 17 ++++++++++------ cavis-native/cavis-native-lib/CMakeLists.txt | 2 +- .../src/main/cpp/blas/CMakeLists.txt | 20 +++++++++---------- .../nd4j/nativeblas/cuda/Nd4jCudaPresets.java | 4 ++-- createTestBackends.gradle | 2 +- 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 7a61d6969..16cf5e67c 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -14,7 +14,7 @@ RUN add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/r RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y openjdk-11-jdk \ + DEBIAN_FRONTEND=noninteractive apt-get install -y openjdk-11-jdk cuda-12-2 \ build-essential checkinstall zlib1g-dev libssl-dev git libpthread-stubs0-dev \ libcudnn8=${cudnn_version}-1+${cuda_version} libcudnn8-dev=${cudnn_version}-1+${cuda_version} diff --git a/brutex-extended-tests/src/test/java/net/brutex/ai/nd4j/tests/LoadBackendTests.java b/brutex-extended-tests/src/test/java/net/brutex/ai/nd4j/tests/LoadBackendTests.java index 4ce2844d5..70ade3485 100644 --- a/brutex-extended-tests/src/test/java/net/brutex/ai/nd4j/tests/LoadBackendTests.java +++ b/brutex-extended-tests/src/test/java/net/brutex/ai/nd4j/tests/LoadBackendTests.java @@ -22,6 +22,7 @@ package net.brutex.ai.nd4j.tests; import lombok.extern.slf4j.Slf4j; +import org.bytedeco.javacpp.Loader; import org.junit.jupiter.api.Test; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.factory.Nd4j; @@ -37,12 +38,16 @@ public class LoadBackendTests { @Test public void loadBackend() throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException { - // check if Nd4j is there - //Logger.getLogger(LoadBackendTests.class.getName()).info("System java.library.path: " + System.getProperty("java.library.path")); - final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths"); - sysPathsField.setAccessible(true); - sysPathsField.set(null, null); - //System.loadLibrary("jnind4jcpu"); + // check if Nd4j is there + Logger.getLogger(LoadBackendTests.class.getName()).info("System java.library.path: " + + System.getProperty("java.library.path")); + // final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths"); + // sysPathsField.setAccessible(true); + // sysPathsField.set(null, null); + // System.loadLibrary("jnind4jcuda"); + //Loader.load(); + //Loader.loadGlobal("nd4jcuda.dll"); + //log.info("Loaded directly, complete."); log.info("Backend: {}", Nd4j.getBackend().buildInfo()); double d1 = 2.0; double d2 = 5.0; diff --git a/cavis-native/cavis-native-lib/CMakeLists.txt b/cavis-native/cavis-native-lib/CMakeLists.txt index 42f002722..f1b9c1091 100644 --- a/cavis-native/cavis-native-lib/CMakeLists.txt +++ b/cavis-native/cavis-native-lib/CMakeLists.txt @@ -121,7 +121,7 @@ endfunction() if (SD_CUDA) #enable_language(CUDA) - find_package(CUDAToolkit 12.2 REQUIRED) + find_package(CUDAToolkit 12.2 REQUIRED) message(STATUS "CUDAToolkit_VERSION: ${CUDAToolkit_VERSION}") message(STATUS "CUDAToolkit_VERSION_MAJOR: ${CUDAToolkit_VERSION_MAJOR}") message(STATUS "CUDAToolkit_VERSION_MINOR: ${CUDAToolkit_VERSION_MINOR}") diff --git a/cavis-native/cavis-native-lib/src/main/cpp/blas/CMakeLists.txt b/cavis-native/cavis-native-lib/src/main/cpp/blas/CMakeLists.txt index fcf367d31..7755b69bd 100644 --- a/cavis-native/cavis-native-lib/src/main/cpp/blas/CMakeLists.txt +++ b/cavis-native/cavis-native-lib/src/main/cpp/blas/CMakeLists.txt @@ -203,16 +203,16 @@ if(SD_CUDA) set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=-fPIC") endif() - if(WIN32) - message("In windows, setting cublas library and cusolver library") - if(NOT DEFINED CUDA_cublas_LIBRARY) - set(CUDA_cublas_LIBRARY ${CUDA_HOME}/lib/x64/cublas.lib) - endif() - - if(NOT DEFINED CUDA_cusolver_LIBRARY) - set(CUDA_cusolver_LIBRARY ${CUDA_HOME}/lib/x64/cusolver.lib) - endif() - endif() +# if(WIN32) + # message("In windows, setting cublas library and cusolver library") + # if(NOT DEFINED CUDA_cublas_LIBRARY) + # set(CUDA_cublas_LIBRARY ${CUDA_HOME}/lib/x64/cublas.lib) + # endif() +# +# if(NOT DEFINED CUDA_cusolver_LIBRARY) +# set(CUDA_cusolver_LIBRARY ${CUDA_HOME}/lib/x64/cusolver.lib) +# endif() +# endif() # #string( TOLOWER "${COMPUTE}" COMPUTE_CMP ) diff --git a/cavis-native/cavis-native-lib/src/main/java/org/nd4j/nativeblas/cuda/Nd4jCudaPresets.java b/cavis-native/cavis-native-lib/src/main/java/org/nd4j/nativeblas/cuda/Nd4jCudaPresets.java index 5a363a962..c9fb737a4 100644 --- a/cavis-native/cavis-native-lib/src/main/java/org/nd4j/nativeblas/cuda/Nd4jCudaPresets.java +++ b/cavis-native/cavis-native-lib/src/main/java/org/nd4j/nativeblas/cuda/Nd4jCudaPresets.java @@ -148,9 +148,9 @@ public class Nd4jCudaPresets implements LoadEnabled, InfoMapper { "cudnn_adv_train", "cudnn_cnn_infer", "cudnn_cnn_train"}; for (String lib : libs) { if (platform.startsWith("linux")) { - lib += lib.startsWith("cudnn") ? "@.8" : lib.equals("curand") ? "@.10" : lib.equals("cudart") ? "@.11.0" : "@.11"; + lib += lib.startsWith("cudnn") ? "@.8" : lib.equals("curand") ? "@.10" : lib.equals("cufft") ? "@.11" : "@.12"; } else if (platform.startsWith("windows")) { - lib += lib.startsWith("cudnn") ? "64_8" : lib.equals("cufft") ? "64_11" : lib.equals("cusolver") ? "64_11" : "64_12"; + lib += lib.startsWith("cudnn") ? "64_8" : lib.equals("cufft") ? "64_11" : lib.equals("cusolver") ? "64_11" : lib.equals("curand") ? "64_10" : "64_12"; } else { continue; // no CUDA } diff --git a/createTestBackends.gradle b/createTestBackends.gradle index 638e511e2..b33853092 100644 --- a/createTestBackends.gradle +++ b/createTestBackends.gradle @@ -87,7 +87,7 @@ ext { cudaTestRuntime group: "org.bytedeco", name: "openblas", classifier: buildTarget cudaTestRuntime group: "org.bytedeco", name: "cuda" cudaTestRuntime group: "org.bytedeco", name: "cuda", classifier: buildTarget - cudaTestRuntime group: "org.bytedeco", name: "cuda", classifier: "${buildTarget}-redist" + //cudaTestRuntime group: "org.bytedeco", name: "cuda", classifier: "${buildTarget}-redist" cudaTestRuntime (project( path: ":cavis-native:cavis-native-lib", configuration: "cudaSupportRuntimeElements")) /* cudaTestRuntime(project(":cavis-native:cavis-native-lib")) {