Skip to content

Instantly share code, notes, and snippets.

@xiphen-jp
Last active December 19, 2017 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiphen-jp/e0dea8822e842eb571c8ba3e2ca6a79f to your computer and use it in GitHub Desktop.
Save xiphen-jp/e0dea8822e842eb571c8ba3e2ca6a79f to your computer and use it in GitHub Desktop.
C#でnVIDIA製GPUのGPU使用率を取得する(nvidia-smiコマンド使用)
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = @"C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi.exe",
Arguments = "--query-gpu=utilization.gpu --format=csv,noheader,nounits",
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true
};
Process p = Process.Start(psi);
string gpu_usage = p.StandardOutput.ReadToEnd().TrimEnd();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment