Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
fixup! Add TensorFlow examples - ResNet50 and BERT models
Browse files Browse the repository at this point in the history
  • Loading branch information
Satya1493 committed Jul 12, 2021
1 parent 13a09c2 commit 9e456cc
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 130 deletions.
24 changes: 14 additions & 10 deletions Examples/tensorflow/BERT/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,29 @@ ifeq ($(SGX),1)
all: python.manifest.sgx python.sig python.token
endif

BERT_DATASET = https://storage.googleapis.com/bert_models/2019_05_30/wwm_uncased_L-24_H-1024_A-16.zip
SQUAAD_DATASET = https://rajpurkar.github.io/SQuAD-explorer/dataset/dev-v1.1.json
CHECKPOINTS = https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_8/bert_large_checkpoints.zip
BERT_INT8_MODEL = https://storage.googleapis.com/intel-optimized-tensorflow/models/r2.5-icx-b631821f/asymmetric_per_channel_bert_int8.pb

collateral:
apt install unzip
test -d models || git clone https://github.com/IntelAI/models.git
mkdir -p data
test -f data/wwm_uncased_L-24_H-1024_A-16.zip || wget https://storage.googleapis.com/bert_models/2019_05_30/wwm_uncased_L-24_H-1024_A-16.zip -P data/
test -f data/wwm_uncased_L-24_H-1024_A-16.zip || wget $(BERT_DATASET) -P data/
test -d data/wwm_uncased_L-24_H-1024_A-16 || unzip data/wwm_uncased_L-24_H-1024_A-16.zip -d data
test -f data/wwm_uncased_L-24_H-1024_A-16/dev-v1.1.json || wget https://rajpurkar.github.io/SQuAD-explorer/dataset/dev-v1.1.json -P data/wwm_uncased_L-24_H-1024_A-16
test -f data/bert_large_checkpoints.zip || wget https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_8/bert_large_checkpoints.zip -P data/
test -f data/wwm_uncased_L-24_H-1024_A-16/dev-v1.1.json || wget $(SQUAAD_DATASET) -P data/wwm_uncased_L-24_H-1024_A-16
test -f data/bert_large_checkpoints.zip || wget $(CHECKPOINTS) -P data/
test -d data/bert_large_checkpoints || unzip data/bert_large_checkpoints.zip -d data
test -f data/asymmetric_per_channel_bert_int8.pb || wget https://storage.googleapis.com/intel-optimized-tensorflow/models/r2.5-icx-b631821f/asymmetric_per_channel_bert_int8.pb -P data/
test -f data/asymmetric_per_channel_bert_int8.pb || wget $(BERT_INT8_MODEL) -P data/

python.manifest: python.manifest.template collateral
graphene-manifest \
-Dlog_level=$(GRAPHENE_LOG_LEVEL) \
-Darch_libdir=$(ARCH_LIBDIR) \
-Dentrypoint=$(realpath $(shell sh -c "command -v python3")) \
-Dpythondistpath=$(PYTHONDISTPATH) \
$< >$@
-Dlog_level=$(GRAPHENE_LOG_LEVEL) \
-Darch_libdir=$(ARCH_LIBDIR) \
-Dentrypoint=$(realpath $(shell sh -c "command -v python3")) \
-Dpythondistpath=$(PYTHONDISTPATH) \
$< >$@

python.manifest.sgx: python.manifest
graphene-sgx-sign \
Expand All @@ -53,4 +58,3 @@ clean:
.PHONY: distclean
distclean: clean
$(RM) -r models/ data/

19 changes: 10 additions & 9 deletions Examples/tensorflow/BERT/python.manifest.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ loader.insecure__use_cmdline_argv = 1
# Propagate environment variables from the host. Don't use this on production!
loader.insecure__use_host_env = 1

# Disable address space layour randomization. Don't use this on production!
# Disable address space layout randomization. Don't use this on production!
loader.insecure__disable_aslr = 1

# Update Library Path - overwrites environment variable
loader.env.LD_LIBRARY_PATH = "{{ python.stdlib }}/lib:/lib:{{ arch_libdir }}:/usr/lib:/usr/{{ arch_libdir }}"

# Additional memory for Graphene's internal use
loader.pal_internal_mem_size = "512M"

# Default glibc files, mounted from graphene's Runtime directory
fs.mount.lib.type = "chroot"
fs.mount.lib.path = "/lib"
Expand Down Expand Up @@ -62,17 +65,15 @@ sgx.nonpie_binary = 1
sgx.trusted_files.runtime = "file:{{ graphene.runtimedir() }}/"
sgx.trusted_files.arch_libdir = "file:{{ arch_libdir }}/"
sgx.trusted_files.usr_arch_libdir = "file:/usr/{{ arch_libdir }}/"
sgx.trusted_files.libcpp = "file:/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
sgx.trusted_files.libgcc = "file:/lib/x86_64-linux-gnu/libgcc_s.so.1"
sgx.trusted_files.python = "file:{{ entrypoint }}"
sgx.trusted_files.pyhome = "file:{{ python.stdlib }}"
sgx.trusted_files.pydisthome = "file:{{ python.distlib }}"
sgx.trusted_files.pydistpath = "file:{{ pythondistpath }}"

# SGX allowed files
sgx.allowed_files.tmp = "file:/tmp/"
sgx.allowed_files.etc = "file:/etc/"
sgx.allow_file_creation = "1"
sgx.allowed_files.output = "file:output/"
sgx.allowed_files.scripts = "file:models/models/language_modeling/tensorflow/bert_large/inference/"
sgx.allowed_files.scripts = "file:models/"
sgx.allowed_files.dataDir = "file:data/"
sgx.allowed_files.python = "file:{{ entrypoint }}"
sgx.allowed_files.pyhome = "file:{{ python.stdlib }}"
sgx.allowed_files.pydisthome = "file:{{ python.distlib }}"
sgx.allowed_files.pydistpath = "file:{{ pythondistpath }}"
sgx.allowed_files.keras = "file:root/.keras/keras.json"
Loading

0 comments on commit 9e456cc

Please sign in to comment.