Giter Club home page Giter Club logo

tobegit3hub / simple_tensorflow_serving Goto Github PK

View Code? Open in Web Editor NEW
757.0 30.0 196.0 26.7 MB

Generic and easy-to-use serving service for machine learning models

Home Page: https://stfs.readthedocs.io

License: Apache License 2.0

Python 40.13% Go 0.23% Ruby 0.16% Erlang 0.08% JavaScript 52.94% Lua 0.30% PHP 0.16% C++ 0.19% Swift 0.38% Perl 0.13% R 0.12% Shell 1.42% HTML 3.50% Dockerfile 0.21% Starlark 0.04%
tensorflow-models savedmodel tensorflow serving client http machine-learning deep-learning

simple_tensorflow_serving's Introduction

Simple TensorFlow Serving

Introduction

Simple TensorFlow Serving is the generic and easy-to-use serving service for machine learning models. Read more in https://stfs.readthedocs.io.

  • Support distributed TensorFlow models
  • Support the general RESTful/HTTP APIs
  • Support inference with accelerated GPU
  • Support curl and other command-line tools
  • Support clients in any programming language
  • Support code-gen client by models without coding
  • Support inference with raw file for image models
  • Support statistical metrics for verbose requests
  • Support serving multiple models at the same time
  • Support dynamic online and offline for model versions
  • Support loading new custom op for TensorFlow models
  • Support secure authentication with configurable basic auth
  • Support multiple models of TensorFlow/MXNet/PyTorch/Caffe2/CNTK/ONNX/H2o/Scikit-learn/XGBoost/PMML/Spark MLlib

Installation

Install the server with pip.

pip install simple_tensorflow_serving

Or install from source code.

python ./setup.py install

python ./setup.py develop

bazel build simple_tensorflow_serving:server

Or use the docker image.

docker run -d -p 8500:8500 tobegit3hub/simple_tensorflow_serving

docker run -d -p 8500:8500 tobegit3hub/simple_tensorflow_serving:latest-gpu

docker run -d -p 8500:8500 tobegit3hub/simple_tensorflow_serving:latest-hdfs

docker run -d -p 8500:8500 tobegit3hub/simple_tensorflow_serving:latest-py34
docker-compose up -d

Or deploy in Kubernetes.

kubectl create -f ./simple_tensorflow_serving.yaml

Quick Start

Start the server with the TensorFlow SavedModel.

simple_tensorflow_serving --model_base_path="./models/tensorflow_template_application_model"

Check out the dashboard in http://127.0.0.1:8500 in web browser.

dashboard

Generate Python client and access the model with test data without coding.

curl http://localhost:8500/v1/models/default/gen_client?language=python > client.py
python ./client.py

Advanced Usage

Multiple Models

It supports serve multiple models and multiple versions of these models. You can run the server with this configuration.

{
  "model_config_list": [
    {
      "name": "tensorflow_template_application_model",
      "base_path": "./models/tensorflow_template_application_model/",
      "platform": "tensorflow"
    }, {
      "name": "deep_image_model",
      "base_path": "./models/deep_image_model/",
      "platform": "tensorflow"
    }, {
       "name": "mxnet_mlp_model",
       "base_path": "./models/mxnet_mlp/mx_mlp",
       "platform": "mxnet"
    }
  ]
}
simple_tensorflow_serving --model_config_file="./examples/model_config_file.json"

Adding or removing model versions will be detected automatically and re-load latest files in memory. You can easily choose the specified model and version for inference.

endpoint = "http://127.0.0.1:8500"
input_data = {
  "model_name": "default",
  "model_version": 1,
  "data": {
      "keys": [[11.0], [2.0]],
      "features": [[1, 1, 1, 1, 1, 1, 1, 1, 1],
                   [1, 1, 1, 1, 1, 1, 1, 1, 1]]
  }
}
result = requests.post(endpoint, json=input_data)

GPU Acceleration

If you want to use GPU, try with the docker image with GPU tag and put cuda files in /usr/cuda_files/.

export CUDA_SO="-v /usr/cuda_files/:/usr/cuda_files/"
export DEVICES=$(\ls /dev/nvidia* | xargs -I{} echo '--device {}:{}')
export LIBRARY_ENV="-e LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/cuda_files"

docker run -it -p 8500:8500 $CUDA_SO $DEVICES $LIBRARY_ENV tobegit3hub/simple_tensorflow_serving:latest-gpu

You can set session config and gpu options in command-line parameter or the model config file.

simple_tensorflow_serving --model_base_path="./models/tensorflow_template_application_model" --session_config='{"log_device_placement": true, "allow_soft_placement": true, "allow_growth": true, "per_process_gpu_memory_fraction": 0.5}'
{
  "model_config_list": [
    {
      "name": "default",
      "base_path": "./models/tensorflow_template_application_model/",
      "platform": "tensorflow",
      "session_config": {
        "log_device_placement": true,
        "allow_soft_placement": true,
        "allow_growth": true,
        "per_process_gpu_memory_fraction": 0.5
      }
    }
  ]
}

Generated Client

You can generate the test json data for the online models.

curl http://localhost:8500/v1/models/default/gen_json

Or generate clients in different languages(Bash, Python, Golang, JavaScript etc.) for your model without writing any code.

curl http://localhost:8500/v1/models/default/gen_client?language=python > client.py
curl http://localhost:8500/v1/models/default/gen_client?language=bash > client.sh
curl http://localhost:8500/v1/models/default/gen_client?language=golang > client.go
curl http://localhost:8500/v1/models/default/gen_client?language=javascript > client.js

The generated code should look like these which can be test immediately.

#!/usr/bin/env python

import requests

def main():
  endpoint = "http://127.0.0.1:8500"
  json_data = {"model_name": "default", "data": {"keys": [[1], [1]], "features": [[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]} }
  result = requests.post(endpoint, json=json_data)
  print(result.text)

if __name__ == "__main__":
  main()
#!/usr/bin/env python

import requests

def main():
  endpoint = "http://127.0.0.1:8500"

  input_data = {"keys": [[1.0], [1.0]], "features": [[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]}
  result = requests.post(endpoint, json=input_data)
  print(result.text)

if __name__ == "__main__":
  main()

Image Model

For image models, we can request with the raw image files instead of constructing array data.

Now start serving the image model like deep_image_model.

simple_tensorflow_serving --model_base_path="./models/deep_image_model/"

Then request with the raw image file which has the same shape of your model.

curl -X POST -F 'image=@./images/mew.jpg' -F "model_version=1" 127.0.0.1:8500

TensorFlow Estimator Model

If we use the TensorFlow Estimator API to export the model, the model signature should look like this.

inputs {
  key: "inputs"
  value {
    name: "input_example_tensor:0"
    dtype: DT_STRING
    tensor_shape {
      dim {
        size: -1
      }
    }
  }
}
outputs {
  key: "classes"
  value {
    name: "linear/binary_logistic_head/_classification_output_alternatives/classes_tensor:0"
    dtype: DT_STRING
    tensor_shape {
      dim {
        size: -1
      }
      dim {
        size: -1
      }
    }
  }
}
outputs {
  key: "scores"
  value {
    name: "linear/binary_logistic_head/predictions/probabilities:0"
    dtype: DT_FLOAT
    tensor_shape {
      dim {
        size: -1
      }
      dim {
        size: 2
      }
    }
  }
}
method_name: "tensorflow/serving/classify"

We need to construct the string tensor for inference and use base64 to encode the string for HTTP. Here is the example Python code.

def _float_feature(value):
  return tf.train.Feature(float_list=tf.train.FloatList(value=[value]))

def _bytes_feature(value):
  return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))

def main():
  # Raw input data
  feature_dict = {"a": _bytes_feature("10"), "b": _float_feature(10)}

  # Create Example as base64 string
  example_proto = tf.train.Example(features=tf.train.Features(feature=feature_dict))
  tensor_proto = tf.contrib.util.make_tensor_proto(example_proto.SerializeToString(), dtype=tf.string)
  tensor_string = tensor_proto.string_val.pop()
  base64_tensor_string = base64.urlsafe_b64encode(tensor_string)

  # Request server
  endpoint = "http://127.0.0.1:8500"
  json_data = {"model_name": "default", "base64_decode": True, "data": {"inputs": [base64_tensor_string]}}
  result = requests.post(endpoint, json=json_data)
  print(result.json())

Custom Op

If your models rely on new TensorFlow custom op, you can run the server while loading the so files.

simple_tensorflow_serving --model_base_path="./model/" --custom_op_paths="./foo_op/"

Please check out the complete example in ./examples/custom_op/.

Authentication

For enterprises, we can enable basic auth for all the APIs and any anonymous request is denied.

Now start the server with the configured username and password.

./server.py --model_base_path="./models/tensorflow_template_application_model/" --enable_auth=True --auth_username="admin" --auth_password="admin"

If you are using the Web dashboard, just type your certification. If you are using clients, give the username and password within the request.

curl -u admin:admin -H "Content-Type: application/json" -X POST -d '{"data": {"keys": [[11.0], [2.0]], "features": [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]}}' http://127.0.0.1:8500
endpoint = "http://127.0.0.1:8500"
input_data = {
  "data": {
      "keys": [[11.0], [2.0]],
      "features": [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]
  }
}
auth = requests.auth.HTTPBasicAuth("admin", "admin")
result = requests.post(endpoint, json=input_data, auth=auth)

TSL/SSL

It supports TSL/SSL and you can generate the self-signed secret files for testing.

openssl req -x509 -newkey rsa:4096 -nodes -out /tmp/secret.pem -keyout /tmp/secret.key -days 365

Then run the server with certification files.

simple_tensorflow_serving --enable_ssl=True --secret_pem=/tmp/secret.pem --secret_key=/tmp/secret.key --model_base_path="./models/tensorflow_template_application_model"

Supported Models

For MXNet models, you can load with commands and configuration like these.

simple_tensorflow_serving --model_base_path="./models/mxnet_mlp/mx_mlp" --model_platform="mxnet"
endpoint = "http://127.0.0.1:8500"
input_data = {
  "model_name": "default",
  "model_version": 1,
  "data": {
      "data": [[12.0, 2.0]]
  }
}
result = requests.post(endpoint, json=input_data)
print(result.text)

For ONNX models, you can load with commands and configuration like these.

simple_tensorflow_serving --model_base_path="./models/onnx_mnist_model/onnx_model.proto" --model_platform="onnx"
endpoint = "http://127.0.0.1:8500"
input_data = {
  "model_name": "default",
  "model_version": 1,
  "data": {
      "data": [[...]]
  }
}
result = requests.post(endpoint, json=input_data)
print(result.text)

For H2o models, you can load with commands and configuration like these.

# Start H2o server with "java -jar h2o.jar"

simple_tensorflow_serving --model_base_path="./models/h2o_prostate_model/GLM_model_python_1525255083960_17" --model_platform="h2o"
endpoint = "http://127.0.0.1:8500"
input_data = {
  "model_name": "default",
  "model_version": 1,
  "data": {
      "data": [[...]]
  }
}
result = requests.post(endpoint, json=input_data)
print(result.text)

For Scikit-learn models, you can load with commands and configuration like these.

simple_tensorflow_serving --model_base_path="./models/scikitlearn_iris/model.joblib" --model_platform="scikitlearn"

simple_tensorflow_serving --model_base_path="./models/scikitlearn_iris/model.pkl" --model_platform="scikitlearn"
endpoint = "http://127.0.0.1:8500"
input_data = {
  "model_name": "default",
  "model_version": 1,
  "data": {
      "data": [[...]]
  }
}
result = requests.post(endpoint, json=input_data)
print(result.text)

For XGBoost models, you can load with commands and configuration like these.

simple_tensorflow_serving --model_base_path="./models/xgboost_iris/model.bst" --model_platform="xgboost"

simple_tensorflow_serving --model_base_path="./models/xgboost_iris/model.joblib" --model_platform="xgboost"

simple_tensorflow_serving --model_base_path="./models/xgboost_iris/model.pkl" --model_platform="xgboost"
endpoint = "http://127.0.0.1:8500"
input_data = {
  "model_name": "default",
  "model_version": 1,
  "data": {
      "data": [[...]]
  }
}
result = requests.post(endpoint, json=input_data)
print(result.text)

For PMML models, you can load with commands and configuration like these. This relies on Openscoring and Openscoring-Python to load the models.

java -jar ./third_party/openscoring/openscoring-server-executable-1.4-SNAPSHOT.jar

simple_tensorflow_serving --model_base_path="./models/pmml_iris/DecisionTreeIris.pmml" --model_platform="pmml"
endpoint = "http://127.0.0.1:8500"
input_data = {
  "model_name": "default",
  "model_version": 1,
  "data": {
      "data": [[...]]
  }
}
result = requests.post(endpoint, json=input_data)
print(result.text)

Supported Client

Here is the example client in Bash.

curl -H "Content-Type: application/json" -X POST -d '{"data": {"keys": [[1.0], [2.0]], "features": [[10, 10, 10, 8, 6, 1, 8, 9, 1], [6, 2, 1, 1, 1, 1, 7, 1, 1]]}}' http://127.0.0.1:8500

Here is the example client in Python.

endpoint = "http://127.0.0.1:8500"
payload = {"data": {"keys": [[11.0], [2.0]], "features": [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]}}

result = requests.post(endpoint, json=payload)

Here is the example client in C++.

Here is the example client in Java.

Here is the example client in Scala.

Here is the example client in Go.

endpoint := "http://127.0.0.1:8500"
dataByte := []byte(`{"data": {"keys": [[11.0], [2.0]], "features": [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]}}`)
var dataInterface map[string]interface{}
json.Unmarshal(dataByte, &dataInterface)
dataJson, _ := json.Marshal(dataInterface)

resp, err := http.Post(endpoint, "application/json", bytes.NewBuffer(dataJson))

Here is the example client in Ruby.

endpoint = "http://127.0.0.1:8500"
uri = URI.parse(endpoint)
header = {"Content-Type" => "application/json"}
input_data = {"data" => {"keys"=> [[11.0], [2.0]], "features"=> [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]}}
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, header)
request.body = input_data.to_json

response = http.request(request)

Here is the example client in JavaScript.

var options = {
    uri: "http://127.0.0.1:8500",
    method: "POST",
    json: {"data": {"keys": [[11.0], [2.0]], "features": [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]}}
};

request(options, function (error, response, body) {});

Here is the example client in PHP.

$endpoint = "127.0.0.1:8500";
$inputData = array(
    "keys" => [[11.0], [2.0]],
    "features" => [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],
);
$jsonData = array(
    "data" => $inputData,
);
$ch = curl_init($endpoint);
curl_setopt_array($ch, array(
    CURLOPT_POST => TRUE,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_HTTPHEADER => array(
        "Content-Type: application/json"
    ),
    CURLOPT_POSTFIELDS => json_encode($jsonData)
));

$response = curl_exec($ch);

Here is the example client in Erlang.

ssl:start(),
application:start(inets),
httpc:request(post,
  {"http://127.0.0.1:8500", [],
  "application/json",
  "{\"data\": {\"keys\": [[11.0], [2.0]], \"features\": [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]}}"
  }, [], []).

Here is the example client in Lua.

local endpoint = "http://127.0.0.1:8500"
keys_array = {}
keys_array[1] = {1.0}
keys_array[2] = {2.0}
features_array = {}
features_array[1] = {1, 1, 1, 1, 1, 1, 1, 1, 1}
features_array[2] = {1, 1, 1, 1, 1, 1, 1, 1, 1}
local input_data = {
    ["keys"] = keys_array,
    ["features"] = features_array,
}
local json_data = {
    ["data"] = input_data
}
request_body = json:encode (json_data)
local response_body = {}

local res, code, response_headers = http.request{
    url = endpoint,
    method = "POST", 
    headers = 
      {
          ["Content-Type"] = "application/json";
          ["Content-Length"] = #request_body;
      },
      source = ltn12.source.string(request_body),
      sink = ltn12.sink.table(response_body),
}

Here is the example client in Rust.

Here is the example client in Swift.

Here is the example client in Perl.

my $endpoint = "http://127.0.0.1:8500";
my $json = '{"data": {"keys": [[11.0], [2.0]], "features": [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]}}';
my $req = HTTP::Request->new( 'POST', $endpoint );
$req->header( 'Content-Type' => 'application/json' );
$req->content( $json );
$ua = LWP::UserAgent->new;

$response = $ua->request($req);

Here is the example client in Lisp.

Here is the example client in Haskell.

Here is the example client in Clojure.

Here is the example client in R.

endpoint <- "http://127.0.0.1:8500"
body <- list(data = list(a = 1), keys = 1)
json_data <- list(
  data = list(
    keys = list(list(1.0), list(2.0)), features = list(list(1, 1, 1, 1, 1, 1, 1, 1, 1), list(1, 1, 1, 1, 1, 1, 1, 1, 1))
  )
)

r <- POST(endpoint, body = json_data, encode = "json")
stop_for_status(r)
content(r, "parsed", "text/html")

Here is the example with Postman.

Performance

You can run SimpleTensorFlowServing with any WSGI server for better performance. We have benchmarked and compare with TensorFlow Serving. Find more details in benchmark.

STFS(Simple TensorFlow Serving) and TFS(TensorFlow Serving) have similar performances for different models. Vertical coordinate is inference latency(microsecond) and the less is better.

Then we test with ab with concurrent clients in CPU and GPU. TensorFlow Serving works better especially with GPUs.

For simplest model, each request only costs ~1.9 microseconds and one instance of Simple TensorFlow Serving can achieve 5000+ QPS. With larger batch size, it can inference more than 1M instances per second.

How It Works

  1. simple_tensorflow_serving starts the HTTP server with flask application.
  2. Load the TensorFlow models with tf.saved_model.loader Python API.
  3. Construct the feed_dict data from the JSON body of the request.
    // Method: POST, Content-Type: application/json
    {
      "model_version": 1, // Optional
      "data": {
        "keys": [[1], [2]],
        "features": [[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]]
      }
    }
    
  4. Use the TensorFlow Python API to sess.run() with feed_dict data.
  5. For multiple versions supported, it starts independent thread to load models.
  6. For generated clients, it reads user's model and render code with Jinja templates.

Contribution

Feel free to open an issue or send pull request for this project. It is warmly welcome to add more clients in your languages to access TensorFlow models.

simple_tensorflow_serving's People

Contributors

chiragjn avatar jcalta avatar kiic-leung avatar krissdap avatar mogoweb avatar ndlinh avatar tobegit3hub avatar wrongtest-intellif avatar yzxchn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple_tensorflow_serving's Issues

where <client.py>??

Hi, your repo is very nice ,and I am interested in it when I look once. When I install sucessfully and type
simple_tensorflow_serving --model_base_path= "./models/tensorflow_template_appliaction_model" --gen_client= "python"

LOG_HERE:

`(py35) ➜ ~/Deep_Learning/tmp/simple_tensorflow_serving(master)$ simple_tensorflow_serving --model_base_path="./models/tensorflow_template_application_model" --gen_client="python"

2018-09-05 14:49:46 INFO reload_models: False
2018-09-05 14:49:46 INFO model_name: default
2018-09-05 14:49:46 INFO model_config_file:
2018-09-05 14:49:46 INFO auth_username: admin
2018-09-05 14:49:46 INFO download_inference_images: True
2018-09-05 14:49:46 INFO enable_colored_log: False
2018-09-05 14:49:46 INFO gen_client: python
2018-09-05 14:49:46 INFO custom_op_paths:
2018-09-05 14:49:46 INFO log_level: info
2018-09-05 14:49:46 INFO auth_password: admin
2018-09-05 14:49:46 INFO enable_auth: False
2018-09-05 14:49:46 INFO bind: 0.0.0.0:8500
2018-09-05 14:49:46 INFO host: 0.0.0.0
2018-09-05 14:49:46 INFO enable_cors: True
2018-09-05 14:49:46 INFO model_base_path: ./models/tensorflow_template_application_model
2018-09-05 14:49:46 INFO port: 8500
2018-09-05 14:49:46 INFO debug: False
2018-09-05 14:49:46 INFO model_platform: tensorflow
2018-09-05 14:49:46.225473: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-09-05 14:49:46 INFO Put the model version: 1 online, path: ./models/tensorflow_template_application_model/1
INFO:tensorflow:Restoring parameters from ./models/tensorflow_template_application_model/1/variables/variables
2018-09-05 14:49:46 INFO Restoring parameters from ./models/tensorflow_template_application_model/1/variables/variables
2018-09-05 14:49:46 INFO Put the model version: 2 online, path: ./models/tensorflow_template_application_model/2
INFO:tensorflow:Restoring parameters from ./models/tensorflow_template_application_model/2/variables/variables
2018-09-05 14:49:46 INFO Restoring parameters from ./models/tensorflow_template_application_model/2/variables/variables
(py35) ➜ ~/Deep_Learning/tmp/simple_tensorflow_serving(master)$
`

The next step is python ./client.py, I think this client.py file should be generate by up command , but it failed. I do not know why.

Though I found it in /python_client/client.py , but I was still puzzled. What went wrong?

Failed to build docker image

since the image of docker hub isn't update sync with current code , am try to build latest one, after a long time compile and dowloading in the cmd "docker build -t " got erro msg:
Installed /usr/local/lib/python2.7/site-packages/simple_tensorflow_serving-0.7.2.2-py2.7.egg
Processing dependencies for simple-tensorflow-serving==0.7.2.2
Searching for pandas
Reading https://pypi.org/simple/pandas/
Downloading https://files.pythonhosted.org/packages/3e/a7/bfbaa1b8b2abc129793c329b37e69c54f5fd9a06f21a283ff91b17eaca73/pandas-0.25.0rc0.tar.gz#sha256=7fa6e3264009127c3b2c2dbd7257ec1301940c0bea0daae983d9d3ac0d7bb8a1
Best match: pandas 0.25.0rc0
Processing pandas-0.25.0rc0.tar.gz
Writing /tmp/easy_install-zKYScO/pandas-0.25.0rc0/setup.cfg
Running pandas-0.25.0rc0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-zKYScO/pandas-0.25.0rc0/egg-dist-tmp-PHTBGJ
Traceback (most recent call last):
File "./setup.py", line 25, in
"stfs=simple_tensorflow_serving.command:main"
File "/usr/local/lib/python2.7/site-packages/setuptools/init.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/usr/local/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/lib/python2.7/site-packages/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/usr/local/lib/python2.7/site-packages/setuptools/command/install.py", line 117, in do_egg_install
cmd.run()
File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 418, in run
self.easy_install(spec, not self.no_deps)
File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 660, in easy_install
return self.install_item(None, spec, tmpdir, deps, True)
File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 707, in install_item
self.process_distribution(spec, dist, deps)
File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 752, in process_distribution
[requirement], self.local_index, self.easy_install
File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 782, in resolve
replace_conflicting=replace_conflicting
File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 1065, in best_match
return self.obtain(req, installer)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 1077, in obtain
return installer(requirement)
File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 679, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 705, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 890, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1158, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1144, in run_setup
run_setup(setup_script, args)
File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 253, in run_setup
raise
File "/usr/local/lib/python2.7/contextlib.py", line 35, in exit
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/local/lib/python2.7/contextlib.py", line 35, in exit
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 166, in save_modules
saved_exc.resume()
File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 141, in resume
six.reraise(type, exc, self._tb)
File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 154, in save_modules
yield saved
File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 250, in run_setup
_execfile(setup_script, ns)
File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-zKYScO/pandas-0.25.0rc0/setup.py", line 21, in
zip_safe=False,
File "/tmp/easy_install-zKYScO/pandas-0.25.0rc0/versioneer.py", line 1629
print("Adding sample versioneer config to setup.cfg", file=sys.stderr)
^
SyntaxError: invalid syntax

Unable to run local trained model

I have convert one of my pretrained network weights into tensorflow saved model and use the check tools you supplied which shows nothing wrong. But when I run the image inference from the broswer I
got following mistake. Could you please help me to locate which step may be wrong. Thanks a lot. Here is some information
question
ques

class 'KeyError'

Predict result:
[{"error": "Inference error <class 'KeyError'>: 'image_bytes'"}, 400]

Image inference error

Hi, can somebody help to have a look my problem, thanks!
Image inference in web menu test image inference:
Predict result: [{"error": "Inference error <class 'KeyError'>: 'input_image'"}, 400]

Image inference in command line:
`E:\Anaconda\Lib\site-packages\simple_tensorflow_serving>curl -X POST -F 'image=images/NG0093.jpg' -F "model_version=3" 127.0.0.1:8500

<title>500 Internal Server Error</title>

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

`

Simple tensorflow serving log:
2019-04-18 09:00:46 ERROR Need to set image or images for form-data 2019-04-18 09:00:46 ERROR Exception on / [POST] Traceback (most recent call last): File "e:\anaconda\lib\site-packages\flask\app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "e:\anaconda\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "e:\anaconda\lib\site-packages\flask_cors\extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "e:\anaconda\lib\site-packages\flask\app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "e:\anaconda\lib\site-packages\flask\_compat.py", line 35, in reraise raise value File "e:\anaconda\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "e:\anaconda\lib\site-packages\flask\app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "e:\anaconda\lib\site-packages\simple_tensorflow_serving\server.py", line 184, in decorated return f(*decorator_args, **decorator_kwargs) File "e:\anaconda\lib\site-packages\simple_tensorflow_serving\server.py", line 308, in inference json_result, status_code = do_inference() File "e:\anaconda\lib\site-packages\simple_tensorflow_serving\server.py", line 349, in do_inference if "model_name" in json_data: TypeError: argument of type 'NoneType' is not iterable 2019-04-18 09:00:46 INFO 127.0.0.1 - - [18/Apr/2019 09:00:46] "�[1m�[35mPOST / HTTP/1.1�[0m" 500 -

A little bit more documentation, what are keys?

Sorry for the noob question, but I'm new to the world of neural networks.

I have been doing some digging, but am unable to find out what the significance of keys within the input data.

input_data = {
  ...
  "data": {
      "keys": [[11.0], [2.0]],
      "features": [[1, 1, 1, 1, 1, 1, 1, 1, 1],
                   [1, 1, 1, 1, 1, 1, 1, 1, 1]]
  }
}

As far as I'm aware, features are the input for the neural network, in the above case, a 2d tensor.

What is the significance of keys and how do they correlate to the input to the neural network?

Support Python3

Python 2.7 will reach end-of-life in 2020. Is it possible to port this code to Python3? I tested and it did not work under python 3.4.

Unable to run on Kubernetes Cluster

Firstly thanks for the great work!

I am having difficulties trying to get simple_tensorflow_serving working on a Kubernetes cluster. Seems to be something with H20, logs are not descriptive enough for me to pinpoint it. It just keeps hanging on the connection refused error below.

01-15 20:11:07.286 10.0.0.41:54321       180    main      INFO: H2O started in 2983ms
01-15 20:11:07.286 10.0.0.41:54321       180    main      INFO:
01-15 20:11:07.286 10.0.0.41:54321       180    main      INFO: Open H2O Flow in your web browser: http://10.0.0.41:54321
01-15 20:11:07.287 10.0.0.41:54321       180    main      INFO:
01-15 20:11:09.699 10.0.0.41:54321       180    FJ-126-3  INFO: Cloud of size 2 formed [/10.0.0.5:54321, /10.0.0.41:54321]
2019-01-15 20:11:14 INFO     Try to get function from file: ./models/h2o_prostate_model/preprocess_function.marshal
2019-01-15 20:11:14 INFO     Try to get function from file: ./models/h2o_prostate_model/postprocess_function.marshal
2019-01-15 20:11:14 INFO     Try to initialize and connect the h2o server
Checking whether there is an H2O instance running at http://localhost:54321. connected.
Warning: Your H2O cluster version is too old (8 months and 27 days)! Please download and install the latest version from http://h2o.ai/download/
01-15 20:11:14.371 10.0.0.41:54321       180    #28758-13 INFO: POST /4/sessions, parms: {}
01-15 20:11:14.377 10.0.0.41:54321       180    #28758-13 INFO: Locking cloud to new members, because water.api.schemas4.SessionIdV4
01-15 20:11:14.414 10.0.0.41:54321       180    #.5:54321 ERRR: Got IO error when sending batch UDP bytes: java.net.ConnectException: Connection refused
01-15 20:11:14.717 10.0.0.41:54321       180    #.5:54321 ERRR: Got IO error when sending batch UDP bytes: java.net.ConnectException: Connection refused
01-15 20:11:15.020 10.0.0.41:54321       180    #.5:54321 ERRR: Got IO error when sending batch UDP bytes: java.net.ConnectException: Connection refused
01-15 20:11:15.322 10.0.0.41:54321       180    #.5:54321 ERRR: Got IO error when sending batch UDP bytes: java.net.ConnectException: Connection refused
01-15 20:11:15.625 10.0.0.41:54321       180    #.5:54321 ERRR: Got IO error when sending batch UDP bytes: java.net.ConnectException: Connection refused
01-15 20:11:15.928 10.0.0.41:54321       180    #.5:54321 ERRR: Got IO error when sending batch UDP bytes: java.net.ConnectException: Connection refused

docker1.7 can support GPU?

My linux system is centos6.3, which only support docker1.7, and does not support nvidia-docker(need docker>=1.13). How to run simple tensorflow serving with GPU?

a bug for model_config_file

Hi , I fixed just mount specified GPU device , and I have simple way to use gpu like:
docker run --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES='0,1' --rm -it -p 8500:8500 tobegit3hub/simple_tensorflow_serving:latest-gpu
this method can runing your docker image with gpu:0 and gpu:1.
[THE BUG is HERE]:
When I run your docker image in only one gpu device machine, it worked well, I can control usage of gpu memory with json file like /models/example/tensorflow_gpu_config.json. every flag such as "per_process_gpu_memory_fraction": 0.5 can be worked .

But when I run the same docker image with the same way and the same tensorflow_gpu_config.json file in machine with four gpu devices, even though I just mount only one gpu devices. It did not work. The flag such as "per_process_gpu_memory_fraction": 0.5 I used , but the code was still use full gpu memory !!
image

Did you check your docker in multiply gpu devices?

Container fails with errors - docker - tobegit3hub/simple_tensorflow_serving:latest-py34

@tobegit3hub

I'm trying to run the docker instance on windows 10.

(base) λ docker --version
Docker version 18.09.2, build 6247962

(base) λ docker run -d -p 8500:8500 tobegit3hub/simple_tensorflow_serving:latest-py34

Docker install completes properly with no errors. The container also startups with no obvious errors.

But, the endpoint at http://127.0.0.1:8500/ returns an internal server error.

(base) λ curl http://127.0.0.1:8500/
Internal Server Error

On inspection, docker's logs shows:

(base) λ docker logs 0b8b9968c3b9 
[uWSGI] getting INI configuration from /tmp/uwsgi.ini
*** Starting uWSGI 2.0.18 (64bit) on [Sat Jul 13 03:56:44 2019] ***
compiled with version: 6.3.0 20170516 on 10 July 2019 06:45:50
os: Linux-4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018
nodename: 0b8b9968c3b9
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /simple_tensorflow_serving
writing pidfile to /tmp/uwsgi.pid
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 0.0.0.0:8500 fd 3
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 6
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.4.10 (default, Mar 20 2019, 00:50:15)  [GCC 6.3.0 20170516]
Python main interpreter initialized at 0x5573028aa050
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145840 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
Traceback (most recent call last):
  File "./simple_tensorflow_serving/server.py", line 19, in <module>
    from manager import InferenceServiceManager
  File "./simple_tensorflow_serving/./manager.py", line 16, in <module>
    from tensorflow_inference_service import TensorFlowInferenceService
  File "./simple_tensorflow_serving/./tensorflow_inference_service.py", line 12, in <module>
    import tensorflow as tf
  File "/usr/local/lib/python3.4/site-packages/tensorflow/__init__.py", line 35, in <module>
    from tensorflow._api.v1 import compat
  File "/usr/local/lib/python3.4/site-packages/tensorflow/_api/v1/compat/__init__.py", line 21, in <module>
    from tensorflow._api.v1.compat import v1
  File "/usr/local/lib/python3.4/site-packages/tensorflow/_api/v1/compat/v1/__init__.py", line 649, in <module>
    from tensorflow_estimator.python.estimator.api._v1 import estimator
  File "/usr/local/lib/python3.4/site-packages/tensorflow_estimator/__init__.py", line 8, in <module>
    from tensorflow_estimator._api.v1 import estimator
  File "/usr/local/lib/python3.4/site-packages/tensorflow_estimator/_api/v1/estimator/__init__.py", line 8, in <module>
    from tensorflow_estimator._api.v1.estimator import experimental
  File "/usr/local/lib/python3.4/site-packages/tensorflow_estimator/_api/v1/estimator/experimental/__init__.py", line 8, in <module>
    from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder
  File "/usr/local/lib/python3.4/site-packages/tensorflow_estimator/python/estimator/__init__.py", line 25, in <module>
    import tensorflow_estimator.python.estimator.estimator_lib
  File "/usr/local/lib/python3.4/site-packages/tensorflow_estimator/python/estimator/estimator_lib.py", line 53, in <module>
    from tensorflow_estimator.python.estimator.inputs import inputs
  File "/usr/local/lib/python3.4/site-packages/tensorflow_estimator/python/estimator/inputs/inputs.py", line 23, in <module>
    from tensorflow_estimator.python.estimator.inputs.pandas_io import pandas_input_fn
  File "/usr/local/lib/python3.4/site-packages/tensorflow_estimator/python/estimator/inputs/pandas_io.py", line 31, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.4/site-packages/pandas-0.25.0rc0-py3.4-linux-x86_64.egg/pandas/__init__.py", line 30, in <module>
    from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
  File "/usr/local/lib/python3.4/site-packages/pandas-0.25.0rc0-py3.4-linux-x86_64.egg/pandas/_libs/__init__.py", line 3, in <module>
    from .tslibs import (
  File "/usr/local/lib/python3.4/site-packages/pandas-0.25.0rc0-py3.4-linux-x86_64.egg/pandas/_libs/tslibs/__init__.py", line 3, in <module>
    from .conversion import localize_pydatetime, normalize_date
  File "pandas/_libs/tslibs/conversion.pyx", line 234, in init pandas._libs.tslibs.conversion
AttributeError: type object 'pandas._libs.tslibs.conversion._TSObject' has no attribute '__reduce_cython__'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 9)
spawned uWSGI worker 1 (pid: 13, cores: 1)
spawned uWSGI http 1 (pid: 14)

Any ideas?

If I want to deploy module on cross-platform

If I want to deploy module on different-platform. For example I trained the module in python -Tensorflow enviroment. But I expect to use this module file in C++ windows env.
I reference some views on TF Serving saved_model_builder() function, it seems like a workable solution. And how could it easily transfer module in different platform within current solution?

Just some thinking about current project.

How to limited GPU memory?

Hi, I update your docker image tobegit3hub/simple_tensorflow_serving:latest-gpu and test it.
I found some problems:

  1. your docker default run simple_tensorflow_serving --model_config_file="./examples/model_config_file.json" but do not install ONNX, it is a small problem!

  2. tf-serving -gpu default is allocation ALL GPU Memory it was so terrible!!! look here , and luckly some have fixed it fixed code,
    Can you add these config and re-compile the TF-Serving.
    By the way , the method is per_process_gpu_memory_fraction but I think allow_growth=True but I do not know how to do it.
    I think the usage of gpu depend on model mybe right?

"error":"Invalid json data:

Thank your reply! I check your update and still questions:

  1. I run simple_tensorflow_serving --model_base_path="./models/tensorflow_template_application_model" and then run curl http://localhost:8500/v1/models/__tensorflow_template_application_model__/gen_client?language=python > client.py but the shell output:

zsh: no matches found: http://localhost:8500/v1/models/tensorflow_template_application_model/gen_client?language=python

  1. I replace tensorflow_template_application_model with default in model_config_file.json like this:
    image
    and the I run simple_tensorflow_serving --model_config_file="./examples/model_config_file.json"
    simple_tensorflow_serving is runing:
    image

In other terminal, I run python client.py:
image
the output is like this :
image

So. I have test your web _Test function:
image
result is the same. I can not get right result..

My input_data of client.py is wrong??

Enhancements for 3rd framework integration

@tobegit3hub, first of all, thanks for working on this framework, really appreciated!

While working on a prototype of YARN submarine project (YARN-8135). I saw this project and wanna to integrate this project into the model serving path.

There're a couple of requirements so far I can see:

  1. Be able to read HDFS files.
    This is P0 requirement since model could be very large.

  2. Allow recursively detect saved model path.
    Existing model serving expects folder with version numbers exist under the specified model path, it might be convenient for end users if the framework can recursively looking for models for serving.
    This is a P1 requirement.

  3. Expose REST APIs to get models-signatures / configs / status, etc.
    Existing simple_tensorflow_serving only exposes POST APIs for model serving, it's better to expose GET APIs as well since simple_tensorflow_serving might be launched in a different machine. We can expose information like:
    a. Status of the service. (including model name, paths, statuses, etc.)
    b. Configs of the service.
    c. Model signatures.
    d. Generate clients examples (with proper endpoint).

Thanks again!

可以用于搭建tensorflow_serving模型服务平台吗?

请教个问题,现在我们有需求搭建机器学习的模型服务平台,看到simple_tensorflow_serving,感觉这个工具还是很方便的,对于启动一个tensorflow serving和客户端的请求来说都很方便很灵活。
可是机器学习的模型服务平台又会涉及到模型的更新、自动化的部署、弹性扩容、灰度发布、测试和验证等多方面的内容,您觉得要做到这些,结合simple_tensorflow_serving,可以从哪些方面来考虑,会不会用到docker。
多谢!

message Invalid HTTP Version (2.0)

Hi

It seems like that the simple_tensorflow_serving does not support requests via http version 2.
Here's the logs:

2018-08-08 08:08:50 ERROR 127.0.0.1 - - [08/Aug/2018 08:08:50] code 505, message Invalid HTTP Version (2.0)
2018-08-08 08:08:50 INFO 127.0.0.1 - - [08/Aug/2018 08:08:50] "PRI * HTTP/2.0" HTTPStatus.HTTP_VERSION_NOT_SUPPORTED -

Will this be supported in future? or how can I solve this problem?

Thx

dashboard index.html templates not found

[2018-03-09 05:44:46,359] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "build/bdist.linux-x86_64/egg/simple_tensorflow_serving/server.py", line 88, in decorated
return f(*args, **kwargs)
File "build/bdist.linux-x86_64/egg/simple_tensorflow_serving/server.py", line 117, in index
model_graph_signature=str(inferenceService.model_graph_signature))
File "/usr/lib64/python2.7/site-packages/flask/templating.py", line 133, in render_template
return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 869, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 830, in get_template
return self._load_template(name, self.make_globals(globals))
File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 804, in _load_template
template = self.loader.load(self, name, globals)
File "/usr/lib/python2.7/site-packages/jinja2/loaders.py", line 113, in load
source, filename, uptodate = self.get_source(environment, name)
File "/usr/lib64/python2.7/site-packages/flask/templating.py", line 57, in get_source
return self._get_source_fast(environment, template)
File "/usr/lib64/python2.7/site-packages/flask/templating.py", line 82, in _get_source_fast
return loader.get_source(environment, template)
File "/usr/lib/python2.7/site-packages/jinja2/loaders.py", line 171, in get_source
f = open_if_exists(filename)
File "/usr/lib/python2.7/site-packages/jinja2/utils.py", line 154, in open_if_exists
return open(filename, mode)
IOError: [Errno 20] Not a directory: '/usr/lib/python2.7/site-packages/UNKNOWN-0.0.0-py2.7.egg/simple_tensorflow_serving/templates/index.html'
INFO:werkzeug:192.168.56.1 - - [09/Mar/2018 05:44:46] "GET / HTTP/1.1" 500 -

ImportError: No module named PIL

In a clean Python 2.7 virtualenv, with the command pip install simple_tensorflow_serving, then simple_tensorflow_serving -h, I get the error ImportError: No module named PIL.

It appears that the package pillow is not installed together with simple_tensorflow_serving as a dependency.

Model does not work , output is alway the same! not change

Hi, I update your docker image and test my model which saved by SavedModel function. my model just is resnet_50 for classification, when I saved model as SavedModel format, the result did not change whether I changed any input picture ???

My Model have problem? what is wrong with my model or some reason?

Here is my saved model code :
image

image

First, I build a resnet_50 compute graph ,
and then I reload graph and restore weights from checkpoint.
Finally, I use tf.saved_model to save and everything is ok. I have no error or trouble.

I write client code for it , here:
image
In client code , first I read a image into numpy.array,
then convert data of image to [1, 64, 64 ,3] dtype=float32, and convert numpy to list .
Finally, send a requests like code and show all result.

the result is always is:
image

image

Docker Run with ImportError: No module named tensorflow_inference_service

Traceback (most recent call last):
File "/usr/local/bin/simple_tensorflow_serving", line 11, in
load_entry_point('simple-tensorflow-serving==0.4.1', 'console_scripts', 'simple_tensorflow_serving')()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 476, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2700, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2318, in load
return self.resolve()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2324, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/local/lib/python2.7/site-packages/simple_tensorflow_serving-0.4.1-py2.7.egg/simple_tensorflow_serving/server.py", line 20, in
from tensorflow_inference_service import TensorFlowInferenceService
ImportError: No module named tensorflow_inference_service

ModuleNotFoundError: No module named 'tensorflow_inference_service'

Hello, sir. First of all, I want to thank you for your attempt to make tensorflow serving friendlier for a regular developer.
After installing simple_tensorflow_serving from your source code I run
simple_tensorflow_serving --port=8500 --model_base_path="./examples/tensorflow_template_application_model"
and get the following error:

$ simple_tensorflow_serving --port=8500 --model_base_path="./examples/tensorflow_template_application_model"
/Users/Dude/anaconda3/lib/python3.6/importlib/_bootstrap.py:205: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
  return f(*args, **kwds)
Traceback (most recent call last):
  File "/Users/Dude/anaconda3/bin/simple_tensorflow_serving", line 11, in <module>
    load_entry_point('simple-tensorflow-serving==0.1.2', 'console_scripts', 'simple_tensorflow_serving')()
  File "/Users/Dude/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 572, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Users/Dude/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2769, in load_entry_point
    return ep.load()
  File "/Users/Dude/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2422, in load
    return self.resolve()
  File "/Users/Dude/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2428, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Users/Dude/anaconda3/lib/python3.6/site-packages/simple_tensorflow_serving-0.1.2-py3.6.egg/simple_tensorflow_serving/server.py", line 10, in <module>
ModuleNotFoundError: No module named 'tensorflow_inference_service'

I have a macOS system. I'm sorry if this is a simple question, but I didn't find an answer in the internet. I'm looking forward to using your program for my bachelor project.

AttributeError: module 'tensorflow' has no attribute 'gfile'

I trained a simple mnist model with tensorflow 2.0 on Google Colab and saved it in the .json format. Then on running the command

!simple_tensorflow_serving --model_base_path="/" --model_platform="tensorflow"

It is showing the error AttributeError: module 'tensorflow' has no attribute 'gfile'

default is cpu mode?

Hi, it's me again. I realized if using tf serving should be used python27 for tensorflow and tf serving .
In your docker image , I see the tensorflow was installed with pypi and it is cpu mode. When I run CNN model such as resnet_50 , it is so slow for predicting!. Then I uninstall tensorflow and install tensorflow-gpu==1.10.1 with pip. anything is not change !! it is still slow!!.

My question is : Does the default mode is CPU? how can I run my model with GPU mode in your docker

There are great trouble when I use multiple gpu device!!!

When I use your docker image in only one gpu machine, everything is ok.
But when I use it in my four gpu machine, the gpu configure option like: "log_device_placement": true,, "allow_soft_placement": true,, "allow_growth": true,, "per_process_gpu_memory_fraction": 0.5, those not work.

ALL gpu memory of four 1080ti have been allocate. So I can not do anything ! Is not right!

please you check in multiple gpus , thank you

"...distribution was not found..."

Having another issue. I'm really trying to get a project up and running:

https://github.com/llSourcell/Make_Money_with_Tensorflow_2.0

...and am having nothing but problems so far, and maybe it's just because I'm not understanding, but I hope you can help again.

I've done a pip uninstall simple_tensorflow_serving to start fresh. I installed Bazel and re-built simple_tensorflow_serving from source on my Windows 10 machine. I try to run the suggested command again and now I receive this traceback:

C:\Users\windowshopr\Desktop\Python_Scripts\simple_tensorflow_serving-master>simple_tensorflow_serving --model_base_path="./models/tensorflow_template_application_model"

Traceback (most recent call last):
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\Scripts\simple_tensorflow_serving-script.py", line 6, in <module>
    from pkg_resources import load_entry_point
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\lib\site-packages\pkg_resources\__init__.py", line 3126, in <module>
    @_call_aside
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\lib\site-packages\pkg_resources\__init__.py", line 3110, in _call_aside
    f(*args, **kwargs)
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\lib\site-packages\pkg_resources\__init__.py", line 3139, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\lib\site-packages\pkg_resources\__init__.py", line 581, in _build_master
    ws.require(__requires__)
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\lib\site-packages\pkg_resources\__init__.py", line 898, in require
    needed = self.resolve(parse_requirements(requirements))
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\lib\site-packages\pkg_resources\__init__.py", line 784, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'simple-tensorflow-serving' distribution was not found and is required by the application

Any ideas on this one? Thanks!

ModuleNotFoundError

hi,
First of all, thanks for working on this repository. appreaciated! 👍

When I use 'simple_tensorflow_serving model_base_path="./models/tensorflow_template_application_model"', I got an error :
from gen_client import gen_client
ModuleNotFoundError: No module named 'gen_client'

I cannot tell why this error happened, looking forward to your reply!

KeyError: 'default'

Hi, it is me again. I think I have a lot of problems.
[1] : When I run simple_tensorflow_serving --model_config_file="./examples/model_config_file.json"
. and then run curl http://localhost:8500/v1/models/default/gen_json
the output is :
Client : {

<title>500 Internal Server Error</title>

<h1_1>Internal Server Error</h1_1>
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

}
Server log: {

  • Debug mode: off
    2018-09-05 15:46:35 INFO * Running on http://0.0.0.0:8500/ (Press CTRL+C to quit)
    2018-09-05 15:46:41 ERROR Exception on /v1/models/default/gen_json [GET]
    Traceback (most recent call last):
    File "/home/yue/.conda/envs/py35/lib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
    File "/home/yue/.conda/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/home/yue/.conda/envs/py35/lib/python3.5/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
    File "/home/yue/.conda/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/home/yue/.conda/envs/py35/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise
    raise value
    File "/home/yue/.conda/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
    File "/home/yue/.conda/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functionsrule.endpoint
    File "/home/yue/Deep_Learning/tmp/simple_tensorflow_serving/simple_tensorflow_serving/server.py", line 174, in decorated
    return f(*decorator_args, **decorator_kwargs)
    File "/home/yue/Deep_Learning/tmp/simple_tensorflow_serving/simple_tensorflow_serving/server.py", line 431, in gen_example_json
    inference_service = model_name_service_map[model_name]
    KeyError: 'default'
    2018-09-05 15:46:41 INFO 127.0.0.1 - - [05/Sep/2018 15:46:41] "GET /v1/models/default/gen_json HTTP/1.1" 500
    }

[2] : Multiple Models Started... , and I run client.py. my client.py is:
`#!/usr/bin/env python

import requests

def main():
endpoint = "http://127.0.0.1:8500"
input_data = {
"model_name": "tensorflow_template_application_model",
"model_version": 2,
"data": {
"keys": [[11.0], [2.0]],
"features": [[1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1]]
}
}
result = requests.post(endpoint, json=input_data)
print(result.text)

if name == "main":
main()`

but ,it error log:
{
$ python ./client.py

{"error":"Invalid json data: b'{"model_version": 2, "data": {"keys": [[11.0], [2.0]], "features": [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]}, "model_name": "tensorflow_template_application_model"}'"}

}

Could not find directory - Windows 10 and pip install

After running the pip install, I try running the suggested command and receive this error:

C:\Users\windowshopr>simple_tensorflow_serving --model_base_path="./models/tensorflow_template_application_model"
2019-05-14 23:06:28 INFO     bind: 0.0.0.0:8500
2019-05-14 23:06:28 INFO     host: 0.0.0.0
2019-05-14 23:06:28 INFO     port: 8500
2019-05-14 23:06:28 INFO     enable_ssl: False
2019-05-14 23:06:28 INFO     secret_pem: secret.pem
2019-05-14 23:06:28 INFO     secret_key: secret.key
2019-05-14 23:06:28 INFO     model_name: default
2019-05-14 23:06:28 INFO     model_base_path: ./models/tensorflow_template_application_model
2019-05-14 23:06:28 INFO     model_platform: tensorflow
2019-05-14 23:06:28 INFO     model_config_file:
2019-05-14 23:06:28 INFO     reload_models: False
2019-05-14 23:06:28 INFO     custom_op_paths:
2019-05-14 23:06:28 INFO     session_config: {}
2019-05-14 23:06:28 INFO     debug: False
2019-05-14 23:06:28 INFO     log_level: info
2019-05-14 23:06:28 INFO     gen_client:
2019-05-14 23:06:28 INFO     enable_auth: False
2019-05-14 23:06:28 INFO     auth_username: admin
2019-05-14 23:06:28 INFO     auth_password: admin
2019-05-14 23:06:28 INFO     enable_colored_log: False
2019-05-14 23:06:28 INFO     enable_cors: True
2019-05-14 23:06:28 INFO     download_inference_images: True
Traceback (most recent call last):
  File "c:\users\windowshopr\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\windowshopr\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\Scripts\simple_tensorflow_serving.exe\__main__.py", line 5, in <module>
  File "c:\users\windowshopr\appdata\local\programs\python\python36\lib\site-packages\simple_tensorflow_serving\server.py", line 252, in <module>
    session_config)
  File "c:\users\windowshopr\appdata\local\programs\python\python36\lib\site-packages\simple_tensorflow_serving\tensorflow_inference_service.py", line 70, in __init__
    model_versions = self.get_all_model_versions()
  File "c:\users\windowshopr\appdata\local\programs\python\python36\lib\site-packages\simple_tensorflow_serving\tensorflow_inference_service.py", line 315, in get_all_model_versions
    model_versions = tf.gfile.ListDirectory(self.model_base_path)
  File "c:\users\windowshopr\appdata\local\programs\python\python36\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 482, in list_directory
    raise errors.NotFoundError(None, None, "Could not find directory")
tensorflow.python.framework.errors_impl.NotFoundError: Could not find directory

Any ideas?

how to shut down a service?

Thank you.
It works very well.
But I still have a few questions.
The first is, how to shut down a service?
The second is ,how to enable the second service when the first service is running?

custom_op (Registered only GPU kernel) failed to load

Hi,

I'm new to tensorflow serving. I'm trying to serving my trained model via simple_tensorflow_serving. However, after I run next line command, it failed to recognize the custom_ops that only registed with GPU kernels.

simple_tensorflow_serving --model_base_path="./models/pointnet2_sem_seg/" --custom_op_paths="./custom_ops/" --session_config='{"log_device_placement": true, "allow_soft_placement": true, "allow_growth": true, "per_process_gpu_memory_fraction": 0.5}'

Result:

2019-04-25 10:26:55 INFO     custom_op_paths: ./custom_ops/
2019-04-25 10:26:55 INFO     debug: False
2019-04-25 10:26:55 INFO     enable_cors: True
2019-04-25 10:26:55 INFO     model_config_file: 
2019-04-25 10:26:55 INFO     host: 0.0.0.0
2019-04-25 10:26:55 INFO     secret_key: secret.key
2019-04-25 10:26:55 INFO     model_name: default
2019-04-25 10:26:55 INFO     port: 8500
2019-04-25 10:26:55 INFO     enable_auth: False
2019-04-25 10:26:55 INFO     model_platform: tensorflow
2019-04-25 10:26:55 INFO     reload_models: False
2019-04-25 10:26:55 INFO     enable_colored_log: False
2019-04-25 10:26:55 INFO     log_level: info
2019-04-25 10:26:55 INFO     auth_username: admin
2019-04-25 10:26:55 INFO     auth_password: admin
2019-04-25 10:26:55 INFO     model_base_path: ./models/pointnet2_sem_seg/
2019-04-25 10:26:55 INFO     gen_client: 
2019-04-25 10:26:55 INFO     bind: 0.0.0.0:8500
2019-04-25 10:26:55 INFO     session_config: {"log_device_placement": true, "allow_soft_placement": true, "allow_growth": true, "per_process_gpu_memory_fraction": 0.5}
2019-04-25 10:26:55 INFO     download_inference_images: True
2019-04-25 10:26:55 INFO     secret_pem: secret.pem
2019-04-25 10:26:55 INFO     enable_ssl: False
2019-04-25 10:26:55 INFO     Load the so file from: ./custom_ops/tf_grouping_so.so
2019-04-25 10:26:55 INFO     Load the so file from: ./custom_ops/tf_interpolate_so.so
2019-04-25 10:26:55 INFO     Load the so file from: ./custom_ops/tf_sampling_so.so
2019-04-25 10:26:55.137247: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Device mapping:
/job:localhost/replica:0/task:0/device:XLA_CPU:0 -> device: XLA_CPU device
2019-04-25 10:26:55.140876: I tensorflow/core/common_runtime/direct_session.cc:307] Device mapping:
/job:localhost/replica:0/task:0/device:XLA_CPU:0 -> device: XLA_CPU device

2019-04-25 10:26:55 INFO     Put the model version: 1 online, path: ./models/pointnet2_sem_seg/1
INFO:tensorflow:Restoring parameters from ./models/pointnet2_sem_seg/1/variables/variables
2019-04-25 10:26:55 INFO     Restoring parameters from ./models/pointnet2_sem_seg/1/variables/variables
Traceback (most recent call last):
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call
    return fn(*args)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1317, in _run_fn
    self._extend_graph()
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1352, in _extend_graph
    tf_session.ExtendSession(self._session)
tensorflow.python.framework.errors_impl.InvalidArgumentError: No OpKernel was registered to support Op 'FarthestPointSample' with these attrs.  Registered devices: [CPU,XLA_CPU], Registered kernels:
  device='GPU'

	 [[{{node layer1/FarthestPointSample}} = FarthestPointSample[npoint=1024, _device="/device:GPU:0"](input)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1546, in restore
    {self.saver_def.filename_tensor_name: save_path})
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 929, in run
    run_metadata_ptr)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1152, in _run
    feed_dict_tensor, options, run_metadata)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run
    run_metadata)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: No OpKernel was registered to support Op 'FarthestPointSample' with these attrs.  Registered devices: [CPU,XLA_CPU], Registered kernels:
  device='GPU'

	 [[node layer1/FarthestPointSample (defined at /home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/tensorflow_inference_service.py:175)  = FarthestPointSample[npoint=1024, _device="/device:GPU:0"](input)]]

Caused by op 'layer1/FarthestPointSample', defined at:
  File "/home/jake/anaconda3/envs/PointNetPP/bin/simple_tensorflow_serving", line 7, in <module>
    from simple_tensorflow_serving.server import main
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
  File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 697, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/server.py", line 252, in <module>
    session_config)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/tensorflow_inference_service.py", line 72, in __init__
    self.load_saved_model_version(model_version)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/tensorflow_inference_service.py", line 175, in load_saved_model_version
    session, [tf.saved_model.tag_constants.SERVING], model_file_path)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/saved_model/loader_impl.py", line 197, in load
    return loader.load(sess, tags, import_scope, **saver_kwargs)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/saved_model/loader_impl.py", line 350, in load
    **saver_kwargs)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/saved_model/loader_impl.py", line 278, in load_graph
    meta_graph_def, import_scope=import_scope, **saver_kwargs)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1696, in _import_meta_graph_with_return_elements
    **kwargs))
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/meta_graph.py", line 806, in import_scoped_meta_graph_with_return_elements
    return_elements=return_elements)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/importer.py", line 442, in import_graph_def
    _ProcessNewOps(graph)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/importer.py", line 234, in _ProcessNewOps
    for new_op in graph._add_new_tf_operations(compute_devices=False):  # pylint: disable=protected-access
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3440, in _add_new_tf_operations
    for c_op in c_api_util.new_tf_operations(self)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3440, in <listcomp>
    for c_op in c_api_util.new_tf_operations(self)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3299, in _create_op_from_tf_operation
    ret = Operation(c_op, self)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1770, in __init__
    self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): No OpKernel was registered to support Op 'FarthestPointSample' with these attrs.  Registered devices: [CPU,XLA_CPU], Registered kernels:
  device='GPU'

	 [[node layer1/FarthestPointSample (defined at /home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/tensorflow_inference_service.py:175)  = FarthestPointSample[npoint=1024, _device="/device:GPU:0"](input)]]


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jake/anaconda3/envs/PointNetPP/bin/simple_tensorflow_serving", line 7, in <module>
    from simple_tensorflow_serving.server import main
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/server.py", line 252, in <module>
    session_config)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/tensorflow_inference_service.py", line 72, in __init__
    self.load_saved_model_version(model_version)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/tensorflow_inference_service.py", line 175, in load_saved_model_version
    session, [tf.saved_model.tag_constants.SERVING], model_file_path)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/saved_model/loader_impl.py", line 197, in load
    return loader.load(sess, tags, import_scope, **saver_kwargs)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/saved_model/loader_impl.py", line 351, in load
    self.restore_variables(sess, saver, import_scope)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/saved_model/loader_impl.py", line 303, in restore_variables
    saver.restore(sess, self._variables_path)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1582, in restore
    err, "a mismatch between the current graph and the graph")
tensorflow.python.framework.errors_impl.InvalidArgumentError: Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

No OpKernel was registered to support Op 'FarthestPointSample' with these attrs.  Registered devices: [CPU,XLA_CPU], Registered kernels:
  device='GPU'

	 [[node layer1/FarthestPointSample (defined at /home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/tensorflow_inference_service.py:175)  = FarthestPointSample[npoint=1024, _device="/device:GPU:0"](input)]]

Caused by op 'layer1/FarthestPointSample', defined at:
  File "/home/jake/anaconda3/envs/PointNetPP/bin/simple_tensorflow_serving", line 7, in <module>
    from simple_tensorflow_serving.server import main
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
  File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 697, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/server.py", line 252, in <module>
    session_config)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/tensorflow_inference_service.py", line 72, in __init__
    self.load_saved_model_version(model_version)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/tensorflow_inference_service.py", line 175, in load_saved_model_version
    session, [tf.saved_model.tag_constants.SERVING], model_file_path)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/saved_model/loader_impl.py", line 197, in load
    return loader.load(sess, tags, import_scope, **saver_kwargs)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/saved_model/loader_impl.py", line 350, in load
    **saver_kwargs)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/saved_model/loader_impl.py", line 278, in load_graph
    meta_graph_def, import_scope=import_scope, **saver_kwargs)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1696, in _import_meta_graph_with_return_elements
    **kwargs))
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/meta_graph.py", line 806, in import_scoped_meta_graph_with_return_elements
    return_elements=return_elements)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/importer.py", line 442, in import_graph_def
    _ProcessNewOps(graph)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/importer.py", line 234, in _ProcessNewOps
    for new_op in graph._add_new_tf_operations(compute_devices=False):  # pylint: disable=protected-access
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3440, in _add_new_tf_operations
    for c_op in c_api_util.new_tf_operations(self)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3440, in <listcomp>
    for c_op in c_api_util.new_tf_operations(self)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3299, in _create_op_from_tf_operation
    ret = Operation(c_op, self)
  File "/home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1770, in __init__
    self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

No OpKernel was registered to support Op 'FarthestPointSample' with these attrs.  Registered devices: [CPU,XLA_CPU], Registered kernels:
  device='GPU'

	 [[node layer1/FarthestPointSample (defined at /home/jake/anaconda3/envs/PointNetPP/lib/python3.5/site-packages/simple_tensorflow_serving/tensorflow_inference_service.py:175)  = FarthestPointSample[npoint=1024, _device="/device:GPU:0"](input)]]

Have anyone has come across this issue? What should I do next?

About STFS-gpu Performance

Hi, my model is work and every is ok. thank you. But in my test case, I found some bugs.

1) Usage of GPU memory:

My model is resnet-50 and I was set session_config flag such as "log_device_placement": true, "allow_soft_placement": true, "allow_growth": true , I do not use "per_process_gpu_memory_fraction": 0.5 because it will limit 50% gpu memory use whether your model is small or big.
So, when I start a serving at first time. the usage of gpu memory is 340+MB, I think it is reasonable. but when I run client code once or more. the usage of gpu memory growth untill 7.4GB. I do not know why, do you check it?

2) cost time of inference:

I test my model with frozen.pb on Session mode , the cost time is about 6-7ms of sess.run(). But when I deploy this model on STFS with gpu, it cost 40ms once! I think you have checked your STFS performace with other deploy framework. but , do you compare the cost time of Session.run() with TF-Serving run??

AbstractInferenceService

from abstract_inference_service import AbstractInferenceService
ImportError: No module named abstract_inference_service

gpu support

From your introduction, it says "support inference with accelerated GPU". How to make it happen? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.