16 #ifndef TENSORFLOW_SERVING_MODEL_SERVERS_SERVER_H_
17 #define TENSORFLOW_SERVING_MODEL_SERVERS_SERVER_H_
21 #include "grpcpp/server.h"
22 #include "tensorflow/core/kernels/batching_util/periodic_function.h"
23 #include "tensorflow/core/lib/core/status.h"
24 #include "tensorflow/core/platform/cpu_info.h"
25 #include "tensorflow/core/platform/types.h"
26 #include "tensorflow/core/profiler/rpc/profiler_service_impl.h"
27 #include "tensorflow_serving/model_servers/http_server.h"
28 #include "tensorflow_serving/model_servers/model_service_impl.h"
29 #include "tensorflow_serving/model_servers/prediction_service_impl.h"
30 #include "tensorflow_serving/model_servers/server_core.h"
31 #include "tensorflow_serving/servables/tensorflow/thread_pool_factory.h"
33 namespace tensorflow {
43 tensorflow::int32 grpc_port = 8500;
44 tensorflow::string grpc_channel_arguments;
45 tensorflow::string grpc_socket_path;
46 tensorflow::int32 grpc_max_threads = 4.0 * port::NumSchedulableCPUs();
51 tensorflow::int32 http_port = 0;
52 tensorflow::int32 http_num_threads = 4.0 * port::NumSchedulableCPUs();
53 tensorflow::int32 http_timeout_in_ms = 30000;
54 bool enable_cors_support =
false;
59 bool enable_batching =
false;
60 bool enable_per_model_batching_params =
false;
61 bool allow_version_labels_for_unavailable_models =
false;
62 bool force_allow_any_version_labels_for_unavailable_models =
false;
63 float per_process_gpu_memory_fraction = 0;
64 tensorflow::string batching_parameters_file;
65 tensorflow::string model_name;
66 tensorflow::int32 num_load_threads = 0;
67 tensorflow::int32 num_unload_threads = 0;
68 tensorflow::int32 max_num_load_retries = 5;
69 int64_t load_retry_interval_micros = 1LL * 60 * 1000 * 1000;
70 tensorflow::int32 file_system_poll_wait_seconds = 1;
71 bool flush_filesystem_caches =
true;
72 tensorflow::string model_base_path;
73 tensorflow::string saved_model_tags;
76 int64_t tensorflow_session_parallelism = 0;
79 int64_t tensorflow_intra_op_parallelism = 0;
80 int64_t tensorflow_inter_op_parallelism = 0;
81 tensorflow::string platform_config_file;
84 bool use_alts_credentials =
false;
85 tensorflow::string ssl_config_file;
86 string model_config_file;
88 string tensorflow_session_config_file;
90 tensorflow::int32 fs_model_config_poll_wait_seconds = 0;
91 bool enable_model_warmup =
true;
93 tensorflow::int32 num_request_iterations_for_warmup = 0;
94 tensorflow::string monitoring_config_file;
96 bool enforce_session_run_timeout =
true;
97 bool remove_unused_fields_from_bundle_metagraph =
true;
98 bool prefer_tflite_model =
false;
99 tensorflow::int32 num_tflite_pools = port::NumSchedulableCPUs();
100 tensorflow::int32 num_tflite_interpreters_per_pool = 1;
101 tensorflow::string thread_pool_factory_config_file;
102 bool enable_signature_method_name_check =
false;
103 bool enable_profiler =
true;
104 tensorflow::string mixed_precision;
105 bool skip_initialize_tpu =
false;
107 bool enable_grpc_healthcheck_service =
false;
117 Status BuildAndStart(
const Options& server_options);
121 void WaitForTermination();
126 void PollFilesystemAndReloadConfig(
const string& config_file_path);
128 std::unique_ptr<ServerCore> server_core_;
129 std::unique_ptr<ModelServiceImpl> model_service_;
130 std::unique_ptr<PredictionService::Service> prediction_service_;
131 std::unique_ptr<tensorflow::grpc::ProfilerService::Service> profiler_service_;
132 std::unique_ptr<::grpc::Server> grpc_server_;
133 std::unique_ptr<net_http::HTTPServerInterface> http_server_;
136 std::unique_ptr<PeriodicFunction> fs_config_polling_thread_;
137 std::unique_ptr<ThreadPoolFactory> thread_pool_factory_;