Files
graphene/Examples/pytorch/README.md
Michał Kowalczyk 6c7ff2d3a6 Migrate and remove test/apps submodule
We decided to merge the sample app integrations submodule back because
working with git submodules turned out to be really painful. The only
blocker for this was the fact, that previously it contained a lot of
binary blobs and copy-pasted sources, but this was cleaned up recently.

Credits: (authors of particular integration examples, extracted from
commits and PR history in https://github.com/oscarlab/graphene-tests)

apache:     Chia-Che Tsai <chiache@tamu.edu>, Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
bash:       Chia-Che Tsai <chiache@tamu.edu>, Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
blender:    borysp <borysp@invisiblethingslab.com>
busybox:    borysp <borysp@invisiblethingslab.com>
capnproto:  Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
curl:       Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
gcc:        Thomas Knauth <thomas.knauth@intel.com>
lighttpd:   Chia-Che Tsai <chiache@tamu.edu>, Thomas Knauth <thomas.knauth@intel.com>
lmbench:    Chia-Che Tsai <chiache@tamu.edu>
memcached:  Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
nginx:      Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
nodejs:     jack.wxz <jack.wxz@alibaba-inc.com>
nodejs-express-server: Eduardo Rodriguez <erodrig@us.ibm.com>
openvino:   Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
python-scipy-insecure: Chia-Che Tsai <chiache@tamu.edu>, Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
python-simple:         Chia-Che Tsai <chiache@tamu.edu>, Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
pytorch:    Thomas Knauth <thomas.knauth@intel.com>
r:          Chia-Che Tsai <chiache@tamu.edu>
redis:      Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
tensorflow: Thomas Knauth <thomas.knauth@intel.com>

LTP was moved to LibOS/shim/test/ltp. It was recently rewritten by
Wojtek Porczyk <woju@invisiblethingslab.com>.
2020-03-30 21:10:41 +02:00

41 lines
1.9 KiB
Markdown

# PyTorch
This directory contains steps and artifacts to run a PyTorch sample workload on
Graphene. Specifically, this example uses a pre-trained model for image classification. We tested
this on Ubuntu 16.04 and 18.04. The sample uses the package versions of Python (3.5 and 3.6) coming
with each distribution.
The workload reads an image from a file on disk `input.jpg` and runs the classifier to detect what
object is present in the image. For the image shipping with the workload, the output should be
```
[('Labrador retriever', 41.58518600463867), ('golden retriever', 16.59165382385254), ('Saluki, gazelle hound', 16.286855697631836), ('whippet', 2.853914976119995), ('Ibizan hound, Ibizan Podenco', 2.3924756050109863)]
```
With high probability (41%) the classifier detected the image to contain a Labrador retriever.
# Pre-requisites
The following steps should suffice to run the workload on a stock Ubuntu 16.04 and 18.04
installation.
- `sudo apt-get install python3-pip lsb-release` to install `pip` and `lsb_release`. The former is
required to install additional Python packages while the latter is used by the Makefile.
- `pip3 install --user torchvision pillow` to install the torchvision and pillow Python packages and
their dependencies (usually in $HOME/.local). WARNING: This downloads several hundred megabytes of
data!
- `python3 -c 'import torchvision ; torchvision.models.alexnet(pretrained=True)'` to download the
pre-trained model ($HOME/.cache/torch). WARNING: This downloads about 200MB of data!
# Build
Run `make` to build the non-SGX version and `make SGX=1` to build the SGX version.
# Run
Execute any one of the following commands to run the workload
- natively: `python3 pytorchexample.py`
- Graphene w/o SGX: `./pal_loader ./pytorch.manifest ./pytorchexample.py`
- Graphene with SGX: `SGX=1 ./pal_loader ./pytorch.manifest ./pytorchexample.py`