文章预览
点击上方 蓝字 关注我们 微信公众号: OpenCV学堂 关注获取更多计算机视觉与深度学习知识 ONNXRUNTIME介绍 ONNXRUNTIME是微软开源的深度学习跨平台的推理与加速部署框架,支持CNN、VIT、CLIP、GenAI等模型推理与部署。官方的说明如下: 安装与配置 在VS2022中安装非常简单,直接通过IDE安装即可: 命令行安装方式如下: dotnet add package Microsoft.ML.OnnxRuntime --version 1 . 16 . 0 dotnet add package System.Numerics.Tensors --version 0 . 1 . 0 SDK与推理流程 创建推理会话与GPU支持 int gpuDeviceId = 0 ; // The GPU device ID to execute on using var gpuSessionOptoins = SessionOptions.MakeSessionOptionWithCudaProvider(gpuDeviceId); using var session = new InferenceSession( "model.onnx" , gpuSessionOptoins); CPU推理会话 using InferenceSession session = new InferenceSession(modelBPath); 创建输入数据 float [] inputData = { 1 , 2 , 3 , 4
………………………………