TensorRT 10.8.0
nvinfer1::IRuntime 类参考

允许反序列化功能上不安全的序列化引擎。 更多...

#include <NvInferRuntime.h>

nvinfer1::IRuntime 的继承关系图
nvinfer1::INoCopy

公共成员函数

virtual ~IRuntime () noexcept=default
 
void setDLACore (int32_t dlaCore) noexcept
 设置网络使用的 DLA 核心。默认为 -1。 更多...
 
int32_t getDLACore () const noexcept
 获取引擎在其上执行的 DLA 核心。 更多...
 
int32_t getNbDLACores () const noexcept
 返回可访问的 DLA 硬件核心数量,如果 DLA 不可用则返回 0。 更多...
 
void setGpuAllocator (IGpuAllocator *allocator) noexcept
 设置 GPU 分配器。 更多...
 
void setErrorRecorder (IErrorRecorder *recorder) noexcept
 为此接口设置 ErrorRecorder。 更多...
 
IErrorRecordergetErrorRecorder () const noexcept
 获取分配给此接口的 ErrorRecorder。 更多...
 
ICudaEnginedeserializeCudaEngine (void const *blob, std::size_t size) noexcept
 从主机内存反序列化引擎。 更多...
 
TRT_DEPRECATED ICudaEnginedeserializeCudaEngine (IStreamReader &streamReader)
 从流反序列化引擎。 更多...
 
ICudaEnginedeserializeCudaEngine (IStreamReaderV2 &streamReader)
 从流反序列化引擎。 IStreamReaderV2 预期支持读取到主机和设备指针。 更多...
 
ILoggergetLogger () const noexcept
 获取创建运行时所用的记录器 更多...
 
bool setMaxThreads (int32_t maxThreads) noexcept
 设置最大线程数。 更多...
 
int32_t getMaxThreads () const noexcept
 获取运行时可以使用的最大线程数。 更多...
 
void setTemporaryDirectory (char const *path) noexcept
 设置此运行时将用于临时文件的目录。 更多...
 
char const * getTemporaryDirectory () const noexcept
 获取此运行时将用于临时文件的目录。 更多...
 
void setTempfileControlFlags (TempfileControlFlags flags) noexcept
 为此运行时设置临时文件控制标志。 更多...
 
TempfileControlFlags getTempfileControlFlags () const noexcept
 获取此运行时的临时文件控制标志。 更多...
 
IPluginRegistrygetPluginRegistry () noexcept
 获取运行时可以使用的本地插件注册表。 更多...
 
IRuntimeloadRuntime (char const *path) noexcept
 从文件加载 IRuntime更多...
 
void setEngineHostCodeAllowed (bool allowed) noexcept
 设置运行时是否允许反序列化带有主机可执行代码的引擎。 更多...
 
bool getEngineHostCodeAllowed () const noexcept
 获取运行时是否允许反序列化带有主机可执行代码的引擎。 更多...
 

保护属性

apiv::VRuntime * mImpl
 

附加继承成员

- 继承自 nvinfer1::INoCopy 的保护成员函数
 INoCopy ()=default
 
virtual ~INoCopy ()=default
 
 INoCopy (INoCopy const &other)=delete
 
INoCopyoperator= (INoCopy const &other)=delete
 
 INoCopy (INoCopy &&other)=delete
 
INoCopyoperator= (INoCopy &&other)=delete
 

详细描述

允许反序列化功能上不安全的序列化引擎。

警告
不要从此类继承,这样做会破坏 API 和 ABI 的向前兼容性。

构造函数 & 析构函数文档

◆ ~IRuntime()

virtual nvinfer1::IRuntime::~IRuntime ( )
virtualdefaultnoexcept

成员函数文档

◆ deserializeCudaEngine() [1/3]

TRT_DEPRECATED ICudaEngine * nvinfer1::IRuntime::deserializeCudaEngine ( IStreamReader streamReader)
inline

从流反序列化引擎。

如果为运行时设置了错误记录器,它也将传递给引擎。

当启用权重流式传输时,此反序列化路径将减少主机内存使用量。

参数
streamReader一个只读流,TensorRT 将从中反序列化先前序列化的引擎。
返回值
引擎,如果无法反序列化,则为 nullptr。
已弃用
在 TensorRT 10.7 中已弃用。deserializeCudaEngine 已取代它,后者采用 IStreamReaderV2 而不是 IStreamReader

◆ deserializeCudaEngine() [2/3]

ICudaEngine * nvinfer1::IRuntime::deserializeCudaEngine ( IStreamReaderV2 streamReader)
inline

从流反序列化引擎。 IStreamReaderV2 预期支持读取到主机和设备指针。

如果为运行时设置了错误记录器,它也将传递给引擎。

当与 GDS(GPU Direct Storage)一起应用或启用权重流式传输时,此反序列化路径将减少引擎加载时间。

参数
streamReader一个只读流,TensorRT 将从中反序列化先前序列化的引擎。
streamCUDA 流,用于执行异步 I/O。
返回值
引擎,如果无法反序列化,则为 nullptr。指针可能在函数返回后不会立即有效。

◆ deserializeCudaEngine() [3/3]

ICudaEngine * nvinfer1::IRuntime::deserializeCudaEngine ( void const *  blob,
std::size_t  size 
)
inlinenoexcept

从主机内存反序列化引擎。

如果为运行时设置了错误记录器,它也将传递给引擎。

参数
blob保存序列化引擎的内存。
size内存大小。
返回值
引擎,如果无法反序列化,则为 nullptr。

◆ getDLACore()

int32_t nvinfer1::IRuntime::getDLACore ( ) const
inlinenoexcept

获取引擎在其上执行的 DLA 核心。

返回值
分配的 DLA 核心或 -1(如果 DLA 不存在或未设置)。

◆ getEngineHostCodeAllowed()

bool nvinfer1::IRuntime::getEngineHostCodeAllowed ( ) const
inlinenoexcept

获取运行时是否允许反序列化带有主机可执行代码的引擎。

返回值
运行时是否允许反序列化带有主机可执行代码的引擎。

◆ getErrorRecorder()

IErrorRecorder * nvinfer1::IRuntime::getErrorRecorder ( ) const
inlinenoexcept

获取分配给此接口的 ErrorRecorder。

检索给定类别的已分配错误记录器对象。如果未设置错误处理程序,则将返回 nullptr。

返回值
指向已注册的 IErrorRecorder 对象的指针。
另请参阅
setErrorRecorder()

◆ getLogger()

ILogger * nvinfer1::IRuntime::getLogger ( ) const
inlinenoexcept

获取创建运行时所用的记录器

返回值
记录器

◆ getMaxThreads()

int32_t nvinfer1::IRuntime::getMaxThreads ( ) const
inlinenoexcept

获取运行时可以使用的最大线程数。

检索运行时可以使用的最大线程数。

返回值
运行时可以使用的最大线程数。
另请参阅
setMaxThreads()

◆ getNbDLACores()

int32_t nvinfer1::IRuntime::getNbDLACores ( ) const
inlinenoexcept

返回可访问的 DLA 硬件核心数量,如果 DLA 不可用则返回 0。

◆ getPluginRegistry()

IPluginRegistry & nvinfer1::IRuntime::getPluginRegistry ( )
inlinenoexcept

获取运行时可以使用的本地插件注册表。

返回值
运行时可以使用的本地插件注册表。

◆ getTempfileControlFlags()

TempfileControlFlags nvinfer1::IRuntime::getTempfileControlFlags ( ) const
inlinenoexcept

获取此运行时的临时文件控制标志。

返回值
当前设置的标志。
另请参阅
TempfileControlFlag, TempfileControlFlags, setTempfileControlFlags()

◆ getTemporaryDirectory()

char const * nvinfer1::IRuntime::getTemporaryDirectory ( ) const
inlinenoexcept

获取此运行时将用于临时文件的目录。

返回值
正在使用的临时目录的路径,如果未指定路径,则为 nullptr。
另请参阅
setTemporaryDirectory()

◆ loadRuntime()

IRuntime * nvinfer1::IRuntime::loadRuntime ( char const *  path)
inlinenoexcept

从文件加载 IRuntime

此方法从共享库文件加载运行时库。然后,可以使用运行时来执行使用 BuilderFlag::kVERSION_COMPATIBLEBuilderFlag::kEXCLUDE_LEAN_RUNTIME 均设置且使用与加载的运行时库相同版本的 TensorRT 构建的计划文件。

参数
path运行时精简库的路径。
返回值
运行时库,如果无法加载,则为 nullptr
警告
路径字符串必须以 null 结尾,并且最多为 4096 字节(包括终止符)。

◆ setDLACore()

void nvinfer1::IRuntime::setDLACore ( int32_t  dlaCore)
inlinenoexcept

设置网络使用的 DLA 核心。默认为 -1。

参数
dlaCore在其上执行引擎的 DLA 核心,范围为 [0,getNbDlaCores())。

如果多个 DLA 核心可用,则此函数用于通过索引指定要使用的 DLA 核心。

警告
如果 getNbDLACores() 返回 0,则此函数不执行任何操作。
另请参阅
getDLACore()

◆ setEngineHostCodeAllowed()

void nvinfer1::IRuntime::setEngineHostCodeAllowed ( bool  allowed)
inlinenoexcept

设置运行时是否允许反序列化带有主机可执行代码的引擎。

参数
allowed运行时是否允许反序列化带有主机可执行代码的引擎。

默认值为 false。

◆ setErrorRecorder()

void nvinfer1::IRuntime::setErrorRecorder ( IErrorRecorder recorder)
inlinenoexcept

为此接口设置 ErrorRecorder。

将 ErrorRecorder 分配给此接口。ErrorRecorder 将跟踪执行期间的所有错误。此函数将至少调用一次已注册的 ErrorRecorder 的 incRefCount。将记录器设置为 nullptr 将取消注册接口的记录器,如果已注册记录器,则会导致调用 decRefCount。

如果未设置错误记录器,则消息将发送到全局日志流。

参数
recorder要向此接口注册的错误记录器。
另请参阅
getErrorRecorder()

◆ setGpuAllocator()

void nvinfer1::IRuntime::setGpuAllocator ( IGpuAllocator allocator)
inlinenoexcept

设置 GPU 分配器。

参数
allocator设置运行时要使用的 GPU 分配器。所有获取的 GPU 内存都将使用此分配器。如果传递 NULL,将使用默认分配器。

默认值:使用 cudaMalloc/cudaFree。

如果传递 nullptr,将使用默认分配器。

◆ setMaxThreads()

bool nvinfer1::IRuntime::setMaxThreads ( int32_t  maxThreads)
inlinenoexcept

设置最大线程数。

参数
maxThreads运行时可以使用的最大线程数。
返回值
如果成功,则为 True,否则为 false。

默认值为 1,包括当前线程。大于 1 的值允许 TensorRT 使用多线程算法。小于 1 的值会触发 kINVALID_ARGUMENT 错误。

◆ setTempfileControlFlags()

void nvinfer1::IRuntime::setTempfileControlFlags ( TempfileControlFlags  flags)
inlinenoexcept

为此运行时设置临时文件控制标志。

参数
flags要设置的标志。

默认值是设置所有标志,即

(1U << static_cast<uint32_t>(kALLOW_IN_MEMORY_FILES)) | (1U << static_cast<uint32_t>(kALLOW_TEMPORARY_FILES))

另请参阅
TempfileControlFlag, TempfileControlFlags, getTempfileControlFlags()

◆ setTemporaryDirectory()

void nvinfer1::IRuntime::setTemporaryDirectory ( char const *  path)
inlinenoexcept

设置此运行时将用于临时文件的目录。

在某些平台上,TensorRT 运行时可能需要创建和使用具有读/写/执行权限的临时文件来实现运行时功能。

参数
path要使用的临时目录的路径,或 nullptr。

如果 path 为 nullptr,则 TensorRT 将使用特定于平台的启发式方法来选择默认临时目录(如果需要)

  • 在 UNIX/Linux 平台上,TensorRT 将首先尝试 TMPDIR 环境变量,然后回退到 /tmp
  • 在 Windows 上,TensorRT 将尝试 TEMP 环境变量。

有关更多信息,请参阅 TensorRT 开发者指南。

默认值为 nullptr。

警告
如果 path 不为 nullptr,则它必须是一个非空字符串,表示主机操作系统期望格式的相对或绝对路径。
字符串路径必须以 null 结尾,并且最多为 4096 字节(包括终止符)。请注意,操作系统可能具有更严格的路径长度要求。
使用 TensorRT 的进程必须对临时目录具有 rwx 权限,并且应将目录配置为禁止其他用户修改创建的文件(例如,在 Linux 上,如果目录与其他用户共享,则必须设置粘滞位)。
另请参阅
getTemporaryDirectory()

成员数据文档

◆ mImpl

apiv::VRuntime* nvinfer1::IRuntime::mImpl
protected

此类文档从以下文件生成:

  版权所有 © 2024 NVIDIA Corporation
  隐私政策 | 管理我的隐私 | 请勿出售或分享我的数据 | 服务条款 | 辅助功能 | 公司政策 | 产品安全 | 联系方式