admin 管理员组

文章数量: 887021

ONNXRuntime下载

        下载地址:Releases · microsoft/onnxruntime (github)

        在下载地址找到对应版本,历史版本在Assets点开折叠后可以看到,可下载内容如下,如果需要支持GPU需要下载对应版本。

         也可以通过指定版本的地址直接定位到想要的版本,例如1.8.0

https://github/microsoft/onnxruntime/releases/tag/v1.8.0

GPU环境准备

        因为onnxruntime官方不支持windows编译(编译需要的Nvidia NCCL不支持widows),所以使用release包时需要使用比较严格对应的CUDA和cudnn,参考安装说明。但实际测试发现也并非严格对应,比如1.10.0可以用1.8.0的环境,但不能用1.6.0的环境。

Please reference table below for official GPU packages dependencies for the ONNX Runtime inferencing package. Note that ONNX Runtime Training is aligned with PyTorch CUDA versions; refer to the Training tab on https://onnxruntime.ai/ for supported versions.

Note: Because of CUDA Minor Version Compatibility, Onnx Runtime built with CUDA 11.4 should be compatible with any CUDA 11.x version. Please reference Nvidia CUDA Minor Version Compatibility.

ONNX RuntimeCUDAcuDNNNotes
1.1011.48.2.4 (Linux)
8.2.2.26 (Windows)
libcudart 11.4.43
libcufft 10.5.2.100
libcurand 10.2.5.120
libcublasLt 11.6.1.51
libcublas 11.6.1.51
libcudnn 8.2.4
1.911.48.2.4 (Linux)
8.2.2.26 (Windows)
libcudart 11.4.43
libcufft 10.5.2.100
libcurand 10.2.5.120
libcublasLt 11.6.1.51
libcublas 11.6.1.51
libcudnn 8.2.4
1.811.0.38.0.4 (Linux)
8.0.2.39 (Windows)
libcudart 11.0.221
libcufft 10.2.1.245
libcurand 10.2.1.245
libcublasLt 11.2.0.252
libcublas 11.2.0.252
libcudnn 8.0.4
1.711.0.38.0.4 (Linux)
8.0.2.39 (Windows)
libcudart 11.0.221
libcufft 10.2.1.245
libcurand 10.2.1.245
libcublasLt 11.2.0.252
libcublas 11.2.0.252
libcudnn 8.0.4
1.5-1.610.28.0.3CUDA 11 can be built from source
1.2-1.410.17.6.5Requires cublas10-10.2.1.243; cublas 10.1.x will not work
1.0-1.110.07.6.4CUDA versions from 9.1 up to 10.1, and cuDNN versions from 7.1 up to 7.4 should also work with Visual Studio 2017

For older versions, please reference the readme and build pages on the release branch.

        以CUDA11.0.3和cudnn8.0.2.39下载环境安装,CUDA只安装runtime和development,cudnn解压放到cuda安装目录即可。

VS开发配置

工程属性

C/C++ -> Additional Include Directories添加:

D:\libs\onnxruntime-win-x64-gpu-1.10.0\include

Linker -> Additional Library Directories添加:

D:\libs\onnxruntime-win-x64-gpu-1.10.0\lib

Linker -> Input -> Additional

onnxruntime.lib

使用时

#include <onnxruntime_cxx_api.h>

如果cuda/cudnn环境与onnxruntime不适配,在session.run()时会报错,例如:

Unhandled exception at 0x00007FF84C9D313C (cudnn64_8.dll) in onnx.exe: Fatal program exit requested.

本文标签: 环境 Onnxruntime GPU