From 17c23067011dcb7aece38b3e0e0b78a737d09fa1 Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 1 Sep 2023 10:31:56 +0200 Subject: [PATCH] Reorganising build.gradle for CUDA 12 Signed-off-by: brian --- .gitea/workflows/demo.yaml | 26 ++++++++++++++++ .../main/java/net/brutex/ai/LoaderTest.java | 30 +++++++++++++++++++ .../nd4j/nativeblas/cuda/Nd4jCudaPresets.java | 6 ++-- cavis-native/cavis-native-lib/CMakeLists.txt | 6 ++-- cavis-native/cavis-native-lib/build.gradle | 3 ++ .../src/main/cpp/blas/CMakeLists.txt | 4 +-- 6 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 .gitea/workflows/demo.yaml create mode 100644 brutex-extended-tests/src/main/java/net/brutex/ai/LoaderTest.java diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml new file mode 100644 index 000000000..dcd1e3f52 --- /dev/null +++ b/.gitea/workflows/demo.yaml @@ -0,0 +1,26 @@ +name: Gitea Actions Demo +run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 +on: [push] + +jobs: + Explore-Gitea-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event." + - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!" + - run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." + - name: Check out repository code + uses: actions/checkout@v3 + - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository + run: | + ls ${{ gitea.workspace }} + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Execute Gradle build + run: ./gradlew build -PCAVIS_CHIP=cpu -Pskip-native=false + + - run: echo "This job's status is ${{ job.status }}." \ No newline at end of file diff --git a/brutex-extended-tests/src/main/java/net/brutex/ai/LoaderTest.java b/brutex-extended-tests/src/main/java/net/brutex/ai/LoaderTest.java new file mode 100644 index 000000000..d0c0a4c7b --- /dev/null +++ b/brutex-extended-tests/src/main/java/net/brutex/ai/LoaderTest.java @@ -0,0 +1,30 @@ +/* + * + * ****************************************************************************** + * * + * * 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 net.brutex.ai; + +public class LoaderTest { + + public static void main(String[] args){ + System.load("C:\\Users\\brian\\_projects\\deeplearning4j\\cavis-native\\cavis-native-lib" + + "\\build\\generated\\sources\\javacpp\\cuda\\windows-x86_64-avx2\\jnind4jcuda.dll"); + } +} diff --git a/cavis-native/cavis-native-cuda-presets/src/main/java/org/nd4j/nativeblas/cuda/Nd4jCudaPresets.java b/cavis-native/cavis-native-cuda-presets/src/main/java/org/nd4j/nativeblas/cuda/Nd4jCudaPresets.java index 9e9f2541f..b821f13c4 100644 --- a/cavis-native/cavis-native-cuda-presets/src/main/java/org/nd4j/nativeblas/cuda/Nd4jCudaPresets.java +++ b/cavis-native/cavis-native-cuda-presets/src/main/java/org/nd4j/nativeblas/cuda/Nd4jCudaPresets.java @@ -129,14 +129,14 @@ import java.util.List; }, compiler = {"cpp11", "nowarnings"}, library = "jnind4jcuda", - link = "nd4jcuda", - preload = "nd4jcuda"), + link = "nd4jcuda"), + //preload = "nd4jcuda"), @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-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 = "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"}) }) public class Nd4jCudaPresets implements LoadEnabled, InfoMapper { diff --git a/cavis-native/cavis-native-lib/CMakeLists.txt b/cavis-native/cavis-native-lib/CMakeLists.txt index 5339e1ab4..029209053 100644 --- a/cavis-native/cavis-native-lib/CMakeLists.txt +++ b/cavis-native/cavis-native-lib/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.20) project(libnd4j) set(CMAKE_VERBOSE_MAKEFILE ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") @@ -160,10 +161,10 @@ elseif (APPLE) set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fPIC -Wno-braced-scalar-init -Wno-delete-non-virtual-dtor -Wno-unused-command-line-argument -Wno-dangling-else -D__APPLE_OS__=true -D_RELEASE=true") set(CMAKE_CXX_FLAGS_DEBUG " -O0 -g -fPIC -Wno-braced-scalar-init -Wno-delete-non-virtual-dtor -Wno-unused-command-line-argument -Wno-dangling-else -D__APPLE_OS__=true") elseif(WIN32) - set(SD_X86_BUILD true) + set(SD_X86_BUILD false) if (SD_CUDA) set(CMAKE_CXX_FLAGS_RELEASE "-D_RELEASE=true") - set(CMAKE_CXX_FLAGS_DEBUG " /FS /EHsc") + #set(CMAKE_CXX_FLAGS_DEBUG " /FS /EHsc") else() set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fPIC -D_RELEASE=true") set(CMAKE_CXX_FLAGS_DEBUG " -g -O2 -fPIC") @@ -375,7 +376,6 @@ if (MSVC_DEV) set(SD_BUILD_MINIFIER false) endif () -set (CMAKE_INSTALL_PREFIX $ENV{ND4J_HOME}/bruai4j-native/bruai4j-native-common/src/main/resources) # Set package information set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Native operations for nd4j.") diff --git a/cavis-native/cavis-native-lib/build.gradle b/cavis-native/cavis-native-lib/build.gradle index 87d3d09cb..676755092 100644 --- a/cavis-native/cavis-native-lib/build.gradle +++ b/cavis-native/cavis-native-lib/build.gradle @@ -187,6 +187,7 @@ task deepClean(type: Delete) { tasks.withType(org.bytedeco.gradle.javacpp.BuildTask).configureEach { org.bytedeco.gradle.javacpp.BuildTask it -> + /* it.buildResource = ["/org/bytedeco/openblas/${javacppPlatform}/", "/org/bytedeco/mkldnn/${javacppPlatform}/"] @@ -194,6 +195,8 @@ tasks.withType(org.bytedeco.gradle.javacpp.BuildTask).configureEach { org.bytede it.linkResource = ["/org/bytedeco/openblas/${javacppPlatform}/", "/org/bytedeco/openblas/${javacppPlatform}/lib/"] + + */ } 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 c804420e8..1ec3ca586 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 @@ -224,7 +224,7 @@ if(SD_CUDA) set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DCUDA_VERSION_MAJOR=12 -w -Xfatbin -compress-all") set(CUDAHOSTCXX "${CMAKE_CXX_COMPILER}") if(WIN32) - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=/EHsc") + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=/EHsc -Xcompiler=/bigobj") endif() message("CMAKE_CUDA_FLAGS = ${CMAKE_CUDA_FLAGS}") @@ -307,7 +307,7 @@ if(SD_CUDA) # Done by nvcc as default on windows if(WIN32) - message("CUDA on Windows: enabling /EHsc") + message("CUDA on Windows: enabling /EHsc and /bigobj") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /bigobj") endif()