diff --git a/.appveyor.yml b/.appveyor.yml index 9a46527ef3d..8e11f969f29 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -70,6 +70,8 @@ environment: APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - PROJ: "tensorflow" OS: windows-x86_64 + - PROJ: "tensorrt" + OS: windows-x86_64 - PROJ: "ale" OS: windows-x86_64 - PROJ: "onnxruntime" diff --git a/CHANGELOG.md b/CHANGELOG.md index 8caa141492b..aee48442d77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ + * Add support for Windows to presets for TensorRT ([pull #860](https://github.com/bytedeco/javacpp-presets/pull/860)) * Add dependency on presets for `jnijavacpp` and `javacpp-platform` artifact to fix issues at load time ([issue bytedeco/javacv#1305](https://github.com/bytedeco/javacv/issues/1305)) * Bundle the official Java API of ONNX Runtime via the `jnionnxruntime` library * Add CUDA-enabled build for ONNX Runtime via `-gpu` extension diff --git a/ci/install-windows.sh b/ci/install-windows.sh index f6e0a58826b..9bb4271401f 100755 --- a/ci/install-windows.sh +++ b/ci/install-windows.sh @@ -115,7 +115,7 @@ if [ "$PROJ" == "mkl" ]; then echo Finished mkl fi -if [ "$PROJ" == "cuda" ] || [ "$EXT" == "-gpu" ]; then +if [ "$PROJ" == "cuda" ] || [ "$PROJ" == "tensorrt" ] || [ "$EXT" == "-gpu" ]; then echo Installing cuda curl -L -o cuda_10.2.89_441.22_windows.exe "http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_441.22_windows.exe" curl -L -o cudnn-10.2-windows7-x64-v7.6.5.32.zip "https://developer.download.nvidia.com/compute/redist/cudnn/v7.6.5/cudnn-10.2-windows7-x64-v7.6.5.32.zip" @@ -128,6 +128,14 @@ if [ "$PROJ" == "cuda" ] || [ "$EXT" == "-gpu" ]; then echo Finished cuda install fi +if [ "$PROJ" == "tensorrt" ] || [ "$EXT" == "-gpu" ]; then + echo Installing tensorrt + /c/python27/python $APPVEYOR_BUILD_FOLDER/ci/gDownload.py 1MqoSNUEnbZPn4HNdJX3uic-Ej5ZejCaV /c/Downloads/tensorrt.zip + unzip -o /c/Downloads/tensorrt.zip -d /c/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/ + ln -sf /c/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/TensorRT* /c/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/TensorRT + echo Finished tensorrt install +fi + if [ "$PROJ" == "tensorflow" ]; then curl -L http://downloads.sourceforge.net/project/swig/swigwin/swigwin-3.0.12/swigwin-3.0.12.zip -o swigwin-3.0.12.zip unzip -o swigwin-3.0.12.zip -d /c/ diff --git a/pom.xml b/pom.xml index 24e2c28812a..d0a11cf74e5 100644 --- a/pom.xml +++ b/pom.xml @@ -1537,6 +1537,7 @@ cuda mxnet tensorflow + tensorrt ale onnxruntime liquidfun diff --git a/tensorrt/README.md b/tensorrt/README.md index f25e8590fa3..7bd5949e4c6 100644 --- a/tensorrt/README.md +++ b/tensorrt/README.md @@ -56,15 +56,13 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic org.bytedeco - cuda + cuda-platform-redist 10.2-7.6-1.5.3-SNAPSHOT - linux-x86_64-redist org.bytedeco - tensorrt + tensorrt-platform-redist 7.0-1.5.3-SNAPSHOT - linux-x86_64-redist diff --git a/tensorrt/cppbuild.sh b/tensorrt/cppbuild.sh index 000020bbba6..07e145280d1 100755 --- a/tensorrt/cppbuild.sh +++ b/tensorrt/cppbuild.sh @@ -14,6 +14,12 @@ case $PLATFORM in exit 1 fi ;; + windows-x86_64) + if [[ ! -f "C:/Program Files/NVIDIA GPU Computing Toolkit/TensorRT/include/NvInfer.h" ]]; then + echo "Please install TensorRT in C:/Program Files/NVIDIA GPU Computing Toolkit/TensorRT/" + exit 1 + fi + ;; *) echo "Error: Platform \"$PLATFORM\" is not supported" ;; diff --git a/tensorrt/platform/pom.xml b/tensorrt/platform/pom.xml index af07407bc81..9124a9ba77d 100644 --- a/tensorrt/platform/pom.xml +++ b/tensorrt/platform/pom.xml @@ -36,6 +36,12 @@ ${project.version} ${javacpp.platform.linux-x86_64} + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.windows-x86_64} + @@ -48,7 +54,7 @@ - ${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86_64.jar + ${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86_64.jar ${javacpp.moduleId}-windows-x86_64.jar @@ -94,6 +100,7 @@ module org.bytedeco.${javacpp.moduleId}.platform { requires org.bytedeco.${javacpp.moduleId}.linux.x86_64; + requires org.bytedeco.${javacpp.moduleId}.windows.x86_64; } diff --git a/tensorrt/platform/redist/pom.xml b/tensorrt/platform/redist/pom.xml new file mode 100644 index 00000000000..39f34bbe663 --- /dev/null +++ b/tensorrt/platform/redist/pom.xml @@ -0,0 +1,111 @@ + + + 4.0.0 + + + org.bytedeco + javacpp-presets + 1.5.3-SNAPSHOT + ../../../ + + + org.bytedeco + tensorrt-platform-redist + 7.0-${project.parent.version} + JavaCPP Presets Platform Redist for TensorRT + + + tensorrt + -redist + + + + + ${project.groupId} + ${javacpp.moduleId}-platform + ${project.version} + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.linux-x86_64} + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.windows-x86_64} + + + + + + + maven-jar-plugin + + + default-jar + + + + ${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86_64-redist.jar ${javacpp.moduleId}-windows-x86_64-redist.jar + + + + + + empty-javadoc-jar + + jar + + + javadoc + + + + empty-sources-jar + + jar + + + sources + + + + + + org.moditect + moditect-maven-plugin + + + add-module-infos + none + + + add-platform-module-info + package + + add-module-info + + + + + ${project.build.directory}/${project.artifactId}.jar + + module org.bytedeco.${javacpp.moduleId}.platform { + requires org.bytedeco.${javacpp.moduleId}.linux.x86_64.redist; + requires org.bytedeco.${javacpp.moduleId}.windows.x86_64.redist; + } + + + + + + + + + + + diff --git a/tensorrt/samples/pom.xml b/tensorrt/samples/pom.xml index 499f13fd853..d8fafd889bf 100644 --- a/tensorrt/samples/pom.xml +++ b/tensorrt/samples/pom.xml @@ -16,15 +16,13 @@ org.bytedeco - cuda + cuda-platform-redist 10.2-7.6-1.5.3-SNAPSHOT - linux-x86_64-redist org.bytedeco - tensorrt + tensorrt-platform-redist 7.0-1.5.3-SNAPSHOT - linux-x86_64-redist diff --git a/tensorrt/src/main/java/org/bytedeco/tensorrt/presets/nvinfer.java b/tensorrt/src/main/java/org/bytedeco/tensorrt/presets/nvinfer.java index 50bebc46267..519fa9de4ba 100644 --- a/tensorrt/src/main/java/org/bytedeco/tensorrt/presets/nvinfer.java +++ b/tensorrt/src/main/java/org/bytedeco/tensorrt/presets/nvinfer.java @@ -43,16 +43,29 @@ */ @Properties( inherit = {cublas.class, cudnn.class, nvrtc.class}, - value = @Platform( - value = "linux-x86_64", - compiler = "cpp11", - include = {"NvInferVersion.h", "NvInferRuntimeCommon.h", "NvInferRuntime.h", "NvInfer.h", "NvUtils.h"}, - includepath = {"/usr/include/x86_64-linux-gnu/", "/usr/local/tensorrt/include/"}, - link = "nvinfer@.7", - preload = "myelin@.1", - linkpath = {"/usr/lib/x86_64-linux-gnu/", "/usr/local/tensorrt/lib/"}), + value = { + @Platform( + value = {"linux-x86_64", "windows-x86_64"}, + compiler = "cpp11", + include = {"NvInferVersion.h", "NvInferRuntimeCommon.h", "NvInferRuntime.h", "NvInfer.h", "NvUtils.h"}, + link = "nvinfer@.7" + ), + @Platform( + value = "linux-x86_64", + includepath = {"/usr/include/x86_64-linux-gnu/", "/usr/local/tensorrt/include/"}, + linkpath = {"/usr/lib/x86_64-linux-gnu/", "/usr/local/tensorrt/lib/"}, + preload = "myelin@.1" + ), + @Platform( + value = "windows-x86_64", + includepath = "C:/Program Files/NVIDIA GPU Computing Toolkit/TensorRT/include", + linkpath = "C:/Program Files/NVIDIA GPU Computing Toolkit/TensorRT/lib/", + preload = "myelin64_1" + ) + }, target = "org.bytedeco.tensorrt.nvinfer", - global = "org.bytedeco.tensorrt.global.nvinfer") + global = "org.bytedeco.tensorrt.global.nvinfer" +) public class nvinfer implements LoadEnabled, InfoMapper { static { Loader.checkVersion("org.bytedeco", "tensorrt"); } @@ -62,13 +75,22 @@ public class nvinfer implements LoadEnabled, InfoMapper { List resources = properties.get("platform.preloadresource"); // Only apply this at load time since we don't want to copy the CUDA libraries here - if (!Loader.isLoadLibraries() || !platform.equals("linux-x86_64")) { + if (!Loader.isLoadLibraries()) { return; } int i = 0; - String[] libs = {"cudart", "cublasLt", "cublas", "cudnn"}; + String[] libs = {"cudart", "cublasLt", "cublas", "cudnn", "nvrtc"}; for (String lib : libs) { - lib += lib.equals("cudnn") ? "@.7" : lib.equals("cudart") ? "@.10.2" : "@.10"; + switch (platform) { + case "linux-x86_64": + lib += lib.equals("cudnn") ? "@.7" : lib.equals("cudart") ? "@.10.2" : lib.equals("nvrtc") ? "@.10.2" : "@.10"; + break; + case "windows-x86_64": + lib += lib.equals("cudnn") ? "64_7" : lib.equals("cudart") ? "64_102" : lib.equals("nvrtc") ? "64_102_0" : "64_10"; + break; + default: + continue; // no CUDA + } if (!preloads.contains(lib)) { preloads.add(i++, lib); }