Reorganising build.gradle for CUDA 12

Signed-off-by: brian <brian@brutex.de>
CUDA12
Brian Rosenberger 2023-08-28 09:35:18 +02:00
parent a63bee1b94
commit 150133602b
21 changed files with 213 additions and 308 deletions

View File

@ -24,6 +24,7 @@ package net.brutex.ai.nd4j.tests;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.bytedeco.javacpp.Loader; import org.bytedeco.javacpp.Loader;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.nd4j.linalg.api.environment.Nd4jEnvironment;
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;
@ -38,16 +39,7 @@ public class LoadBackendTests {
@Test @Test
public void loadBackend() throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException { public void loadBackend() throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
// check if Nd4j is there log.info("get number of GPUs {}", Nd4jEnvironment.getEnvironment().getNumGpus());
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()); log.info("Backend: {}", Nd4j.getBackend().buildInfo());
double d1 = 2.0; double d1 = 2.0;
double d2 = 5.0; double d2 = 5.0;

View File

@ -23,7 +23,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath "com.vanniktech:gradle-dependency-graph-generator-plugin:0.6.0" classpath "com.vanniktech:gradle-dependency-graph-generator-plugin:0.8.0"
classpath 'com.google.gradle:osdetector-gradle-plugin:1.7.0' classpath 'com.google.gradle:osdetector-gradle-plugin:1.7.0'
} }
} }

View File

@ -48,9 +48,9 @@ dependencies {
constraints { constraints {
api enforcedPlatform("io.netty:netty-bom:${netty.version}") api ("io.netty:netty-bom:${netty.version}")
api enforcedPlatform("com.fasterxml.jackson:jackson-bom:${jackson.version}") api ("com.fasterxml.jackson:jackson-bom:${jackson.version}")
api enforcedPlatform("com.squareup.okhttp3:okhttp-bom:${okhttp3.version}") api ("com.squareup.okhttp3:okhttp-bom:${okhttp3.version}")
api 'com.google.guava:guava:30.1-jre' api 'com.google.guava:guava:30.1-jre'
api "com.google.protobuf:protobuf-java:3.15.6" api "com.google.protobuf:protobuf-java:3.15.6"
@ -105,6 +105,7 @@ dependencies {
api "org.bytedeco:javacv:${javacv.version}" api "org.bytedeco:javacv:${javacv.version}"
api "org.bytedeco:opencv:${opencv.version}-${javacpp.presetsVersion}" api "org.bytedeco:opencv:${opencv.version}-${javacpp.presetsVersion}"
api "org.bytedeco:openblas:${openblas.version}-${javacpp.presetsVersion}" api "org.bytedeco:openblas:${openblas.version}-${javacpp.presetsVersion}"
api "org.bytedeco:openblas-platform:${openblas.version}-${javacpp.presetsVersion}"
api "org.bytedeco:leptonica-platform:${leptonica.version}-${javacpp.presetsVersion}" api "org.bytedeco:leptonica-platform:${leptonica.version}-${javacpp.presetsVersion}"
api "org.bytedeco:hdf5-platform:${hdf5.version}-${javacpp.presetsVersion}" api "org.bytedeco:hdf5-platform:${hdf5.version}-${javacpp.presetsVersion}"
api "org.bytedeco:hdf5:${hdf5.version}-${javacpp.presetsVersion}" api "org.bytedeco:hdf5:${hdf5.version}-${javacpp.presetsVersion}"

View File

@ -19,5 +19,4 @@
# #
# #
#org.nd4j.linalg.jcublas.JCublasBackend
org.nd4j.linalg.cpu.nativecpu.CpuBackend org.nd4j.linalg.cpu.nativecpu.CpuBackend

View File

@ -13,7 +13,7 @@ dependencies {
implementation projects.cavisNative.cavisNativeCommon implementation projects.cavisNative.cavisNativeCommon
implementation projects.cavisDnn.cavisDnnApi implementation projects.cavisDnn.cavisDnnApi
implementation projects.cavisDnn.cavisDnnCommon implementation projects.cavisDnn.cavisDnnCommon
implementation projects.cavisNative.cavisNativeCpuPresets
implementation (projects.cavisNative.cavisNativeLib) { implementation (projects.cavisNative.cavisNativeLib) {
capabilities { capabilities {

View File

@ -10,22 +10,24 @@ ext {
dependencies { dependencies {
implementation platform(projects.cavisCommonPlatform) implementation platform(projects.cavisCommonPlatform)
//implementation project(":cavis-native:cavis-native-blas")
implementation projects.cavisNative.cavisNativeBlas implementation projects.cavisNative.cavisNativeBlas
implementation group: "org.bytedeco", name: "cuda" implementation group: "org.bytedeco", name: "cuda"
implementation group: "org.bytedeco", name: "cuda", classifier: buildTarget implementation group: "org.bytedeco", name: "cuda", classifier: buildTarget
implementation group: "org.bytedeco", name: "cuda", classifier: "${buildTarget}-redist" //implementation group: "org.bytedeco", name: "cuda", classifier: "${buildTarget}-redist"
implementation group: "org.bytedeco", name: "javacpp" implementation group: "org.bytedeco", name: "javacpp"
implementation group: "org.bytedeco", name: "javacpp", classifier: buildTarget implementation group: "org.bytedeco", name: "javacpp", classifier: buildTarget
implementation(project(path: ":cavis-native:cavis-native-lib")) { implementation projects.cavisNative.cavisNativeCudaPresets
//implementation name: "cavis-native:cavis-native-lib", configuration: "cuda"
implementation(project(":cavis-native:cavis-native-lib")) {
capabilities { capabilities {
it.requireCapability(group: "net.brutex.cavis.cavis-native", name: "cavis-native-lib-cuda-support", version:project.version) requireCapability("${project.group}:cavis-native-lib-cuda-support:${project.version}")
} }
} }
implementation project(":cavis-native:cavis-native-common") implementation project(":cavis-native:cavis-native-common")
implementation project(":cavis-dnn:cavis-dnn-api") implementation project(":cavis-dnn:cavis-dnn-api")
implementation project(":cavis-dnn:cavis-dnn-common") implementation project(":cavis-dnn:cavis-dnn-common")
@ -36,3 +38,9 @@ dependencies {
implementation "org.apache.commons:commons-lang3" implementation "org.apache.commons:commons-lang3"
} }
tasks.named("compileJava").configure {
dependsOn ":cavis-native:cavis-native-lib:javacppCudaSupportBuildParser",
":cavis-native:cavis-native-lib:compileCudaGeneratedJava"
}

View File

@ -1,3 +1,5 @@
import org.gradle.api.internal.java.DefaultJavaPlatformExtension
import org.gradle.api.plugins.internal.DefaultJavaPluginExtension
import org.gradle.api.publish.maven.internal.publisher.MavenRemotePublisher import org.gradle.api.publish.maven.internal.publisher.MavenRemotePublisher
import org.gradle.language.nativeplatform.internal.Dimensions import org.gradle.language.nativeplatform.internal.Dimensions
@ -44,8 +46,7 @@ buildscript {
logger.info("Setting properties for task '{}' to '{}'", tsk.getName(), pf) logger.info("Setting properties for task '{}' to '{}'", tsk.getName(), pf)
return pf return pf
} }
} // End of ext block
}
dependencies { dependencies {
@ -64,104 +65,101 @@ buildscript {
plugins { plugins {
id 'java-library' id 'java-library'
id 'org.bytedeco.gradle-javacpp-build' version "1.5.9" id 'org.bytedeco.gradle-javacpp-build' version "1.5.10-SNAPSHOT"
id 'maven-publish' id 'maven-publish'
id 'signing' id 'signing'
} }
chipList.each {thisChip -> chipList.each {String thisChip ->
sourceSets.register("${thisChip}Support") { sourceSets.register(thisChip) {
java { java {
srcDirs = ['src/main/java', "${buildDir}/generated/sources/javacpp/${thisChip}//${javacppPlatform}${javacppPlatformExtension}/"] srcDirs = ["${projectDir}/src/main/java/"]
include "org/nd4j/nativeblas/${thisChip}/Nd4j${thisChip.capitalize()}Helper.java" include "org/nd4j/nativeblas/${thisChip}/Nd4j${thisChip.capitalize()}Helper.java"
include "org/nd4j/nativeblas/${thisChip}/Nd4j${thisChip.capitalize()}Presets.java" include "org/nd4j/nativeblas/${thisChip}/Nd4j${thisChip.capitalize()}Presets.java"
}
java.destinationDirectory.set(file("${projectDir}/build/classes/java/main/"))
}
sourceSets.register("${thisChip}Generated") {
java {
srcDirs = ["${buildDir}/generated/sources/javacpp/${thisChip}/${javacppPlatform}${javacppPlatformExtension}/"]
include "org/nd4j/nativeblas/Nd4j${thisChip.capitalize()}.java" include "org/nd4j/nativeblas/Nd4j${thisChip.capitalize()}.java"
} }
it.compiledBy("javacpp${thisChip.capitalize()}SupportBuildCommand", java.destinationDirectory.set(file("${projectDir}/build/classes/java/main/"))
"javacpp${thisChip.capitalize()}SupportBuildCompiler")
} }
} }
/*
//if(osdetector.os.startsWith("windows")) { sourceSets {
sourceSets { main {
main { java {
java { srcDirs = new HashSet<>();
srcDirs = ['src/main/java'] include 'org/nd4j/nativeblas/Dummy.java'
include 'org/nd4j/nativeblas/Dummy.java'
}
} }
} }
//} }
*/
// This block registers the cpu and cuda features and creates
// i. e. the {chip}Implementation
java { java {
chipList.each {thisChip -> chipList.each {thisChip ->
registerFeature("${thisChip}Support") { registerFeature("${thisChip}Support") {
usingSourceSet(sourceSets.findByName("${thisChip}Support")) usingSourceSet(sourceSets.findByName("${thisChip}"))
capability(project.group, "cavis-native-lib-${thisChip}-support", project.version) capability(project.group, "cavis-native-lib-${thisChip}-support", project.version)
//withJavadocJar() //withJavadocJar()
//withSourcesJar() //withSourcesJar()
} }}}
}
}
dependencies { dependencies {
api platform(project(':cavis-common-platform'))
implementation "org.bytedeco:javacpp"
implementation group: "org.bytedeco", name: "javacpp", classifier: "${javacppPlatform}"
if(withCuda()) { if(withCuda()) {
cudaSupportImplementation platform(project(':cavis-common-platform')) cudaImplementation platform(project(':cavis-common-platform'))
cudaSupportImplementation project(":cavis-dnn:cavis-dnn-api")
cudaSupportImplementation project(":cavis-dnn:cavis-dnn-common") //cudaImplementation project(":cavis-dnn:cavis-dnn-api")
cudaSupportImplementation project(":cavis-native:cavis-native-blas") //cudaImplementation project(":cavis-dnn:cavis-dnn-common")
cudaSupportImplementation project(":cavis-native:cavis-native-common") cudaImplementation project(":cavis-native:cavis-native-blas")
cudaSupportImplementation "commons-io:commons-io" //cudaImplementation project(":cavis-native:cavis-native-common")
cudaSupportImplementation group: "org.bytedeco", name: "openblas" //cudaImplementation "commons-io:commons-io"
cudaSupportImplementation group: "org.bytedeco", name: "openblas", classifier: "${javacppPlatform}" //cudaImplementation "org.bytedeco:openblas"
cudaSupportImplementation group: "org.bytedeco", name: "cuda" //cudaImplementation "org.bytedeco:openblas::${javacppPlatform}"
cudaSupportImplementation group: "org.bytedeco", name: "cuda", classifier: "${javacppPlatform}" //cudaImplementation "org.bytedeco:cuda"
cudaSupportImplementation "org.apache.logging.log4j:log4j-core:2.17.0" //cudaImplementation "org.bytedeco:cuda::${javacppPlatform}"
cudaSupportImplementation "com.google.guava:guava:14.0.1" //cudaImplementation "org.apache.logging.log4j:log4j-core:2.17.0"
cudaSupportImplementation "org.apache.commons:commons-lang3" //cudaImplementation "com.google.guava:guava:14.0.1"
cudaSupportImplementation "org.apache.commons:commons-math3" //cudaImplementation "org.apache.commons:commons-lang3"
cudaSupportImplementation "com.google.flatbuffers:flatbuffers-java" //cudaImplementation "org.apache.commons:commons-math3"
cudaSupportImplementation 'javax.mail:javax.mail-api:1.6.2' //cudaImplementation "com.google.flatbuffers:flatbuffers-java"
//cudaImplementation 'javax.mail:javax.mail-api:1.6.2'
cudaImplementation "org.bytedeco:javacpp"
cudaImplementation "org.bytedeco:javacpp::${javacppPlatform}"
cudaImplementation project(":cavis-native:cavis-native-cuda-presets")
cudaGeneratedImplementation platform(project(':cavis-common-platform'))
cudaGeneratedImplementation project(":cavis-native:cavis-native-blas")
cudaGeneratedImplementation "org.bytedeco:javacpp"
cudaGeneratedImplementation "org.bytedeco:javacpp::${javacppPlatform}"
cudaGeneratedImplementation project(":cavis-native:cavis-native-cuda-presets")
} }
if(withCpu()) { if(withCpu()) {
cpuSupportImplementation platform(project(':cavis-common-platform')) cpuImplementation platform(project(':cavis-common-platform'))
cpuSupportImplementation project(":cavis-dnn:cavis-dnn-api") //cpuImplementation project(":cavis-dnn:cavis-dnn-api")
cpuSupportImplementation project(":cavis-dnn:cavis-dnn-common") //cpuImplementation project(":cavis-dnn:cavis-dnn-common")
cpuSupportImplementation project(":cavis-native:cavis-native-blas") //cpuImplementation project(":cavis-native:cavis-native-blas")
cpuSupportImplementation project(":cavis-native:cavis-native-common") //cpuImplementation project(":cavis-native:cavis-native-common")
cpuSupportImplementation "commons-io:commons-io" //cpuImplementation "commons-io:commons-io"
cpuSupportImplementation group: "org.bytedeco", name: "openblas" //cpuImplementation "org.bytedeco:opencv"
cpuSupportImplementation group: "org.bytedeco", name: "openblas", classifier: "${javacppPlatform}" //cpuImplementation "org.bytedeco:opencv::${javacppPlatform}"
cpuSupportImplementation group: "org.bytedeco", name: "opencv" //cpuImplementation "org.apache.logging.log4j:log4j-core:2.17.0"
cpuSupportImplementation group: "org.bytedeco", name: "opencv", classifier: "${javacppPlatform}" //cpuImplementation "com.google.guava:guava:14.0.1"
cpuSupportImplementation "org.apache.logging.log4j:log4j-core:2.17.0" //cpuImplementation "org.apache.commons:commons-lang3"
cpuSupportImplementation "com.google.guava:guava:14.0.1" //cpuImplementation "org.apache.commons:commons-math3"
cpuSupportImplementation "org.apache.commons:commons-lang3" //cpuImplementation "com.google.flatbuffers:flatbuffers-java"
cpuSupportImplementation "org.apache.commons:commons-math3" //cpuImplementation 'javax.mail:javax.mail-api:1.6.2'
cpuSupportImplementation "com.google.flatbuffers:flatbuffers-java" //cpuImplementation "org.bytedeco:javacpp"
cpuSupportImplementation 'javax.mail:javax.mail-api:1.6.2' //cpuImplementation "org.bytedeco:javacpp::${javacppPlatform}"
cpuImplementation project(":cavis-native:cavis-native-cpu-presets")
} }
implementation projects.cavisDnn.cavisDnnApi
implementation projects.cavisDnn.cavisDnnCommon
implementation project(":cavis-native:cavis-native-blas")
implementation project(":cavis-native:cavis-native-common")
implementation "commons-io:commons-io"
implementation "org.bytedeco:openblas"
implementation group: "org.bytedeco", name: "openblas", classifier: "${javacppPlatform}"
implementation "org.apache.logging.log4j:log4j-core"
implementation "com.google.guava:guava:14.0.1"
implementation "org.apache.commons:commons-lang3"
implementation "org.apache.commons:commons-math3"
implementation "com.google.flatbuffers:flatbuffers-java"
} }
@ -183,40 +181,31 @@ task deepClean(type: Delete) {
} }
tasks.withType(org.bytedeco.gradle.javacpp.BuildTask) { tasks.withType(org.bytedeco.gradle.javacpp.BuildTask).configureEach { org.bytedeco.gradle.javacpp.BuildTask it ->
buildResource = [ "/org/bytedeco/openblas/${javacppPlatform}/", it.buildResource = ["/org/bytedeco/openblas/${javacppPlatform}/",
"/org/bytedeco/mkldnn/${javacppPlatform}/"] "/org/bytedeco/mkldnn/${javacppPlatform}/"]
includeResource = ["/org/bytedeco/openblas/${javacppPlatform}/include/"]
linkResource = ["/org/bytedeco/openblas/${javacppPlatform}/",
"/org/bytedeco/openblas/${javacppPlatform}/lib/"]
//buildPath = [ org.bytedeco.javacpp.Loader.getCacheDir() ]
it.includeResource = ["/org/bytedeco/openblas/${javacppPlatform}/include/"]
it.linkResource = ["/org/bytedeco/openblas/${javacppPlatform}/",
"/org/bytedeco/openblas/${javacppPlatform}/lib/"]
} }
// Disable the standard javacpp generated tasks and use own // Disable the standard javacpp generated tasks and use own
// versions below. This allows to build for each variant // versions below. This allows to build for each variant
[javacppBuildParser, javacppBuildCommand, javacppCompileJava, javacppBuildCompiler].each { [javacppBuildParser, javacppBuildCommand, javacppCompileJava, javacppBuildCompiler].each {
it.enabled false it.enabled false
} }
chipList.each { thisChip -> chipList.each { String thisChip ->
// 1) // 1)
//Run the C++ compile first //Run the C++ compile first
tasks.register("javacpp${thisChip.capitalize()}SupportBuildCommand", org.bytedeco.gradle.javacpp.BuildTask) { tasks.register("javacpp${thisChip.capitalize()}SupportBuildCommand", org.bytedeco.gradle.javacpp.BuildTask) {org.bytedeco.gradle.javacpp.BuildTask it ->
if (project.hasProperty("skip-native") && project.getProperty("skip-native").equals("true")) {
enabled = false
}
dependsOn "processResources"
properties = getBuildPlatform( thisChip, it ) properties = getBuildPlatform( thisChip, it )
includePath = ["${projectDir}/src/main/cpp/blas/", includePath = ["${projectDir}/src/main/cpp/blas/",
"${projectDir}/blasbuild/${thisChip}/${avxExtension}/src/main/include/", "${projectDir}/blasbuild/${thisChip}/${avxExtension}/src/main/include/",
"${projectDir}/blasbuild/${thisChip}/${avxExtension}/flatbuffers-src/include", "${projectDir}/blasbuild/${thisChip}/${avxExtension}/flatbuffers-src/include",
@ -226,13 +215,19 @@ chipList.each { thisChip ->
//No idea why this is here, but it looks like even for the javacppBuildCommand task, //No idea why this is here, but it looks like even for the javacppBuildCommand task,
//there is a javacpp Loader actively determining platform etc. //there is a javacpp Loader actively determining platform etc.
classOrPackageNames = ["org.nd4j.nativeblas.${thisChip}.Nd4j${thisChip.capitalize()}Presets"] classOrPackageNames = ["org.nd4j.nativeblas.${thisChip}.Nd4j${thisChip.capitalize()}Presets"]
workingDirectory = projectDir //workingDirectory = projectDir
//if the classpath is not set here, the javacpp classloader starts to look around //if the classpath is not set here, the javacpp classloader starts to look around
//everywhere and causes java.io.IOExceptions: because files is being used by another process //everywhere and causes java.io.IOExceptions: because files is being used by another process
classPath = [:] //logger.quiet("Using compile classpath from configuration named '{}'", sourceSets.named(thisChip).get().getCompileClasspathConfigurationName())
classPath += ["${buildDir}/classes/java/${thisChip}Support/"]
//classPath += ["${buildDir}/classes/java/main/"]
classPath = sourceSets.named(thisChip).get().compileClasspath.collect()
//tasks.named("compileCudaJava").get().getOutputs().files.each {System.out.println(it)}
System.out.println(it.name + ": INPUTS----------------")
inputs.files.each {System.out.println(it)}
System.out.println(it.name + ": INPUTS------------ENDE")
/* Get VCVARS in case we want to build CUDA /* Get VCVARS in case we want to build CUDA
* MinGW64 g++ on MSYS is used otherwise */ * MinGW64 g++ on MSYS is used otherwise */
if (thisChip.equals('cuda') && osdetector.os.startsWith("win") if (thisChip.equals('cuda') && osdetector.os.startsWith("win")
@ -246,10 +241,11 @@ chipList.each { thisChip ->
if (line.contains("=")) { if (line.contains("=")) {
def parts = line.split("=") def parts = line.split("=")
it.environmentVariables.put(parts[0], parts[1]) it.environmentVariables.put(parts[0], parts[1])
logger.quiet("Added variable to environment: {} = {}", parts[0], parts[1])
} }
} }
} }
workingDirectory projectDir
if (thisChip.equals('cuda') && osdetector.os.startsWith("windows")) { //cuDNN requires CUDA if (thisChip.equals('cuda') && osdetector.os.startsWith("windows")) { //cuDNN requires CUDA
it.buildCommand = ['sh', 'buildnativeoperations.sh', it.buildCommand = ['sh', 'buildnativeoperations.sh',
'-V', '-V',
@ -282,22 +278,10 @@ chipList.each { thisChip ->
} }
} }
//Create a task to (pre)compile the java presets (required for javacppBuildParser)
tasks.register("compile${thisChip.capitalize()}Support", JavaCompile) {
def thisSS = sourceSets.findByName("${thisChip}Support")
it.source = thisSS.allSource
it.classpath = thisSS.compileClasspath
it.destinationDirectory = file("${buildDir}/classes/java/${thisChip}Support/")
}
//Run the parser on the InfoMap in Nd4j$ChipPresets and listed header files in @Platform //Run the parser on the InfoMap in Nd4j$ChipPresets and listed header files in @Platform
//Generates Nd4jCpu.java and/ or Nd4jCuda.java Java JNI code //Generates Nd4jCpu.java and/ or Nd4jCuda.java Java JNI code
tasks.register("javacpp${thisChip.capitalize()}SupportBuildParser", org.bytedeco.gradle.javacpp.BuildTask) { tasks.register("javacpp${thisChip.capitalize()}SupportBuildParser", org.bytedeco.gradle.javacpp.BuildTask) {
if (project.hasProperty("skip-native") && project.getProperty("skip-native").equals("true")) {
enabled = false
}
dependsOn "compile${thisChip.capitalize()}Support"
includePath = ["${projectDir}/src/main/cpp/blas/", includePath = ["${projectDir}/src/main/cpp/blas/",
"${projectDir}/blasbuild/${thisChip}/${avxExtension}/src/main/include/", "${projectDir}/blasbuild/${thisChip}/${avxExtension}/src/main/include/",
@ -305,13 +289,9 @@ chipList.each { thisChip ->
"${projectDir}/blasbuild/${thisChip}/${avxExtension}/cpu_features-src/include", "${projectDir}/blasbuild/${thisChip}/${avxExtension}/cpu_features-src/include",
"${projectDir}/blasbuild/${thisChip}/${avxExtension}/mkldnn-src/include"] "${projectDir}/blasbuild/${thisChip}/${avxExtension}/mkldnn-src/include"]
classOrPackageNames = ["org.nd4j.nativeblas.${thisChip}.Nd4j${thisChip.capitalize()}Presets"] classOrPackageNames = ["org.nd4j.nativeblas.${thisChip}.Nd4j${thisChip.capitalize()}Presets"]
outputDirectory = file("${buildDir}/generated/sources/javacpp/${thisChip}/${javacppPlatform}${javacppPlatformExtension}/") classPath = sourceSets.named(thisChip).get().compileClasspath.collect()
outputDirectory file("${buildDir}/generated/sources/javacpp/${thisChip}/${javacppPlatform}${javacppPlatformExtension}/")
classPath = sourceSets.getByName("${thisChip}Support").getRuntimeClasspath()
classPath += ["${buildDir}/classes/java/${thisChip}Support/"]
} }
@ -321,7 +301,6 @@ chipList.each { thisChip ->
enabled = false enabled = false
} }
def thisTask = (org.bytedeco.gradle.javacpp.BuildTask) it def thisTask = (org.bytedeco.gradle.javacpp.BuildTask) it
thisTask.dependsOn = ["javacpp${thisChip.capitalize()}SupportBuildParser"]
thisTask.linkPath = ["${projectDir}/blasbuild/${thisChip}/${avxExtension}/output"] thisTask.linkPath = ["${projectDir}/blasbuild/${thisChip}/${avxExtension}/output"]
thisTask.includePath = ["${projectDir}/src/main/cpp/blas/", thisTask.includePath = ["${projectDir}/src/main/cpp/blas/",
@ -343,6 +322,7 @@ chipList.each { thisChip ->
System.setProperty("org.bytedeco.javacpp.platform.compiler", cl) System.setProperty("org.bytedeco.javacpp.platform.compiler", cl)
System.setProperty("platform.compiler.cpp11", cl) System.setProperty("platform.compiler.cpp11", cl)
logger.quiet("Task ${thisTask.name} overrides compiler '${currentCompiler}' with '${cl}'.") logger.quiet("Task ${thisTask.name} overrides compiler '${currentCompiler}' with '${cl}'.")
} }
doLast { doLast {
//restore compiler //restore compiler
@ -365,32 +345,27 @@ chipList.each { thisChip ->
} }
thisTask.buildPath = ["$buildDir/generated/sources/javacpp/${thisChip}/${javacppPlatform}${javacppPlatformExtension}/"] thisTask.buildPath = ["${buildDir}/generated/sources/javacpp/${thisChip}/${javacppPlatform}${javacppPlatformExtension}/"]
thisTask.copyLibs = true thisTask.copyLibs = true
thisTask.deleteJniFiles(false) thisTask.deleteJniFiles(false)
outputName = "jnind4j${thisChip}" outputName = "jnind4j${thisChip}"
thisTask.outputDirectory = file("$buildDir/generated/sources/javacpp/${thisChip}/${javacppPlatform}${javacppPlatformExtension}/") thisTask.outputDirectory = file("${buildDir}/generated/sources/javacpp/${thisChip}/${javacppPlatform}${javacppPlatformExtension}/")
thisTask.classOrPackageNames= ["org.nd4j.nativeblas.Nd4j${thisChip.capitalize()}"] thisTask.classOrPackageNames= ["org.nd4j.nativeblas.Nd4j${thisChip.capitalize()}"]
thisTask.configDirectory = file("${buildDir}/classes/java/${thisChip}Support/META-INF/native-image/${javacppPlatform}") thisTask.configDirectory = file("${buildDir}/classes/java/${thisChip}Support/META-INF/native-image/${javacppPlatform}")
thisTask.classPath = sourceSets.named("${thisChip}Generated").get().compileClasspath.collect()
//Need to set the classpath, so that external jars from the dependency list are resolved by the ClassLoader as well thisTask.classPath += "${buildDir}/classes/java/main/"
thisTask.classPath = [:]
thisTask.classPath = ["${buildDir}/classes/java/${thisChip}Support"]
thisTask.classPath += sourceSets.findByName("${thisChip}Support").runtimeClasspath
//sourceSets.findByName("${thisChip}Support").runtimeClasspath.each{ s ->
// thisTask.classPath += s
//}
} }
// Create Jar with classifier // Create Jar with classifier
tasks.getByName("${thisChip}SupportJar") { Jar thisTask -> tasks.getByName("${thisChip}Jar") { Jar thisTask ->
dependsOn "javacpp${thisChip.capitalize()}SupportBuildCompiler" dependsOn "javacpp${thisChip.capitalize()}SupportBuildCompiler"
dependsOn "javacpp${thisChip.capitalize()}SupportBuildCommand" dependsOn "javacpp${thisChip.capitalize()}SupportBuildCommand"
//it.from sourceSets.getByName("${thisChip}Support").getOutput() //it.from sourceSets.getByName("${thisChip}Support").getOutput()
def spec = copySpec { def spec = copySpec {
from(tasks.getByName("javacpp${thisChip.capitalize()}SupportBuildCompiler")) {
from(tasks.named("javacpp${thisChip.capitalize()}SupportBuildCompiler").get()) {
exclude { f -> exclude { f ->
def exclude = f.file.isDirectory() def exclude = f.file.isDirectory()
if(exclude) { if(exclude) {
@ -402,8 +377,8 @@ chipList.each { thisChip ->
} }
into "${javacppPlatform}/" //path within jar, we need it in a platform, that javacpp Loader understands into "${javacppPlatform}/" //path within jar, we need it in a platform, that javacpp Loader understands
} }
from(sourceSets.getByName("${thisChip}Support").getOutput()) { from(sourceSets.named(thisChip).get().getOutput()) {
into "${javacppPlatform}/" //path within jar, we need it in a platform, that javacpp Loader understands
} }
duplicatesStrategy DuplicatesStrategy.EXCLUDE duplicatesStrategy DuplicatesStrategy.EXCLUDE
} }
@ -415,34 +390,36 @@ chipList.each { thisChip ->
//Before we can compile the whole java part, we //Before we can compile the whole java part, we
//need to generate the Nd4jXXX.java files first //need to generate the Nd4jXXX.java files first
chipList.each { thisChip -> tasks.named("compileJava").configure {enabled false}
tasks.findByName("compile${thisChip.capitalize()}SupportJava").each { t ->
t.dependsOn "javacpp${thisChip.capitalize()}SupportBuildParser" chipList.each { String thisChip ->
tasks.named("javacpp${thisChip.capitalize()}SupportBuildCompiler").configure {
dependsOn "javacpp${thisChip.capitalize()}SupportBuildParser"
}
tasks.named("javacpp${thisChip.capitalize()}SupportBuildParser").configure {
dependsOn "javacpp${thisChip.capitalize()}SupportBuildCommand"
}
tasks.named("javacpp${thisChip.capitalize()}SupportBuildCommand").configure {
dependsOn "process${thisChip.capitalize()}Resources",
"compile${thisChip.capitalize()}Java",
"compile${thisChip.capitalize()}GeneratedJava"
}
tasks.named("${thisChip}Jar").configure {
dependsOn "javacpp${thisChip.capitalize()}SupportBuildCompiler"
} }
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile).configureEach {
// options.setCompilerArgs(Arrays.asList("-Xlint:unchecked")) // options.setCompilerArgs(Arrays.asList("-Xlint:unchecked"))
} }
tasks.withType(Javadoc) { tasks.withType(Javadoc).configureEach {
options.addStringOption('Xdoclint:none', '-quiet') options.addStringOption('Xdoclint:none', '-quiet')
} }
/*
jar {
manifest {
attributes 'Class-Path': configurations.runtimeClasspath.collect { it.getName() }.join(' '),
'Implementation-Title': 'Brutex AI - Native Components',
'Implementation-Vendor': 'Brutex Network',
'Implementation-Version': archiveVersion,
'Specification-Title': 'Brutex AI - Native Components',
'Specification-Vendor': 'Brutex Network',
'Specification-Version': archiveVersion
}
//archiveClassifier = "${javacppPlatform}${javacppPlatformExtension}-${chip}"
}
*/
javadoc { javadoc {
dependsOn "javacppPomProperties" dependsOn "javacppPomProperties"
failOnError = false failOnError = false
@ -452,10 +429,6 @@ javadoc {
} }
tasks.getByName("generatePomFileForMavenJavaPublication") { tasks.getByName("generatePomFileForMavenJavaPublication") {
enabled = true enabled = true
} }
@ -465,32 +438,14 @@ javadoc {
artifacts { artifacts {
//implementation(jar) //implementation(jar)
chipList.each { thisChip ->
implementation(tasks.getByName("${thisChip}SupportJar")) chipList.each { String thisChip ->
implementation tasks.getByName("${thisChip}Jar")
} }
} }
/*
artifacts {
archives jar
chipList.each { thisChip ->
archives tasks.getByName("${thisChip}SupportJar")
}
}
*/
/*
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
chipList.each { thisChip ->
artifact tasks.getByName("${thisChip}SupportJar")
}
}
}
}
*/
/* /*
if( osdetector.os.startsWith("windows")) { if( osdetector.os.startsWith("windows")) {
@ -516,52 +471,10 @@ if( osdetector.os.startsWith("windows")) {
} }
*/ */
task printDeps {
doLast {
configurations.apiElements.dependencies.each { dep ->
println "${dep.group} - ${dep.name} - ${dep.version}"
dep.artifacts.each { art ->
println " ${art.extension} - ${art.classifier}"
}
}
}
}
/*
def pomClosure = {
name = 'Brutex AI - Native Components'
delegate.description = 'Underlying native components for the Brutex AI deeplearning framework for Java'
url = 'https://ai.brutex.net'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
distribution = 'repo'
}
}
developers {
developer {
id = 'irnbrux'
name = 'Brian Rosenberger'
email = 'bru@brutex.de'
}
}
scm {
url = 'https://brutex.net/svn/'
connection = 'scm:svn:https://brutex.net/svn/bruai4j/'
}
}
*/
//tasks.getByName("publishMavenJavaPublicationToOSSRHRepository") { MavenRemotePublisher pub ->
// logger.quiet(pub.dump());
//}
signing { signing {
useGpgCmd() useGpgCmd()
if (!version.endsWith('SNAPSHOT')) { if (!version.endsWith('SNAPSHOT')) {
sign publishing.publications.mavenJava sign publishing.publications.mavenJava
//sign publishing.publications.mavenJavacppPlatform //sign publishing.publications.mavenJavacppPlatform
} }
} }

View File

@ -19,7 +19,7 @@
# ******************************************************************************/ # ******************************************************************************/
# #
#env env
set -eu set -eu

View File

@ -205,16 +205,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 )
@ -242,6 +242,7 @@ if(SD_CUDA)
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 --cudart=static -Xfatbin -compress-all")
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")
endif() endif()
@ -255,6 +256,7 @@ if(SD_CUDA)
message("CUDA_NVCC_FLAGS = ${CUDA_NVCC_FLAGS}") message("CUDA_NVCC_FLAGS = ${CUDA_NVCC_FLAGS}")
message("CUDA_PROPAGATE_HOST_FLAGS = ${CUDA_PROPAGATE_HOST_FLAGS}") message("CUDA_PROPAGATE_HOST_FLAGS = ${CUDA_PROPAGATE_HOST_FLAGS}")
message("CUDA_ARCH_FLAGS = ${CUDA_ARCH_FLAGS}") message("CUDA_ARCH_FLAGS = ${CUDA_ARCH_FLAGS}")
message("CUDAHOSTCXX = ${CUDAHOSTCXX}")
file(GLOB_RECURSE PERF_SOURCES false performance/*.cpp performance/*.h) file(GLOB_RECURSE PERF_SOURCES false performance/*.cpp performance/*.h)
file(GLOB_RECURSE EXCEPTIONS_SOURCES false exceptions/*.cpp exceptions/*.h) file(GLOB_RECURSE EXCEPTIONS_SOURCES false exceptions/*.cpp exceptions/*.h)
@ -301,11 +303,13 @@ if(SD_CUDA)
# build shared library by default or when it's explicitly requested # build shared library by default or when it's explicitly requested
if(NOT SD_STATIC_LIB OR SD_SHARED_LIB) if(NOT SD_STATIC_LIB OR SD_SHARED_LIB)
message("Will build a shared library '${SD_LIBRARY_NAME}'.")
add_library(${SD_LIBRARY_NAME} SHARED $<TARGET_OBJECTS:samediff_obj>) add_library(${SD_LIBRARY_NAME} SHARED $<TARGET_OBJECTS:samediff_obj>)
endif() endif()
if (SD_STATIC_LIB AND SD_SHARED_LIB) if (SD_STATIC_LIB AND SD_SHARED_LIB)
# if both static and shared library are going to be built - static library will have special suffix # if both static and shared library are going to be built - static library will have special suffix
message("Will build a static library '${SD_LIBRARY_NAME}static'.")
add_library(${SD_LIBRARY_NAME}static STATIC $<TARGET_OBJECTS:samediff_obj>) add_library(${SD_LIBRARY_NAME}static STATIC $<TARGET_OBJECTS:samediff_obj>)
set_property(TARGET ${SD_LIBRARY_NAME}static PROPERTY MSVC_RUNTIME_LIBRARY "${MSVC_RT_LIB}$<$<CONFIG:Debug>:Debug>") set_property(TARGET ${SD_LIBRARY_NAME}static PROPERTY MSVC_RUNTIME_LIBRARY "${MSVC_RT_LIB}$<$<CONFIG:Debug>:Debug>")
install(TARGETS ${SD_LIBRARY_NAME}static DESTINATION .) install(TARGETS ${SD_LIBRARY_NAME}static DESTINATION .)
@ -327,7 +331,8 @@ if(SD_CUDA)
endif() endif()
#target_link_libraries(${SD_LIBRARY_NAME} ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_cusolver_LIBRARY} ${CUDNN} ${MKLDNN}) #target_link_libraries(${SD_LIBRARY_NAME} ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_cusolver_LIBRARY} ${CUDNN} ${MKLDNN})
target_link_libraries(${SD_LIBRARY_NAME} CUDA::cudart CUDA::cublas CUDA::cusolver ${CUDNN} ${MKLDNN}) target_link_libraries(${SD_LIBRARY_NAME} CUDA::cudart CUDA::cublas CUDA::cusolver CUDA::cublasLt ${CUDNN} ${MKLDNN})
#target_link_libraries(${SD_LIBRARY_NAME} ${CUDNN} ${MKLDNN})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/cuda/${SD_EXTENSION}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/cuda/${SD_EXTENSION})
install(TARGETS ${SD_LIBRARY_NAME} DESTINATION .) install(TARGETS ${SD_LIBRARY_NAME} DESTINATION .)
@ -488,4 +493,4 @@ elseif(SD_CPU)
install(TARGETS ${SD_LIBRARY_NAME} DESTINATION .) install(TARGETS ${SD_LIBRARY_NAME} DESTINATION .)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/cpu/${SD_EXTENSION}/) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/cpu/${SD_EXTENSION}/)
endif() endif()

View File

@ -1,25 +0,0 @@
/*
*
* ******************************************************************************
* *
* * This program and the accompanying materials are made available under the
* * terms of the Apache License, Version 2.0 which is available at
* * https://www.apache.org/licenses/LICENSE-2.0.
* *
* * See the NOTICE file distributed with this work for additional
* * information regarding copyright ownership.
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* * License for the specific language governing permissions and limitations
* * under the License.
* *
* * SPDX-License-Identifier: Apache-2.0
* *****************************************************************************
*
*/
package org.nd4j.nativeblas;
public class Dummy {
}

View File

@ -37,7 +37,10 @@ import java.util.List;
* @author saudet * @author saudet
*/ */
@Properties(target = "org.nd4j.nativeblas.Nd4jCuda", helper = "org.nd4j.nativeblas.cuda.Nd4jCudaHelper", @Properties(target = "org.nd4j.nativeblas.Nd4jCuda", helper = "org.nd4j.nativeblas.cuda.Nd4jCudaHelper",
value = {@Platform(define = "LIBND4J_ALL_OPS", include = { value = {
@Platform(
define = "LIBND4J_ALL_OPS",
include = {
"array/DataType.h", "array/DataType.h",
"array/DataBuffer.h", "array/DataBuffer.h",
"array/PointerDeallocator.h", "array/PointerDeallocator.h",
@ -105,7 +108,7 @@ import java.util.List;
"ops/declarable/CustomOperations.h", "ops/declarable/CustomOperations.h",
"build_info.h", "build_info.h",
}, },
exclude = {"ops/declarable/headers/activations.h", exclude = {"ops/declarable/headers/activations.h",
"ops/declarable/headers/boolean.h", "ops/declarable/headers/boolean.h",
"ops/declarable/headers/broadcastable.h", "ops/declarable/headers/broadcastable.h",
"ops/declarable/headers/convo.h", "ops/declarable/headers/convo.h",
@ -125,12 +128,15 @@ import java.util.List;
"cnpy/cnpy.h" "cnpy/cnpy.h"
}, },
compiler = {"cpp11", "nowarnings"}, compiler = {"cpp11", "nowarnings"},
library = "jnind4jcuda", link = "nd4jcuda", preload = "nd4jcuda"), library = "jnind4jcuda",
link = "nd4jcuda"),
@Platform(value = "linux", preload = "gomp@.1", preloadpath = {"/lib64/", "/lib/", "/usr/lib64/", "/usr/lib/", "/usr/local/cuda/lib64"}), @Platform(value = "linux", preload = "gomp@.1", preloadpath = {"/lib64/", "/lib/", "/usr/lib64/", "/usr/lib/", "/usr/local/cuda/lib64"}),
@Platform(value = "linux-armhf", preloadpath = {"/usr/arm-linux-gnueabihf/lib/", "/usr/lib/arm-linux-gnueabihf/"}), @Platform(value = "linux-armhf", preloadpath = {"/usr/arm-linux-gnueabihf/lib/", "/usr/lib/arm-linux-gnueabihf/"}),
@Platform(value = "linux-arm64", preloadpath = {"/usr/aarch64-linux-gnu/lib/", "/usr/lib/aarch64-linux-gnu/"}), @Platform(value = "linux-arm64", preloadpath = {"/usr/aarch64-linux-gnu/lib/", "/usr/lib/aarch64-linux-gnu/"}),
@Platform(value = "linux-ppc64", preloadpath = {"/usr/powerpc64-linux-gnu/lib/", "/usr/powerpc64le-linux-gnu/lib/", "/usr/lib/powerpc64-linux-gnu/", "/usr/lib/powerpc64le-linux-gnu/"}), @Platform(value = "linux-ppc64", preloadpath = {"/usr/powerpc64-linux-gnu/lib/", "/usr/powerpc64le-linux-gnu/lib/", "/usr/lib/powerpc64-linux-gnu/", "/usr/lib/powerpc64le-linux-gnu/"})
@Platform(value = "windows", preload = {"libwinpthread-1", "libgcc_s_seh-1", "libgomp-1", "libstdc++-6", "nd4jcuda"}) }) //@Platform(value = "windows", preload = {"libwinpthread-1", "libgcc_s_seh-1", "libgomp-1", "libstdc++-6", "nd4jcuda"})
})
public class Nd4jCudaPresets implements LoadEnabled, InfoMapper { public class Nd4jCudaPresets implements LoadEnabled, InfoMapper {
@Override public void init(ClassProperties properties) { @Override public void init(ClassProperties properties) {
@ -143,9 +149,14 @@ public class Nd4jCudaPresets implements LoadEnabled, InfoMapper {
return; return;
} }
int i = 0; int i = 0;
/*
String[] libs = {"cudart", "cublasLt", "cublas", "curand", "cusolver", "cusparse", "cudnn", String[] libs = {"cudart", "cublasLt", "cublas", "curand", "cusolver", "cusparse", "cudnn",
"cudnn_ops_infer", "cudnn_ops_train", "cudnn_adv_infer", "cudnn_ops_infer", "cudnn_ops_train", "cudnn_adv_infer",
"cudnn_adv_train", "cudnn_cnn_infer", "cudnn_cnn_train"}; "cudnn_adv_train", "cudnn_cnn_infer", "cudnn_cnn_train"};
*/
// test no preload
String[] libs = {};
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("cufft") ? "@.11" : "@.12"; lib += lib.startsWith("cudnn") ? "@.8" : lib.equals("curand") ? "@.10" : lib.equals("cufft") ? "@.11" : "@.12";

View File

@ -31,4 +31,8 @@ ext {
withCpu = { -> withCpu = { ->
return chip.contains("cpu") return chip.contains("cpu")
} }
if ( ! rootProject.hasProperty("skip-native")) {
logger.info("Project variable 'skip-native' is not set. Will default to 'false'.")
}
} }

View File

@ -26,13 +26,13 @@ ext {
chipList.each { thisChip -> chipList.each { thisChip ->
configurations.register("${thisChip}TestImplementation") { configurations.register("${thisChip}TestImplementation") {
it.extendsFrom configurations.testImplementation, configurations.implementation it.extendsFrom configurations.testImplementation //, configurations.implementation
} }
configurations.register("${thisChip}TestRuntime") { configurations.register("${thisChip}TestRuntime") {
if(configurations.find {Configuration c -> c.name == "api"}) { if(configurations.find {Configuration c -> c.name == "api"}) {
it.extendsFrom configurations.api, configurations.testRuntimeOnly, configurations.implementation,configurations.testImplementation it.extendsFrom configurations.api, configurations.testRuntimeOnly, configurations.implementation, configurations.testImplementation
} else { } else {
it.extendsFrom configurations.testRuntimeOnly, configurations.implementation,configurations.testImplementation it.extendsFrom configurations.testRuntimeOnly, configurations.implementation,configurations.testImplementation
} }
@ -79,6 +79,7 @@ ext {
dependencies { dependencies {
//testRuntime projects.cavisNative.cavisNativeLib
if (withCuda()) { if (withCuda()) {
cudaTestRuntime platform(projects.cavisCommonPlatform) cudaTestRuntime platform(projects.cavisCommonPlatform)
cudaTestRuntime projects.cavisNative.cavisNativeJcublas cudaTestRuntime projects.cavisNative.cavisNativeJcublas
@ -87,17 +88,11 @@ 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 (project( path: ":cavis-native:cavis-native-lib", configuration: "cudaSupportRuntimeElements"))
/*
cudaTestRuntime(project(":cavis-native:cavis-native-lib")) { cudaTestRuntime(project(":cavis-native:cavis-native-lib")) {
capabilities { capabilities {
it.requireCapabilities "net.brutex.cavis.native:cavis-native-lib-cuda-support:1.0.0-SNAPSHOT" it.requireCapabilities "net.brutex.cavis.cavis-native:cavis-native-lib-cuda-support:${project.version}"
} }
} }
*/
} }
if (withCpu()) { if (withCpu()) {
@ -107,16 +102,11 @@ ext {
cpuTestRuntime group: "org.bytedeco", name: "openblas", classifier: buildTarget cpuTestRuntime group: "org.bytedeco", name: "openblas", classifier: buildTarget
cpuTestRuntime group: "org.bytedeco", name: "opencv" cpuTestRuntime group: "org.bytedeco", name: "opencv"
cpuTestRuntime group: "org.bytedeco", name: "opencv", classifier: buildTarget cpuTestRuntime group: "org.bytedeco", name: "opencv", classifier: buildTarget
cpuTestRuntime project( path: ":cavis-native:cavis-native-lib", configuration: "cpuSupportRuntimeElements")
/*
cpuTestRuntime(project(":cavis-native:cavis-native-lib")) { cpuTestRuntime(project(":cavis-native:cavis-native-lib")) {
capabilities { capabilities {
it.requireCapabilities "net.brutex.cavis.native:cavis-native-lib-cpu-support:1.0.0-SNAPSHOT" it.requireCapabilities "net.brutex.cavis.cavis-native:cavis-native-lib-cpu-support:${project.version}"
} }
} }
*/
} }
} }
} }

View File

@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip #distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -85,6 +85,8 @@ include ':cavis-native'
include ':cavis-native:cavis-native-blas' include ':cavis-native:cavis-native-blas'
if(withCuda()) { include ':cavis-native:cavis-native-jcublas'} if(withCuda()) { include ':cavis-native:cavis-native-jcublas'}
if(withCpu()) { include ':cavis-native:cavis-native-cpu' } if(withCpu()) { include ':cavis-native:cavis-native-cpu' }
if(withCuda()) { include 'cavis-native:cavis-native-cuda-presets' }
if(withCpu()) { include 'cavis-native:cavis-native-cpu-presets' }
include ':cavis-native:cavis-native-lib' include ':cavis-native:cavis-native-lib'
include ':cavis-native:cavis-native-common' include ':cavis-native:cavis-native-common'
include ':cavis-dnn' include ':cavis-dnn'
@ -155,4 +157,3 @@ include ':brutex-extended-tests'
include ':cavis-full' include ':cavis-full'

View File

@ -26,12 +26,17 @@
* proven in the past to be unreliable when multiple versions of Visual Studio * proven in the past to be unreliable when multiple versions of Visual Studio
* and SDKs are installed. * and SDKs are installed.
****************************************************************************/ ****************************************************************************/
/*
if (!hasProperty("VISUAL_STUDIO_INSTALL_DIR") && osdetector.os.equals("windows")) { if (!hasProperty("VISUAL_STUDIO_INSTALL_DIR") && osdetector.os.equals("windows")) {
if (project.hasProperty("skip-native") && !project.getProperty("skip-native").equals("true")) { if (project.hasProperty("skip-native") && !project.getProperty("skip-native").equals("true")) {
configureVisualStudio() configureVisualStudio()
} }
} }
*/
if(osdetector.os.equals("windows")) {
logger.quiet("Detected windows operating system. Running configureVisualStudio().")
configureVisualStudio()
}
def configureVisualStudio() { def configureVisualStudio() {
@ -46,35 +51,35 @@ def configureVisualStudio() {
rootProject.ext.VISUAL_STUDIO_VCVARS_CMD = "" rootProject.ext.VISUAL_STUDIO_VCVARS_CMD = ""
// Use vswhere.exe to search for latest Visual Studio installation // Use vswhere.exe to search for latest Visual Studio installation
println "Searching for latest Visual Studio and required components..." logger.quiet("Searching for latest Visual Studio and required components...")
def vswherePath = "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe" def vswherePath = "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe"
if (!file(vswherePath).exists()) { if (!file(vswherePath).exists()) {
println "Visual Studio not found!" logger.error("Visual Studio not found!")
return return
} }
def vswhereOutput = "${vswherePath} -latest -format json".execute().text.trim() def vswhereOutput = "${vswherePath} -latest -format json".execute().text.trim()
def vswhereJson = new groovy.json.JsonSlurper().parseText(vswhereOutput) def vswhereJson = new groovy.json.JsonSlurper().parseText(vswhereOutput)
if (vswhereJson.isEmpty()) { if (vswhereJson.isEmpty()) {
println "Visual Studio not found!" logger.error("Visual Studio not found!")
return return
} }
def vsInstallDir = vswhereJson[0].installationPath def vsInstallDir = vswhereJson[0].installationPath
println " -> Installation Directory: ${vsInstallDir}" logger.quiet(" -> Installation Directory: ${vsInstallDir}")
// Use vcvarsall.bat to determine the latest Visual Studio's default SDK and tool versions // Use vcvarsall.bat to determine the latest Visual Studio's default SDK and tool versions
def vcvarsPath = "${vsInstallDir}\\VC\\Auxiliary\\Build\\vcvarsall.bat" def vcvarsPath = "${vsInstallDir}\\VC\\Auxiliary\\Build\\vcvarsall.bat"
def vcvarsCmd = "\"${vcvarsPath}\" x64" def vcvarsCmd = "\"${vcvarsPath}\" x64"
def vcvarsEnvCmd = "cmd /v:ON /c ${vcvarsCmd} > nul && cmd /c echo" def vcvarsEnvCmd = "cmd /v:ON /c ${vcvarsCmd} > nul && cmd /c echo"
def toolsVersion = "${vcvarsEnvCmd} !VCToolsVersion!".execute().text.trim() def toolsVersion = "${vcvarsEnvCmd} !VCToolsVersion!".execute().text.trim()
println " -> VCTools Version (default): ${toolsVersion}" logger.quiet(" -> VCTools Version (default): ${toolsVersion}")
def sdkDir = "${vcvarsEnvCmd} !WindowsSdkDir!".execute().text.trim() def sdkDir = "${vcvarsEnvCmd} !WindowsSdkDir!".execute().text.trim()
println " -> SDK Directory (default): ${sdkDir}" logger.quiet(" -> SDK Directory (default): ${sdkDir}")
def sdkVersion = "${vcvarsEnvCmd} !WindowsSDKVersion!".execute().text.trim().replace('\\', '') def sdkVersion = "${vcvarsEnvCmd} !WindowsSDKVersion!".execute().text.trim().replace('\\', '')
println " -> SDK Version (default): ${sdkVersion}" logger.quiet(" -> SDK Version (default): ${sdkVersion}")
// Check Gradle properties for override values // Check Gradle properties for override values
def windowsTargetPlatformVersion = findProperty("WindowsTargetPlatformVersion") def windowsTargetPlatformVersion = findProperty("WindowsTargetPlatformVersion")
println " -> SDK Version (override): " + (windowsTargetPlatformVersion ?: "N/A") logger.quiet(" -> SDK Version (override): " + (windowsTargetPlatformVersion ?: "N/A"))
// Save Visual Studio information so other projects can access it // Save Visual Studio information so other projects can access it
rootProject.ext.VISUAL_STUDIO_INSTALL_DIR = vsInstallDir rootProject.ext.VISUAL_STUDIO_INSTALL_DIR = vsInstallDir