|
|
NVIDIA DeepStream SDK API Reference
|
9.1 Release
|
Go to the documentation of this file.
29 #ifndef __NVDSINFER_TRTIS_SERVER_H__
30 #define __NVDSINFER_TRTIS_SERVER_H__
38 #include "infer_post_datatypes.h"
42 #include "nvds_version.h"
45 #define TRITON_DEFAULT_MINIMUM_COMPUTE_CAPABILITY 5.3
46 #define TRITON_DEFAULT_PINNED_MEMORY_BYTES (1 << 26)
48 #define TRITON_DEFAULT_MINIMUM_COMPUTE_CAPABILITY 6.0
49 #define TRITON_DEFAULT_PINNED_MEMORY_BYTES (1 << 28)
51 #define TRITON_DEFAULT_BACKEND_DIR "/opt/tritonserver/backends"
53 struct TRITONSERVER_Server;
57 namespace ni = inference;
60 class TrtServerRequest;
61 class TrtServerResponse;
62 class TrtServerAllocator;
73 class TrtServerRequest {
96 const std::vector<std::string>&
outputs, uint64_t reqId,
97 const std::vector<TritonClassParams>& clasList);
119 void* responseUserPtr);
128 TRITONSERVER_InferenceRequest* request,
const uint32_t flags,
140 TRITONSERVER_InferenceRequest*
ptr() {
return m_ReqPtr.get(); }
144 const std::string&
model()
const {
return m_Model; }
148 uint64_t
id()
const {
return m_ReqId; }
152 uint64_t
bufId()
const {
return m_BufId; }
161 const std::vector<std::string>&
outputs()
const {
return m_Outputs; }
166 const std::map<std::string, TritonClassParams>&
classParams()
const {
193 std::weak_ptr<TrtISServer> m_Server;
205 uint64_t m_ReqId = UINT64_C(0);
209 uint64_t m_BufId = UINT64_C(0);
214 std::vector<std::string> m_Outputs;
218 std::map<std::string, TritonClassParams> m_ClasList;
224 class TrtServerResponse {
235 TrtServerPtr server, UniqTritonT<TRITONSERVER_InferenceResponse> data,
253 const std::string&
model()
const {
return m_Model; }
299 uint32_t tensorIdx,
const void* base);
320 uint64_t m_ResponseId = UINT64_C(0);
328 std::weak_ptr<TrtISServer> m_Server;
336 int64_t m_ModelVersion = UINT64_C(1);
346 std::vector<SharedBatchBuf> m_BufOutputs;
356 class TrtServerAllocator
357 :
public std::enable_shared_from_this<TrtServerAllocator> {
379 TRITONSERVER_ResponseAllocator*
ptr() {
return m_Allocator.get(); }
397 static TRITONSERVER_Error* ResponseAlloc(
398 TRITONSERVER_ResponseAllocator* allocator,
const char* tensorName,
400 int64_t preferredDevId,
void* userP,
void** buffer,
void** bufferUserP,
413 static TRITONSERVER_Error* ResponseRelease(
414 TRITONSERVER_ResponseAllocator* allocator,
void* buffer,
440 struct BackendConfig {
458 struct RepoSettings {
462 std::set<std::string>
roots;
518 const ic::TritonModelRepo& repo,
const std::vector<int>& devIds);
526 bool operator==(
const RepoSettings& other)
const;
538 class TrtISServer :
public std::enable_shared_from_this<TrtISServer> {
603 bool isModelReady(
const std::string& model, int64_t version);
627 const std::string& model, int64_t version, ni::ModelConfig& config);
641 const std::vector<std::string>& outputs,
const std::vector<TritonClassParams>& clasList);
673 using InferUserData =
674 std::tuple<SharedRequest, TritonInferAsyncDone, TrtISServer*>;
684 static void InferComplete(
685 TRITONSERVER_InferenceResponse* response,
const uint32_t flags,
691 TRITONSERVER_Server* serverPtr()
const {
return m_Impl.get(); }
698 static std::weak_ptr<TrtISServer> sTrtServerInstance;
702 static std::mutex sTrtServerMutex;
708 UniqTritonT<TRITONSERVER_Server> m_Impl;
712 std::atomic<uint64_t> m_LastRequestId{UINT64_C(0)};
716 triton::RepoSettings m_RepoSettings;
double minComputeCapacity
The minimun supported compute compability for Triton server.
Header file of batch buffer related class declarations.
This is a header file for pre-processing cuda kernels with normalization and mean subtraction require...
bool initFrom(const ic::TritonModelRepo &repo, const std::vector< int > &devIds)
Populate the RepoSettings instance with the values from the TritonModelRepo protobuf message.
const std::vector< std::string > & outputs() const
Get the list of requested output layer names.
bool isModelReady(const std::string &model, int64_t version)
Check if the server is ready for inference using specified model.
NvDsInferStatus setRequestComplete(TRITONSERVER_InferenceRequestReleaseFn_t requestCompleteCb, void *userPtr)
Set the release callback function for the request.
enum TRITONSERVER_memorytype_enum TRITONSERVER_MemoryType
TRITONSERVER_MemoryType.
#define DISABLE_CLASS_COPY(NoCopyClass)
APIs/macros for some frequently used functionality.
uint64_t id() const
Get the request ID.
const std::map< std::string, TritonClassParams > & classParams() const
Get the Triton classification parameters list (tensor name : classification parameters).
std::string debugStr
Debug string of the TritonModelRepo protobuf message.
friend class TrtServerResponse
Wrapper class for Triton output parsing.
NvDsInferStatus getStatus() const
Check if the response could be parsed correctly.
std::shared_ptr< T > ShrTritonT
static TrtServerPtr getInstance(const triton::RepoSettings *repo)
Get a new or existing instance of the Triton Inference Server.
SharedRequest createRequest(const std::string &model, int64_t version, SharedBatchArray &inputs, const std::vector< std::string > &outputs, const std::vector< TritonClassParams > &clasList)
Create and initializes a new inference request.
uint64_t pinnedMemBytes
Pre-allocated pinned memory on host for Triton runtime.
bool strictModelConfig
Flag to enable/disable Triton strict model configuration.
std::shared_ptr< BaseBatchArray > SharedBatchArray
@ NVDSINFER_SUCCESS
NvDsInferContext operation succeeded.
Wrapper class for Triton server output memory allocator.
std::vector< SharedBatchBuf > & mutableOutputs()
Get the list of output batch buffers.
uint64_t bufId() const
Get the input buffer ID associated with the request.
bool isServerReady()
Check if the server is ready.
uint32_t logLevel
Level of the Triton log output.
std::function< void(SharedRequest, UniqResponse)> TritonInferAsyncDone
NvDsInferStatus initialize()
Create a new instance of the Triton Inference Server.
std::string backend
Name of the backend.
NvDsInferStatus getModelConfig(const std::string &model, int64_t version, ni::ModelConfig &config)
Get the model configuration for the specified model.
Model repository settings for the Triton Inference Server.
TRITONSERVER_ResponseAllocator * ptr()
Get the pointer to the TRITONSERVER_ResponseAllocator instance.
#define TRITON_DEFAULT_BACKEND_DIR
std::string key
Name of the setting.
TRITONSERVER_InferenceRequest * ptr()
Get the pointer to the Triton inference request object.
TrtISServer(const triton::RepoSettings &repo)
Constructor.
std::unique_ptr< T, std::function< void(T *)> > UniqTritonT
float tfGpuMemoryFraction
TensorFlow GPU memory fraction per process.
int32_t controlMode
Triton model control mode.
std::map< uint32_t, uint64_t > cudaDevMemMap
Map of the device IDs and corresponding size of CUDA memory pool to be allocated.
@ TRITONSERVER_MODEL_CONTROL_EXPLICIT
SharedOptions takeoverOptions()
Get and own the options list.
std::shared_ptr< TrtServerAllocator > ShrTritonAllocator
std::string value
Value of the setting.
std::shared_ptr< IOptions > SharedOptions
TrtServerRequest(TrtServerPtr server)
Constructor.
NvDsInferStatus init(const std::string &model, int64_t version, SharedBatchArray &inputs, const std::vector< std::string > &outputs, uint64_t reqId, const std::vector< TritonClassParams > &clasList)
Create a new Triton inference request with the specified inputs and parameters.
static void RequestOnRelease(TRITONSERVER_InferenceRequest *request, const uint32_t flags, void *userp)
The callback function to release the request instance.
#define TRITON_DEFAULT_PINNED_MEMORY_BYTES
const std::string & model() const
Get the model name parsed from the Triton response.
virtual ~TrtServerAllocator()=default
Destructor.
bool tfAllowSoftPlacement
Flag to enable/disable soft placement of TF operators.
std::shared_ptr< SysMem > SharedSysMem
std::function< SharedSysMem(const std::string &, size_t, InferMemType, int64_t)> AllocFn
std::shared_ptr< TrtServerResponse > SharedResponse
std::shared_ptr< TrtISServer > TrtServerPtr
~TrtServerRequest()
Destructor.
std::function< void(const std::string &, SharedSysMem)> FreeFn
bool isServerLive()
Check if the server is live.
std::string backendDirectory
The path to the Triton backends directory.
NvDsInferStatus parse(const TrtServerRequest *req)
Check for error and parse the inference output.
#define TRITON_DEFAULT_MINIMUM_COMPUTE_CAPABILITY
NvDsInferStatus setResponseComplete(ShrTritonAllocator &allocator, TRITONSERVER_InferenceResponseCompleteFn_t responseCompleteCb, void *responseUserPtr)
Set the allocator and response callback for the request.
bool operator!=(const RepoSettings &other) const
InferMemType
The memory types of inference buffers.
std::set< std::string > roots
Set of model repository directories.
std::vector< BackendConfig > backendConfigs
Array of backend configurations settings.
NvDsInferStatus loadModel(const std::string &modelName)
Load or reload the specified model.
bool operator==(const RepoSettings &other) const
Comparison operators.
~TrtISServer()
Destructor.
std::weak_ptr< TrtServerAllocator > WeakTritonAllocator
const std::string & model() const
Get the model name.
void(* TRITONSERVER_InferenceRequestReleaseFn_t)(struct TRITONSERVER_InferenceRequest *request, const uint32_t flags, void *userp)
Type for inference request release callback function.
void(* TRITONSERVER_InferenceResponseCompleteFn_t)(struct TRITONSERVER_InferenceResponse *response, const uint32_t flags, void *userp)
Type for callback function indicating that an inference response has completed.
std::unique_ptr< TrtServerResponse > UniqResponse
TrtServerResponse(TrtServerPtr server, UniqTritonT< TRITONSERVER_InferenceResponse > data, uint64_t id)
Constructor.
Wrapper class for Triton inference request.
friend class TrtServerRequest
NvDsInferStatus unloadModel(const std::string &modelName)
Unload the specified model.
std::shared_ptr< TrtServerRequest > SharedRequest
NvDsInferStatus inferAsync(SharedRequest request, WeakTritonAllocator allocator, TritonInferAsyncDone done)
Submit a request for asynchronous inference.
const triton::RepoSettings & getRepoSettings()
Get the model repository settings.
Triton Inference Server utilies header file.
SharedBatchArray releaseInputs()
Release the ownership of input batch buffer array.
TrtServerAllocator(AllocFn alloc, FreeFn release)
Constructor, create an instance of the type TRITONSERVER_ResponseAllocator which calls provided alloc...
NvDsInferStatus
Enum for the status codes returned by NvDsInferContext.
Holds the information about a inference buffer.