Skip to content
Merged
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
44 changes: 0 additions & 44 deletions awscurl/build.gradle

This file was deleted.

48 changes: 48 additions & 0 deletions awscurl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
plugins {
ai.djl.javaProject
}

dependencies {
implementation(platform("ai.djl:bom:${version}"))
implementation(libs.huggingface.tokenizers) {
exclude(group = "org.apache.commons", module = "commons-compress")
}
implementation(libs.slf4j.simple)
implementation(libs.commons.cli)
implementation(libs.commons.codec)
implementation(libs.apache.httpclient)
implementation(libs.apache.httpmime)

testImplementation(libs.netty.http)
testImplementation(libs.testng) {
exclude(group = "junit", module = "junit")
}

tasks {
jar {
manifest {
attributes["Main-Class"] = "ai.djl.awscurl.AwsCurl"
}
includeEmptyDirs = false
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(configurations.runtimeClasspath.get().map {
if (it.isDirectory()) it else zipTree(it).matching {
exclude("**/*.so")
exclude("**/*.dylib")
exclude("**/*.dll")
}
})

doLast {
exec {
workingDir(".")
executable("sh")
args(
"-c",
"cat src/main/scripts/stub.sh build/libs/awscurl*.jar > build/awscurl && chmod +x build/awscurl"
)
}
}
}
}
}
148 changes: 0 additions & 148 deletions benchmark/build.gradle

This file was deleted.

147 changes: 147 additions & 0 deletions benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
@file:Suppress("UNCHECKED_CAST")

import com.netflix.gradle.plugins.deb.Deb

plugins {
ai.djl.javaProject
application
id("com.netflix.nebula.ospackage") version "11.4.0"
}

dependencies {
implementation(platform("ai.djl:bom:${version}"))
implementation(project(":wlm"))

implementation(libs.commons.cli)
implementation(libs.apache.log4j.slf4j)
implementation("ai.djl:model-zoo")

runtimeOnly("ai.djl.pytorch:pytorch-model-zoo")
runtimeOnly("ai.djl.tensorflow:tensorflow-model-zoo")
runtimeOnly("ai.djl.mxnet:mxnet-model-zoo")
runtimeOnly("ai.djl.ml.xgboost:xgboost")
runtimeOnly("ai.djl.tensorrt:tensorrt")
runtimeOnly("ai.djl.huggingface:tokenizers")
runtimeOnly(project(":engines:python"))

testImplementation(libs.testng) {
exclude(group = "junit", module = "junit")
}

if (hasGpu) {
runtimeOnly("ai.djl.onnxruntime:onnxruntime-engine") {
exclude(group = "com.microsoft.onnxruntime", module = "onnxruntime")
}
runtimeOnly(libs.onnxruntime.gpu)
} else {
runtimeOnly("ai.djl.onnxruntime:onnxruntime-engine")
}
}

tasks {
application {
mainClass = System.getProperty("main", "ai.djl.benchmark.Benchmark")
}

run.configure {
environment("TF_CPP_MIN_LOG_LEVEL", "1") // turn off TensorFlow print out
systemProperties = System.getProperties().toMap() as Map<String, Any>
systemProperties.remove("user.dir")
}

register<JavaExec>("benchmark") {
environment("TF_CPP_MIN_LOG_LEVEL", "1") // turn off TensorFlow print out
val arguments = gradle.startParameter.taskRequests[0].args
for (argument in arguments) {
if (argument.trim().startsWith("--args")) {
var line = argument.split("=", limit = 2)
if (line.size == 2) {
line = line[1].split(" ")
if (line.contains("-t")) {
if (System.getProperty("ai.djl.default_engine") == "TensorFlow") {
environment("OMP_NUM_THREADS", "1")
environment("TF_NUM_INTRAOP_THREADS", "1")
} else {
environment("MXNET_ENGINE_TYPE", "NaiveEngine")
environment("OMP_NUM_THREADS", "1")
}
}
break
}
}
}

systemProperties = System.getProperties().toMap() as Map<String, Any>
systemProperties.remove("user.dir")
classpath = sourceSets.main.get().runtimeClasspath
// restrict the jvm heap size for better monitoring benchmark
if (project.hasProperty("loggc")) {
jvmArgs("-Xmx2g", "-Xlog:gc*=debug:file=build/gc.log")
} else {
jvmArgs("-Xmx2g")
}
mainClass = "ai.djl.benchmark.Benchmark"
}

register("prepareDeb") {
dependsOn(distTar)
doFirst {
exec {
commandLine(
"tar",
"xvf",
"${buildDirectory}/distributions/benchmark-${version}.tar",
"-C",
"$buildDirectory"
)
}
}
}

register<Deb>("createDeb") {
dependsOn("prepareDeb")

packageName = "djl-bench"
archiveVersion = version
release = "1"
maintainer = "Deep Java Library <[email protected]>"
summary = "djl-bench is a command line tool that allows you to benchmark the\n" +
" model on all different platforms for single-thread/multi-thread\n" +
" inference performance."

from(buildDirectory / "benchmark-${version}") {
into("/usr/local/djl-bench-${version}")
}
link("/usr/bin/djl-bench", "/usr/local/djl-bench-${version}/bin/benchmark")
}

register<Exec>("installOnLinux") {
dependsOn("createDeb")
doFirst {
if ("linux" in os) {
val ver = version.toString().replace("-", "~")
commandLine("sudo", "dpkg", "-i", "${buildDirectory}/distributions/djl-bench_${ver}-1_all.deb")
} else {
throw GradleException("task installOnLinux Only supported on Linux.")
}
}
}

startScripts {
doLast {
val replacement = "CLASSPATH=\\\$APP_HOME/lib/*\n\n" +
"if [[ \"\\\$*\" == *-t* || \"\\\$*\" == *--threads* ]]\n" +
"then\n" +
" export TF_CPP_MIN_LOG_LEVEL=1\n" +
" export MXNET_ENGINE_TYPE=NaiveEngine\n" +
" export OMP_NUM_THREADS=1\n" +
" export TF_NUM_INTRAOP_THREADS=1\n" +
"fi"

unixScript.text = unixScript.text
.replace(Regex("CLASSPATH=\\\$APP_HOME/lib/.*"), replacement)
.replace("/usr/bin/env sh", "/usr/bin/env bash")
.replace("#!/bin/sh", "#!/bin/bash")
}
}
}
Loading