Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Configure CUDA and cuDNN for GPU with ONNX Runtime and C# on Windows 11


  • Windows 11
  • Visual Studio 2019 or 2022

Steps to Configure CUDA and cuDNN for ONNX Runtime with C# on Windows 11

See this table for supported versions:

ONNX Runtime Version CUDA Toolkit Version cuDNN Version
1.13 - 1.14 11.6
1.9 - 1.12 11.4

NOTE: Full table can be found here

  • Follow section 2. Installing cuDNN on Windows. NOTE: Skip step 5 in section 2.3 on updating Visual Studio settings, this is only for C++ projects.

  • Restart your computer and verify the installation by running the following command or in python with PyTorch:

nvcc --version
import torch
  • Now you can enable GPU in the C# ONNX Runtime API with the following code:
var session = new InferenceSession(modelPath, SessionOptions.MakeSessionOptionWithCudaProvider(0));

Checkout more C# ONNX Runtime resources