【ONNXRuntime】Win10 GPU环境 ONNXRuntime下载与VS开发配置

ONNXRuntime下载

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

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

【ONNXRuntime】Win10 GPU环境 ONNXRuntime下载与VS开发配置_第1张图片

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

https://github.com/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 Runtime CUDA cuDNN Notes
1.10 11.4 8.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.9 11.4 8.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.8 11.0.3 8.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.7 11.0.3 8.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.6 10.2 8.0.3 CUDA 11 can be built from source
1.2-1.4 10.1 7.6.5 Requires cublas10-10.2.1.243; cublas 10.1.x will not work
1.0-1.1 10.0 7.6.4 CUDA 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 

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

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

你可能感兴趣的:(c/c++,AI/ML/DL,onnxruntime)