Skip to content

Commit

Permalink
[benchmark] build snap package for ubuntu (#1055)
Browse files Browse the repository at this point in the history
Change-Id: Id13f237649bb81f4b980601fb7393998438d5080
  • Loading branch information
frankfliu authored Jun 27, 2021
1 parent d892248 commit a2233b7
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 6 deletions.
2 changes: 1 addition & 1 deletion extensions/benchmark/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ startScripts {
'fi'

String text = unixScript.text.replaceAll('CLASSPATH=\\$APP_HOME/lib/.*', replacement)
text = text.replaceAll("/usr/bin/env sh", "/usr/bin/env bash")
unixScript.text = text
}
}

tasks.distZip.enabled = false
1 change: 1 addition & 0 deletions extensions/benchmark/gradle
1 change: 1 addition & 0 deletions extensions/benchmark/gradlew
46 changes: 46 additions & 0 deletions extensions/benchmark/snapcraft/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: djlbench
version: '0.12.0'
title: DJL Benhmark
license: Apache-2.0
summary: A machine learning benchmarking toolkit
description: |
djlbench is a command line tool that allows you to benchmark the
model on all different platforms for single-thread/multi-thread
inference performance.
Currently djlbench support the models from the following framework:
- PyTorch
- TensorFlow
- Apachmark MXNet
- PaddlePaddle
- ONNXRuntime
- TensorFlow Lite
- Neo DLR
- XGBoost
base: core18
grade: stable
confinement: classic

apps:
djlbench:
command: benchmark-$SNAPCRAFT_PROJECT_VERSION/bin/benchmark
environment:
JAVA_HOME: "$SNAP/usr/lib/jvm/java-11-openjdk-amd64"
PATH: "$SNAP/bin:$PATH:$SNAP/usr/lib/jvm/java-11-openjdk-amd64/bin"
plugs:
- home
- network
- cups-control

parts:
djlbench:
plugin: gradle
source: https://github.com/deepjavalibrary/djl.git
# source-tag: v$SNAPCRAFT_PROJECT_VERSION
gradle-output-dir: extensions/benchmark/build/libs
gradle-options: [ -Pstaging, ':extensions:benchmark:dT' ]
override-build: |
snapcraftctl build
tar xvf $SNAPCRAFT_PART_BUILD/extensions/benchmark/build/distributions/benchmark-*.tar -C $SNAPCRAFT_PART_INSTALL/
rm -rf $SNAPCRAFT_PART_INSTALL/jar
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,28 @@ public final boolean runBenchmark(String[] args) {
DefaultParser parser = new DefaultParser();
CommandLine cmd = parser.parse(options, args, null, false);
Arguments arguments = new Arguments(cmd);
String engine = arguments.getEngine();
String engineName = arguments.getEngine();
Engine engine = Engine.getEngine(engineName);

long init = System.nanoTime();
String version = Engine.getEngine(engine).getVersion();
String version = engine.getVersion();
long loaded = System.nanoTime();
logger.info(
String.format(
"Load %s (%s) in %.3f ms.",
engine, version, (loaded - init) / 1_000_000f));
engineName, version, (loaded - init) / 1_000_000f));
Duration duration = Duration.ofSeconds(arguments.getDuration());
if (arguments.getDuration() != 0) {
logger.info(
"Running {} on: {}, duration: {} minutes.",
getClass().getSimpleName(),
Device.defaultDevice(),
Device.defaultDevice(engine),
duration.toMinutes());
} else {
logger.info(
"Running {} on: {}.", getClass().getSimpleName(), Device.defaultDevice());
"Running {} on: {}.",
getClass().getSimpleName(),
Device.defaultDevice(engine));
}
int numOfThreads = arguments.getThreads();
int iteration = arguments.getIteration();
Expand Down

0 comments on commit a2233b7

Please sign in to comment.