本次分析主要找到对应于图中loader部分的代码,代码的具体实现和内部使用后续分析。

image.png
Loader
A standardized abstraction for an object that manages the lifecycle of a
/// servable, including loading and unloading it.
/// A standardized abstraction for an object that manages the lifecycle of a
/// servable, including loading and unloading it. Servables are arbitrary
/// objects that serve algorithms or data that often, though not necessarily,
/// use a machine-learned model.
///
/// A Loader for a servable object represents one instance of a stream of
/// servable versions, all sharing a common name (e.g. "my_servable") and
/// increasing version numbers, typically representing updated model parameters
/// learned from fresh training data.
///
/// A Loader should start in an unloaded state, meaning that no work has been
/// done to prepare to perform operations. A typical instance that has not yet
/// been loaded contains merely a pointer to a location from which its data can
/// be loaded (e.g. a file-system path or network location). Construction and
/// destruction of instances should be fairly cheap. Expensive initialization
/// operations should be done in Load().
///
/// Subclasses may optionally store a pointer to the Source that originated it,
/// for accessing state shared across multiple servable objects in a given
/// servable stream.
///
/// Implementations need to ensure that the methods they expose are thread-safe,
/// or carefully document and/or coordinate their thread-safety properties with
/// their clients to ensure correctness.
/// Servables do not need to worry about concurrent execution of Load()/Unload()
/// as the caller will ensure that does not happen.
class Loader {
public:
/// The destructor will never be called on a Loader whose servable is
/// currently loaded, i.e. between (successful) calls to Load() and Unload().
virtual ~Loader() = default;
/// Estimates the resources a servable will use.
///
/// IMPORTANT: This method's implementation must obey following requirements,
/// which enable the serving system to reason correctly about which servables
/// can be loaded safely:
/// 1. The estimate must represent an upper bound on the actual value.
/// 2. Prior to load, the estimate may include resources that are not bound
/// to any specific device instance, e.g. RAM on one of the two GPUs.
/// 3. While loaded, for any devices with multiple instances (e.g. two GPUs),
/// the estimate must specify the instance to which each resource is
/// bound.
/// 4. The estimate must be monotonically non-increasing, i.e. it cannot
/// increase over time. Reasons to have it potentially decrease over time
// include: (a) replace conservative estimate with actual measurement
// once loaded in memory; (b) load process consumes extra transient
// memory that is not used in steady-state after the load completes.
///
/// @return an estimate of the resources the servable will consume once
/// loaded. If the servable has already been loaded, returns an estimate of
/// the actual resource usage.
virtual Status EstimateResources(ResourceAllocation* estimate) const = 0;
/// Fetches any data that needs to be loaded before using the servable
/// returned by servable(). May use no more resources than the estimate
/// reported by EstimateResources().
///
/// If implementing Load(), you don't have to override LoadWithMetadata().
virtual Status Load() {
return errors::Unimplemented("Load isn't implemented.");
}
/// The metadata consists of the ServableId.
struct Metadata {
ServableId servable_id;
};
/// Similar to the above method, but takes Metadata as a param, which
/// may be used by the loader implementation appropriately.
///
/// If you're overriding LoadWithMetadata(), because you can use the metadata
/// appropriately, you can skip overriding Load().
virtual Status LoadWithMetadata(const Metadata& metadata) { return Load(); }
/// Frees any resources allocated during Load() (except perhaps for resources
/// shared across servables that are still needed for other active ones).
/// The loader does not need to return to the "new" state (i.e. Load() cannot
/// be called after Unload()).
virtual void Unload() = 0;
/// Returns an opaque interface to the underlying servable object.
/// The caller should know the precise type of the interface in order to make
/// actual use of it. For example:
///
/// CustomLoader implementation:
///
/// class CustomLoader : public Loader {
/// public:
/// ...
/// Status Load() override {
/// servable_ = ...;
/// }
///
/// AnyPtr servable() override { return servable_; }
///
/// private:
/// CustomServable* servable_ = nullptr;
/// };
///
/// Serving user request:
///
/// ServableHandle<CustomServable> handle = ...
/// CustomServable* servable = handle.get();
/// servable->...
///
/// If servable() is called after successful Load() and before Unload(), it
/// returns a valid, non-null AnyPtr object. If called before a successful
/// Load() call or after Unload(), it returns null AnyPtr.
virtual AnyPtr servable() = 0;
};
SimpleLoader
// SimpleLoader is a wrapper that simplifies Loader creation for common, simple
// use-cases that conform to the following restrictions:
// - The servable's estimated resource footprint is static.
// - The servable can be loaded by invoking a no-argument closure.
// - The servable can be unloaded by invoking its destructor.
//
// When constructing a SimpleLoader users provide a Creator callback. This
// callback is used in the Load() method to construct a servable of type
// ServableType and populate the servable. The servable object is destroyed when
// Unload() is called.
//
// SimpleLoader uses a second supplied callback to estimate the servable's
// resource usage. It memoizes that callback's result, for efficiency. If main-
// memory resources are specified, Unload() releases that amount of memory to
// the OS after deleting the servable.
//
// Example use: create a toy Loader for a servable of type time_t. Here the
// time servable is instantiated with the current time when Load() is called.
// auto servable_creator = [](std::unique_ptr<time_t>* servable) {
// servable->reset(new time_t);
// *servable = time(nullptr);
// return Status::OK();
// };
// auto resource_estimator = [](ResourceAllocation* estimate) {
// estimate->mutable_...(...)->set_...(...);
// return Status::OK();
// };
// std::unique_ptr<Loader> loader(new SimpleLoader<time_t>(
// servable_creator, resource_estimator));
//
// This class is not thread-safe. Synchronization is assumed to be done by the
// caller.
template <typename ServableType>
class SimpleLoader : public Loader {
public:
// Creator is called in Load and used to create the servable.
using Creator = std::function<Status(std::unique_ptr<ServableType>*)>;
using CreatorWithMetadata =
std::function<Status(const Metadata&, std::unique_ptr<ServableType>*)>;
using CreatorVariant = absl::variant<Creator, CreatorWithMetadata>;
// A callback for estimating a servable's resource usage.
using ResourceEstimator = std::function<Status(ResourceAllocation*)>;
// Returns a dummy resource-estimation callback that estimates the servable's
// resource footprint at zero. Useful in best-effort or test environments that
// do not track resource usage.
//
// IMPORTANT: Use of EstimateNoResources() abdicates resource safety, i.e. a
// loader using that option does not declare its servable's resource usage,
// and hence the serving system cannot enforce resource safety.
static ResourceEstimator EstimateNoResources();
// Constructor that takes a single resource estimator, to use for estimating
// the resources needed during load as well as post-load.
SimpleLoader(Creator creator, ResourceEstimator resource_estimator);
// Similar to the above constructor, but accepts a CreatorWithMetadata
// function.
SimpleLoader(CreatorWithMetadata creator_with_metadata,
ResourceEstimator resource_estimator);
// Constructor that takes two resource estimators: one to use for estimating
// the resources needed during load, as well as a second one that gives a
// different estimate after loading has finished. See the documentation on
// Loader::EstimateResources() for (a) potential reasons the estimate might
// decrease, and (b) correctness constraints on how the estimate is allowed to
// change over time.
SimpleLoader(Creator creator, ResourceEstimator resource_estimator,
ResourceEstimator post_load_resource_estimator);
// Similar to the above constructor, but accepts a CreatorWithMetadata
// function.
SimpleLoader(CreatorWithMetadata creator_with_metadata,
ResourceEstimator resource_estimator,
ResourceEstimator post_load_resource_estimator);
// Constructor which accepts all variations of the params.
SimpleLoader(CreatorVariant creator_variant,
ResourceEstimator resource_estimator,
optional<ResourceEstimator> post_load_resource_estimator);
~SimpleLoader() override = default;
Status EstimateResources(ResourceAllocation* estimate) const override;
// REQUIRES: That the ctor with Creator be used, otherwise returns an error
// status.
Status Load() override;
Status LoadWithMetadata(const Metadata& metadata) override;
void Unload() override;
AnyPtr servable() override { return AnyPtr{servable_.get()}; }
private:
Status EstimateResourcesPostLoad();
CreatorVariant creator_variant_;
// A function that estimates the resources needed to load the servable.
ResourceEstimator resource_estimator_;
// An optional function that estimates the resources needed for the servable
// after it has been loaded. (If omitted, 'resource_estimator_' should be used
// for all estimates, i.e. before, during and after load.)
optional<ResourceEstimator> post_load_resource_estimator_;
// The memoized estimated resource requirement of the servable.
mutable optional<ResourceAllocation> memoized_resource_estimate_;
std::unique_ptr<ResourceUtil> resource_util_;
Resource ram_resource_;
std::unique_ptr<ServableType> servable_;
TF_DISALLOW_COPY_AND_ASSIGN(SimpleLoader);
};
loader子类
跟踪LoadWithMetadata实现找到loader使用的具体类为SimpleLoader
#0 tensorflow::serving::SimpleLoader<tensorflow::SavedModelBundle>::LoadWithMetadata (this=0x7ffff0001240, metadata=...)
at ./tensorflow_serving/core/simple_loader.h:302
#1 0x000000000093017c in operator() (__closure=<optimized out>) at tensorflow_serving/core/loader_harness.cc:80
#2 std::_Function_handler<tensorflow::Status(), tensorflow::serving::LoaderHarness::Load()::<lambda()> >::_M_invoke(const std::_Any_data &) (__functor=...)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:302
#3 0x0000000000932ec9 in operator() (this=0x7fffedff9260)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#4 tensorflow::serving::Retry(std::string const&, unsigned int, long long, std::function<tensorflow::Status ()> const&, std::function<bool ()> const&) (description=..., max_num_retries=max_num_retries@entry=5,
retry_interval_micros=retry_interval_micros@entry=60000000, retried_fn=..., is_cancelled=...)
at tensorflow_serving/util/retrier.cc:35
#5 0x0000000000931c87 in tensorflow::serving::LoaderHarness::Load (this=this@entry=0x7fffe8000950)
at tensorflow_serving/core/loader_harness.cc:81
#6 0x000000000092a39e in tensorflow::serving::BasicManager::ExecuteLoad (this=0x11a5e8b0, harness=0x7fffe8000950)
at tensorflow_serving/core/basic_manager.cc:492
#7 0x000000000092a97f in tensorflow::serving::BasicManager::ExecuteLoadOrUnload (this=this@entry=0x11a5e8b0, request=...,
harness=<optimized out>) at tensorflow_serving/core/basic_manager.cc:569
#8 0x000000000092c3d6 in tensorflow::serving::BasicManager::HandleLoadOrUnloadRequest(tensorflow::serving::BasicManager::LoadOrUnloadRequest const&, std::function<void (tensorflow::Status const&)>) (this=this@entry=0x11a5e8b0, request=..., done_callback=...)
at tensorflow_serving/core/basic_manager.cc:657
#9 0x000000000092c634 in operator() (__closure=0x7fffe8000c60) at tensorflow_serving/core/basic_manager.cc:626
#10 std::_Function_handler<void(), tensorflow::serving::BasicManager::LoadOrUnloadServable(const tensorflow::serving::BasicManager::LoadOrUnloadRequest&, tensorflow::serving::BasicManager::DoneCallback)::<lambda()> >::_M_invoke(const std::_Any_data &) (
__functor=...)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:316
#11 0x00000000081cf69b in operator() (this=<optimized out>)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#12 ExecuteTask (this=0x11a65b48, t=...) at external/org_tensorflow/tensorflow/core/platform/threadpool.cc:85
#13 Eigen::ThreadPoolTempl<tensorflow::thread::EigenEnvironment>::WorkerLoop (this=<optimized out>, thread_id=<optimized out>)
at external/eigen_archive/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h:326
#14 0x00000000081cb8b3 in operator() (this=0x11a6b2e8)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#15 operator() (__closure=0x11a6b2e0) at external/org_tensorflow/tensorflow/core/platform/threadpool.cc:62
#16 std::_Function_handler<void (), tensorflow::thread::EigenEnvironment::CreateThread(std::function<void ()>)::{lambda()#1}>::_M_invoke(std::_Any_data const&) (__functor=...)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:316
#17 0x00007ffff7b129ff in std::execute_native_thread_routine (__p=0x11a6b310)
at ../../../../../libstdc++-v3/src/c++11/thread.cc:83
#18 0x00007ffff7542ea5 in start_thread (arg=0x7fffedffb700) at pthread_create.c:307
#19 0x00007ffff6c498dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
SimpleLoader:: LoadWithMetadata
SimpleLoader的具体调用内部部分,后续分析参考。
#0 tensorflow::ReadMetaGraphDefFromSavedModel (export_dir=..., tags=..., meta_graph_def=meta_graph_def@entry=0x7fffe0001390)
at external/org_tensorflow/tensorflow/cc/saved_model/reader.cc:83
#1 0x00000000077aae6b in tensorflow::(anonymous namespace)::LoadSavedModelInternal (session_options=..., run_options=...,
export_dir=..., tags=..., bundle=bundle@entry=0x7fffe0001380)
at external/org_tensorflow/tensorflow/cc/saved_model/loader.cc:285
#2 0x00000000077ac136 in tensorflow::LoadSavedModel (session_options=..., run_options=..., export_dir=..., tags=...,
bundle=bundle@entry=0x7fffe0001380) at external/org_tensorflow/tensorflow/cc/saved_model/loader.cc:331
#3 0x0000000001c5a017 in tensorflow::serving::session_bundle::LoadSessionBundleOrSavedModelBundle (session_options=...,
run_options=..., export_dir=..., tags=..., bundle=0x7fffe0001380, is_session_bundle=0x0)
at tensorflow_serving/session_bundle/oss/session_bundle_util.cc:52
#4 0x000000000094e1c9 in tensorflow::serving::SavedModelBundleFactory::InternalCreateSavedModelBundle (this=0x11a64b70,
metadata=..., path=..., bundle=bundle@entry=0x7ffff0001328)
at tensorflow_serving/servables/tensorflow/saved_model_bundle_factory.cc:144
#5 0x000000000094fec4 in tensorflow::serving::SavedModelBundleFactory::CreateSavedModelBundle (this=<optimized out>, path=...,
bundle=bundle@entry=0x7ffff0001328) at tensorflow_serving/servables/tensorflow/saved_model_bundle_factory.cc:116
#6 0x00000000009487d3 in operator() (bundle=0x7ffff0001328, __closure=0x7ffff0001340)
at tensorflow_serving/servables/tensorflow/saved_model_bundle_source_adapter.cc:68
#7 std::_Function_handler<tensorflow::Status(std::unique_ptr<tensorflow::SavedModelBundle, std::default_delete<tensorflow::SavedModelBundle> >*), tensorflow::serving::SavedModelBundleSourceAdapter::GetServableCreator(std::shared_ptr<tensorflow::serving::SavedModelBundleFactory>, const StoragePath&) const::<lambda(std::unique_ptr<tensorflow::SavedModelBundle, std::default_delete<tensorflow::SavedModelBundle> >*)> >::_M_invoke(const std::_Any_data &, <unknown type in /data/bazel_cache/264a8b0ede8d34e880b595ffed8a8ed6/execroot/tf_serving/bazel-out/k8-dbg/bin/tensorflow_serving/model_servers/tensorflow_model_server, CU 0x165a849, DIE 0x16cc135>) (__functor=..., __args#0=<optimized out>)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:302
#8 0x000000000094a035 in operator() (__args#0=<optimized out>, this=0x7ffff0001248)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#9 tensorflow::serving::SimpleLoader<tensorflow::SavedModelBundle>::LoadWithMetadata (this=0x7ffff0001240, metadata=...)
at ./tensorflow_serving/core/simple_loader.h:306
#10 0x000000000093017c in operator() (__closure=<optimized out>) at tensorflow_serving/core/loader_harness.cc:80
#11 std::_Function_handler<tensorflow::Status(), tensorflow::serving::LoaderHarness::Load()::<lambda()> >::_M_invoke(const std::_Any_data &) (__functor=...)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:302
#12 0x0000000000932ec9 in operator() (this=0x7fffedff9260)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#13 tensorflow::serving::Retry(std::string const&, unsigned int, long long, std::function<tensorflow::Status ()> const&, std::function<bool ()> const&) (description=..., max_num_retries=max_num_retries@entry=5,
retry_interval_micros=retry_interval_micros@entry=60000000, retried_fn=..., is_cancelled=...)
at tensorflow_serving/util/retrier.cc:35
#14 0x0000000000931c87 in tensorflow::serving::LoaderHarness::Load (this=this@entry=0x7fffe8000950)
at tensorflow_serving/core/loader_harness.cc:81
#15 0x000000000092a39e in tensorflow::serving::BasicManager::ExecuteLoad (this=0x11a5e8b0, harness=0x7fffe8000950)
at tensorflow_serving/core/basic_manager.cc:492
#16 0x000000000092a97f in tensorflow::serving::BasicManager::ExecuteLoadOrUnload (this=this@entry=0x11a5e8b0, request=...,
harness=<optimized out>) at tensorflow_serving/core/basic_manager.cc:569
#17 0x000000000092c3d6 in tensorflow::serving::BasicManager::HandleLoadOrUnloadRequest(tensorflow::serving::BasicManager::LoadOrUnloadRequest const&, std::function<void (tensorflow::Status const&)>) (this=this@entry=0x11a5e8b0, request=..., done_callback=...)
at tensorflow_serving/core/basic_manager.cc:657
#18 0x000000000092c634 in operator() (__closure=0x7fffe8000c60) at tensorflow_serving/core/basic_manager.cc:626
#19 std::_Function_handler<void(), tensorflow::serving::BasicManager::LoadOrUnloadServable(const tensorflow::serving::BasicManager::LoadOrUnloadRequest&, tensorflow::serving::BasicManager::DoneCallback)::<lambda()> >::_M_invoke(const std::_Any_data &) (
__functor=...)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:316
#20 0x00000000081cf69b in operator() (this=<optimized out>)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#21 ExecuteTask (this=0x11a65b48, t=...) at external/org_tensorflow/tensorflow/core/platform/threadpool.cc:85
#22 Eigen::ThreadPoolTempl<tensorflow::thread::EigenEnvironment>::WorkerLoop (this=<optimized out>, thread_id=<optimized out>)
at external/eigen_archive/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h:326
#23 0x00000000081cb8b3 in operator() (this=0x11a6b2e8)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#24 operator() (__closure=0x11a6b2e0) at external/org_tensorflow/tensorflow/core/platform/threadpool.cc:62
#25 std::_Function_handler<void (), tensorflow::thread::EigenEnvironment::CreateThread(std::function<void ()>)::{lambda()#1}>::_M_invoke(std::_Any_data const&) (__functor=...)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:316
#26 0x00007ffff7b129ff in std::execute_native_thread_routine (__p=0x11a6b310)
at ../../../../../libstdc++-v3/src/c++11/thread.cc:83
#27 0x00007ffff7542ea5 in start_thread (arg=0x7fffedffb700) at pthread_create.c:307
#28 0x00007ffff6c498dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
设置使用SimpleLoader的地方
#0 tensorflow::serving::SavedModelBundleSourceAdapter::Convert (this=<optimized out>, path=..., loader=0x7ffff6346bc8)
at tensorflow_serving/servables/tensorflow/saved_model_bundle_source_adapter.cc:110
#1 0x000000000094b947 in tensorflow::serving::UnarySourceAdapter<std::string, std::unique_ptr<tensorflow::serving::Loader, std::default_delete<tensorflow::serving::Loader> > >::Adapt (this=0x11a64e40, servable_name=..., versions=...)
at ./tensorflow_serving/core/source_adapter.h:213
#2 0x00000000008f89da in tensorflow::serving::SourceAdapter<std::string, std::unique_ptr<tensorflow::serving::Loader, std::default_delete<tensorflow::serving::Loader> > >::SetAspiredVersions (this=0x11a64e40, servable_name=..., versions=...)
at ./tensorflow_serving/core/source_adapter.h:180
#3 0x00000000008f6dee in operator() (
versions=<error reading variable: access outside bounds of object referenced via synthetic pointer>, servable_name=...,
__closure=<optimized out>) at ./tensorflow_serving/core/target.h:124
#4 _ZNSt17_Function_handlerIFvN4absl11string_viewESt6vectorIN10tensorflow7serving12ServableDataISsEESaIS6_EEEZNS4_10TargetBaseISsEC4EvEUlS1_S8_E_E9_M_invokeERKSt9_Any_dataOS1_OS8_ (__functor=..., __args#0=<optimized out>, __args#1=<optimized out>)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:316
#5 0x00000000008f707d in operator() (__args#1=..., __args#0=..., this=0x11a64f60)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#6 Notify (args#1=<error reading variable: access outside bounds of object referenced via synthetic pointer>, args#0=...,
this=0x11a64f50) at ./tensorflow_serving/util/observer.h:149
#7 operator() (args#1=<error reading variable: access outside bounds of object referenced via synthetic pointer>, args#0=...,
__closure=<optimized out>) at ./tensorflow_serving/util/observer.h:80
#8 std::_Function_handler<void (absl::string_view, std::vector<tensorflow::serving::ServableData<std::string>, std::allocator<tensorflow::serving::ServableData<std::string> > >), tensorflow::serving::Observer<absl::string_view const, std::vector<tensorflow::serving::ServableData<std::string>, std::allocator<tensorflow::serving::ServableData<std::string> > > >::Notifier() const::{lambda(absl::string_view, std::vector<tensorflow::serving::ServableData<std::string>, std::allocator<tensorflow::serving::ServableData<std::string> > >)#1}>::_M_invoke(std::_Any_data const&, absl::string_view&&, std::vector<tensorflow::serving::ServableData<std::string>, std::allocator<tensorflow::serving::ServableData<std::string> > >&&) (__functor=..., __args#0=<optimized out>,
__args#1=<optimized out>)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:316
#9 0x00000000008f6eff in operator() (__args#1=..., __args#0=..., this=0x11a650e8)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#10 tensorflow::serving::SourceAdapter<std::string, std::string>::SetAspiredVersions (this=0x11a650b0, servable_name=...,
versions=...) at ./tensorflow_serving/core/source_adapter.h:180
#11 0x00000000008fb7b0 in tensorflow::serving::SourceRouter<std::string>::SetAspiredVersions (this=0x11a64f90,
servable_name=..., versions=...) at ./tensorflow_serving/core/source_router.h:166
#12 0x00000000008f6dee in operator() (
versions=<error reading variable: access outside bounds of object referenced via synthetic pointer>, servable_name=...,
__closure=<optimized out>) at ./tensorflow_serving/core/target.h:124
#13 _ZNSt17_Function_handlerIFvN4absl11string_viewESt6vectorIN10tensorflow7serving12ServableDataISsEESaIS6_EEEZNS4_10TargetBaseISs
EC4EvEUlS1_S8_E_E9_M_invokeERKSt9_Any_dataOS1_OS8_ (__functor=..., __args#0=<optimized out>, __args#1=<optimized out>)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:316
#14 0x00000000008f707d in operator() (__args#1=..., __args#0=..., this=0x11a5a720)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#15 Notify (args#1=<error reading variable: access outside bounds of object referenced via synthetic pointer>, args#0=...,
this=0x11a5a710) at ./tensorflow_serving/util/observer.h:149
#16 operator() (args#1=<error reading variable: access outside bounds of object referenced via synthetic pointer>, args#0=...,
__closure=<optimized out>) at ./tensorflow_serving/util/observer.h:80
#17 std::_Function_handler<void (absl::string_view, std::vector<tensorflow::serving::ServableData<std::string>, std::allocator<tensorflow::serving::ServableData<std::string> > >), tensorflow::serving::Observer<absl::string_view const, std::vector<tensorflow::serving::ServableData<std::string>, std::allocator<tensorflow::serving::ServableData<std::string> > > >::Notifier() const::{lambda(absl::string_view, std::vector<tensorflow::serving::ServableData<std::string>, std::allocator<tensorflow::serving::ServableData<std::string> > >)#1}>::_M_invoke(std::_Any_data const&, absl::string_view&&, std::vector<tensorflow::serving::ServableData<std::string>, std::allocator<tensorflow::serving::ServableData<std::string> > >&&) (__functor=..., __args#0=<optimized out>,
__args#1=<optimized out>)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:316
#18 0x0000000001ccb668 in operator() (__args#1=..., __args#0=..., this=0x11a65530)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#19 CallAspiredVersionsCallback<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<tensorflow::serving::ServableData<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<tensorflow::serving::ServableData<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&> (this=0x11a654d0)
at ./tensorflow_serving/sources/storage_path/file_system_storage_path_source.h:100
#20 tensorflow::serving::FileSystemStoragePathSource::PollFileSystemAndInvokeCallback (this=0x11a654d0)
at tensorflow_serving/sources/storage_path/file_system_storage_path_source.cc:409
#21 0x0000000001ccbb20 in tensorflow::serving::FileSystemStoragePathSource::<lambda()>::operator()(void) const (
__closure=<optimized out>) at tensorflow_serving/sources/storage_path/file_system_storage_path_source.cc:360
#22 0x00000000028b1022 in operator() (this=0x11a65700)
at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_function.h:706
#23 tensorflow::serving::PeriodicFunction::RunLoop (this=0x11a65700, start=<optimized out>)
at external/org_tensorflow/tensorflow/core/kernels/batching_util/periodic_function.cc:77
#24 0x00007ffff7b129ff in std::execute_native_thread_routine (__p=0x11a65580)
at ../../../../../libstdc++-v3/src/c++11/thread.cc:83
#25 0x00007ffff7542ea5 in start_thread (arg=0x7ffff6349700) at pthread_create.c:307
#26 0x00007ffff6c498dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
参考:tensorflow serving 2.2.0代码