Update to CUDA 12

Signed-off-by: brian <brian@brutex.de>
CUDA12
Brian Rosenberger 2023-08-15 14:50:59 +02:00
parent d5eda7d4de
commit 3463b81d37
6 changed files with 26 additions and 21 deletions

View File

@ -14,7 +14,7 @@ RUN add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/r
RUN apt-get update && \ 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 \ build-essential checkinstall zlib1g-dev libssl-dev git libpthread-stubs0-dev \
libcudnn8=${cudnn_version}-1+${cuda_version} libcudnn8-dev=${cudnn_version}-1+${cuda_version} libcudnn8=${cudnn_version}-1+${cuda_version} libcudnn8-dev=${cudnn_version}-1+${cuda_version}

View File

@ -22,6 +22,7 @@
package net.brutex.ai.nd4j.tests; package net.brutex.ai.nd4j.tests;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.bytedeco.javacpp.Loader;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.Nd4j; import org.nd4j.linalg.factory.Nd4j;
@ -37,12 +38,16 @@ public class LoadBackendTests {
@Test @Test
public void loadBackend() throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException { public void loadBackend() throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
// check if Nd4j is there // check if Nd4j is there
//Logger.getLogger(LoadBackendTests.class.getName()).info("System java.library.path: " + System.getProperty("java.library.path")); Logger.getLogger(LoadBackendTests.class.getName()).info("System java.library.path: " +
final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths"); System.getProperty("java.library.path"));
sysPathsField.setAccessible(true); // final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths");
sysPathsField.set(null, null); // sysPathsField.setAccessible(true);
//System.loadLibrary("jnind4jcpu"); // sysPathsField.set(null, null);
// System.loadLibrary("jnind4jcuda");
//Loader.load();
//Loader.loadGlobal("nd4jcuda.dll");
//log.info("Loaded directly, complete.");
log.info("Backend: {}", Nd4j.getBackend().buildInfo()); log.info("Backend: {}", Nd4j.getBackend().buildInfo());
double d1 = 2.0; double d1 = 2.0;
double d2 = 5.0; double d2 = 5.0;

View File

@ -121,7 +121,7 @@ endfunction()
if (SD_CUDA) if (SD_CUDA)
#enable_language(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: ${CUDAToolkit_VERSION}")
message(STATUS "CUDAToolkit_VERSION_MAJOR: ${CUDAToolkit_VERSION_MAJOR}") message(STATUS "CUDAToolkit_VERSION_MAJOR: ${CUDAToolkit_VERSION_MAJOR}")
message(STATUS "CUDAToolkit_VERSION_MINOR: ${CUDAToolkit_VERSION_MINOR}") message(STATUS "CUDAToolkit_VERSION_MINOR: ${CUDAToolkit_VERSION_MINOR}")

View File

@ -203,16 +203,16 @@ if(SD_CUDA)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=-fPIC") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=-fPIC")
endif() endif()
if(WIN32) # if(WIN32)
message("In windows, setting cublas library and cusolver library") # message("In windows, setting cublas library and cusolver library")
if(NOT DEFINED CUDA_cublas_LIBRARY) # if(NOT DEFINED CUDA_cublas_LIBRARY)
set(CUDA_cublas_LIBRARY ${CUDA_HOME}/lib/x64/cublas.lib) # set(CUDA_cublas_LIBRARY ${CUDA_HOME}/lib/x64/cublas.lib)
endif() # endif()
#
if(NOT DEFINED CUDA_cusolver_LIBRARY) # if(NOT DEFINED CUDA_cusolver_LIBRARY)
set(CUDA_cusolver_LIBRARY ${CUDA_HOME}/lib/x64/cusolver.lib) # set(CUDA_cusolver_LIBRARY ${CUDA_HOME}/lib/x64/cusolver.lib)
endif() # endif()
endif() # endif()
# #
#string( TOLOWER "${COMPUTE}" COMPUTE_CMP ) #string( TOLOWER "${COMPUTE}" COMPUTE_CMP )

View File

@ -148,9 +148,9 @@ public class Nd4jCudaPresets implements LoadEnabled, InfoMapper {
"cudnn_adv_train", "cudnn_cnn_infer", "cudnn_cnn_train"}; "cudnn_adv_train", "cudnn_cnn_infer", "cudnn_cnn_train"};
for (String lib : libs) { for (String lib : libs) {
if (platform.startsWith("linux")) { 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")) { } 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 { } else {
continue; // no CUDA continue; // no CUDA
} }

View File

@ -87,7 +87,7 @@ ext {
cudaTestRuntime group: "org.bytedeco", name: "openblas", classifier: buildTarget cudaTestRuntime group: "org.bytedeco", name: "openblas", classifier: buildTarget
cudaTestRuntime group: "org.bytedeco", name: "cuda" cudaTestRuntime group: "org.bytedeco", name: "cuda"
cudaTestRuntime group: "org.bytedeco", name: "cuda", classifier: buildTarget 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( path: ":cavis-native:cavis-native-lib", configuration: "cudaSupportRuntimeElements"))
/* /*
cudaTestRuntime(project(":cavis-native:cavis-native-lib")) { cudaTestRuntime(project(":cavis-native:cavis-native-lib")) {