1.8 KiB
| title | description | parent | grand_parent | has_children | nav_order |
|---|---|---|---|---|---|
| Configure CUDA for C# | Configure CUDA and cuDNN for ONNX Runtime with C# on Windows 11 | Inference with C# | Tutorials | false | 1 |
Configure CUDA and cuDNN for ONNX Runtime with C# on Windows 11
{: .no_toc }
Prerequisites
- Windows 11
- Visual Studio 2019 or 2022
Steps to Configure CUDA and cuDNN for ONNX Runtime with C# on Windows 11
-
Install CUDA toolkit based on the supported version for the ONNX Runtime Version. See this link for compatible versions: NVIDIA - CUDA - ONNX Runtime
-
Install Driver from NVIDIA based on your GPU. Find the driver download here: Official Drivers - NVIDIA
-
Install the cuDNN version based on the supported version for the ONNX Runtime Version. See this link for compatible versions: NVIDIA - CUDA - ONNX Runtime then download the cuDNN version from here: cuDNN Archive - NVIDIA Developer
-
Follow the steps here from Installation Guide - NVIDIA Deep Learning cuDNN Documentation. NOTE: Skip step 5 in section 2.3 on updating Visual Studio settings, this is only for C++ projects.
-
Restart your computer.
-
Now you can enable GPU in the C# ONNX Runtime API with the following code:
var session = new InferenceSession(modelPath, SessionOptions.MakeSessionOptionWithCudaProvider(0));