'How can I determine the number of CUDA devices on my system (without compiling anything)?
I want to determine the number of CUDA devices on my system. Of course I can do this using the CUDA runtime API in a C program I compile, but - what's the simplest/most straightforward way to do this without compiling any code?
Assumptions:
- CUDA >= 7.0 is installed
- up-to-date nVIDIA drivers are installed
- You may provide different solutions for UNIX-like and non-UNIX-like OSes.
Solution 1:[1]
If you're on Linux or a UNIX-like system, this works:
nvidia-smi -L | wc -l
Explanation:
nvidia-smiis nVIDIA's "system management interface" utility. You can use it to determine all sorts of information about your GPUs and also to carry out some maintenance actions.nvidia-smi -Llists the GPUs available on the system.wcis the UNIX word/line/character counting utilitywc -lcounts the number of lines on the standard input
... but is kind of brittle. I wish I had something a bit more robust.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
