This repository was archived by the owner on Sep 1, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ # PyTorch Java Demo
2
+
3
+ This repository is a demonstration of how to use PyTorch from Java.
4
+
5
+ ## Setup
6
+
7
+ Download and unpack libtorch nightly (or 1.4 or greater once it is released).
8
+ From the pytorch.org homepage under "Quick Start Locally",
9
+ make sure "LibTorch" is the selected package.
10
+ As of this writing, only Linux is supported. Mac and Windows will follow.
11
+
12
+ Run ` export LIBTORCH_HOME=/path/to/libtorch ` .
13
+ The ` build.gradle ` file will use this to set ` java.library.path `
14
+ when running the application.
15
+ If you are using PyTorch in your own environment,
16
+ ` LIBTORCH_HOME ` is not necessary.
17
+ Instead, you will need to set ` java.library.path ` to ` /path/to/libtorch/lib ` .
18
+
19
+ Run ` ./gradlew run ` to build and run the demo application.
20
+ It will load ` demo-model.pt ` and run it on some simple data.
21
+ [ This notebook] ( TorchScriptForJavaDemo.ipynb ) was used to generate the model.
22
+
23
+ More information about the Java API and TorchScript:
24
+ - [ TorchScript tutorial] ( https://pytorch.org/tutorials/beginner/Intro_to_TorchScript_tutorial.html )
25
+ - [ TorchScript reference] ( https://pytorch.org/docs/stable/jit.html )
26
+ - [ Loading TorchScript in C++] ( https://pytorch.org/tutorials/advanced/cpp_export.html )
27
+ - [ PyTorch-style JavaDoc] ( https://pytorch.org/docs/stable/packages.html )
28
+ - [ Standard JavaDoc] ( https://dreiss.github.io/pytorch/android/pytorch_android/javadoc-out/ )
29
+ - [ PyTorch Android tutorial] ( https://pytorch.org/mobile/android/ )
You can’t perform that action at this time.
0 commit comments