Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CUDA v12 support for Java onnxruntime_gpu build #20011

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions dockerfiles/Dockerfile.java-cuda
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM nvidia/cuda:12.1.1-cudnn8-devel-ubi8

ENV DEBIAN_FRONTEND=noninteractive

RUN yum install -y zlib-devel python39-devel python39-numpy python39-setuptools python39-wheel python39-pip git unzip wget java-1.8.0-devel patch && \
wget https://github.com/Kitware/CMake/releases/download/v3.27.3/cmake-3.27.3-linux-x86_64.tar.gz && \
tar -zxf cmake-3.27.3-linux-x86_64.tar.gz --strip=1 -C /usr && rm -f cmake-3.27.3-linux-x86_64.tar.gz && \
wget https://services.gradle.org/distributions/gradle-8.6-bin.zip && unzip gradle-8.6-bin.zip -d /opt/ && rm -f gradle-8.6-bin.zip

ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0
ENV GRADLE_HOME=/opt/gradle-8.6
ENV PATH=${GRADLE_HOME}/bin:${PATH}

COPY ./onnxruntime /onnxruntime
WORKDIR /onnxruntime

RUN ./build.sh --allow_running_as_root --compile_no_warning_as_error --skip_tests \
--use_cuda --cuda_home /usr/local/cuda --cudnn_home /usr/lib64/ --config Release --build_java --update --build --parallel --cmake_extra_defines \
ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) CMAKE_CUDA_ARCHITECTURES="52;60;61;70;75;86" CMAKE_CXX_STANDARD=17 CMAKE_CXX_STANDARD_REQUIRED=ON \
ONNX_USE_PROTOBUF_SHARED_LIBS=OFF onnxruntime_BUILD_UNIT_TESTS=OFF
27 changes: 25 additions & 2 deletions java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,23 @@ allprojects {
}
}

project.group = "com.microsoft.onnxruntime"
version = rootProject.file('../VERSION_NUMBER').text.trim()
def getCUDAVersion = {
def nvccStdout = new ByteArrayOutputStream()
exec {
commandLine 'nvcc', '--version'
standardOutput = nvccStdout
}

for (line in nvccStdout.toString().trim().split("\n")) {
if (line.contains("release")) {
def fromIndex = line.indexOf("release") + 7
def toIndex = line.indexOf(".", fromIndex)
return Integer.parseInt(line.substring(fromIndex, toIndex).trim())
}
}

throw new IllegalArgumentException("Unexpected output of \"nvcc --version\" command");
}

// cmake runs will inform us of the build directory of the current run
def cmakeBuildDir = System.properties['cmakeBuildDir']
Expand All @@ -37,6 +52,14 @@ def trainingDescription = 'ONNX Runtime Training is a training and inference pac
'(Open Neural Network Exchange) models. This package is targeted for Learning on The Edge aka On-Device Training ' +
'See https://github.com/microsoft/onnxruntime-training-examples/tree/master/on_device_training for more details.'

project.group = "com.microsoft.onnxruntime"
version = rootProject.file('../VERSION_NUMBER').text.trim()
if (useCUDA != null) {
version += "-cu" + getCUDAVersion()
} else if (useROCM != null) {
version += "-rocm"
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
Loading