alanxinn.TensorRtOnnxBuilder
0.1.3
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Framework 4.7.2
This package targets .NET Framework 4.7.2. The package is compatible with this framework or higher.
dotnet add package alanxinn.TensorRtOnnxBuilder --version 0.1.3
NuGet\Install-Package alanxinn.TensorRtOnnxBuilder -Version 0.1.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="alanxinn.TensorRtOnnxBuilder" Version="0.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="alanxinn.TensorRtOnnxBuilder" Version="0.1.3" />
<PackageReference Include="alanxinn.TensorRtOnnxBuilder" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add alanxinn.TensorRtOnnxBuilder --version 0.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: alanxinn.TensorRtOnnxBuilder, 0.1.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package alanxinn.TensorRtOnnxBuilder@0.1.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=alanxinn.TensorRtOnnxBuilder&version=0.1.3
#tool nuget:?package=alanxinn.TensorRtOnnxBuilder&version=0.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
alanxinn.TensorRtOnnxBuilder
C# 调用 TensorRT native builder,将 ONNX 转为 serialized engine。
不启动 trtexec.exe。
安装
dotnet add package alanxinn.TensorRtOnnxBuilder --version 0.1.3
要求 Windows x64、NVIDIA 驱动和匹配的 TensorRT/CUDA。 NuGet 仅包含 C# 程序集和 builder DLL。
C# 示例
using alanxinn.TensorRt;
var result = TensorRtOnnxBuilder.Build(
"model.onnx",
"model.engine",
new TensorRtBuildOptions
{
Precision = TensorRtPrecision.Fp32,
WorkspaceMiB = 4096,
EnableTf32 = true
});
动态输入
var profile = new TensorRtOptimizationProfile
{
MinShapes = new() { ["images"] = new TensorRtShape(1, 3, 320, 320) },
OptShapes = new() { ["images"] = new TensorRtShape(1, 3, 640, 640) },
MaxShapes = new() { ["images"] = new TensorRtShape(1, 3, 1280, 1280) }
};
动态输入的每个输入都必须同时出现在 min/opt/max 中。 INT8 适用于包含 Q/DQ 节点的 ONNX。
TensorRT 8.6 解析原始 YOLO26 ONNX 可能在 ReduceMax/TopK 失败;
请先使用修正版 ONNX,或升级 TensorRT。
Runtime
缺少 runtime 时默认下载并缓存到:
%LOCALAPPDATA%\alanxinn\TensorRtOnnxBuilder\0.1.3\win-x64
可配置:
TensorRtRuntime.DownloadUrl = "...";
TensorRtRuntime.CacheDirectory = @"D:\TensorRT\runtime";
TensorRtRuntime.ExpectedSha256 = "...";
TensorRtRuntime.DisableAutoDownload = true;
构建
cmake --preset ninja-msvc-release
cmake --build --preset build-ninja-msvc-release
dotnet pack .\csharp\alanxinn.TensorRtOnnxBuilder\alanxinn.TensorRtOnnxBuilder.csproj -c Release
详细转换命令见同目录 Demo README。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.7.2
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Managed ONNX to TensorRT engine builder. Large TensorRT/CUDA runtime DLLs are downloaded from a versioned GitHub Release on first use.