Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gpu tensorflow example #638

Merged
merged 13 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from 12 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
3 changes: 3 additions & 0 deletions doc/source/examples/gpu_tensorflow_deep_mnist.nblink
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../../examples/models/gpu_tensorflow_deep_mnist/gpu_tensorflow_deep_mnist.ipynb"
}
1 change: 1 addition & 0 deletions doc/source/examples/notebooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Notebooks
Custom Endpoints <custom_endpoints>
Example Helm Deployments <helm_examples>
Go Model <go_example>
GPU Tensorflow Deep MNIST <gpu_tensorflow_deep_mnist>
H2O Java MoJo <h2o_mojo>
Istio Canary <istio_canary>
Istio Examples <istio_examples>
Expand Down
4 changes: 4 additions & 0 deletions examples/models/gpu_tensorflow_deep_mnist/.s2i/environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MODEL_NAME=DeepMnist
API_TYPE=REST
SERVICE_TYPE=MODEL
PERSISTENCE=0
17 changes: 17 additions & 0 deletions examples/models/gpu_tensorflow_deep_mnist/DeepMnist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import tensorflow as tf
import numpy as np

class DeepMnist(object):
def __init__(self):
self.class_names = ["class:{}".format(str(i)) for i in range(10)]
self.sess = tf.Session()
saver = tf.train.import_meta_graph("model/deep_mnist_model.meta")
saver.restore(self.sess,tf.train.latest_checkpoint("./model/"))

graph = tf.get_default_graph()
self.x = graph.get_tensor_by_name("x:0")
self.y = graph.get_tensor_by_name("y:0")

def predict(self,X,feature_names):
predictions = self.sess.run(self.y,feed_dict={self.x:X})
return predictions.astype(np.float64)
20 changes: 20 additions & 0 deletions examples/models/gpu_tensorflow_deep_mnist/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
IMAGE_NAME=seldonio/gpu-mnist-example
IMAGE_VERSION=0.1


build_image:
s2i build . joelh1996/gpu-base:0.4 ${IMAGE_NAME}:${IMAGE_VERSION}

push_image:
docker push $(IMAGE_NAME):$(IMAGE_VERSION)


.PHONY: train
train:
mkdir -p model
sudo python3 create_model.py

.PHONY: clean
clean:
rm -rf model
rm -rf MNIST_data
Loading