How to get number of gpu cards I have from a command line?

8,223

Solution 1

This command gets the number of GPUs directly, assuming you have nvidia-smi.

nvidia-smi --query-gpu=name --format=csv,noheader | wc -l

It prints the names of the GPUs, one per line, and then counts the number of lines.

Solution 2

nvidia-smi --list-gpus | wc -l

This will first list the GPUS one per line and then counts the lines of output which is the number of GPUS

Solution 3

You can use sudo lshw -C display to list your video card(s), then google each one to see how many cores it has.

Share:
8,223

Related videos on Youtube

agangwal
Author by

agangwal

Updated on September 18, 2022

Comments

  • agangwal
    agangwal over 1 year

    I am trying to make a CUDA tool and I have to make it scalable. I need to give number of GPU a system have as an argument to my tool. Please tell me if there is any command for getting number of GPUs directly??

  • agangwal
    agangwal almost 7 years
    Since I want to make a tool, I don't think using sudo command will be safe. Is there is any other way which do not require any permission since my tool will be using the common server here.
  • agangwal
    agangwal almost 7 years
    And I don't want to see cores. I only want to get number of GPU cards
  • Tomasz Gandor
    Tomasz Gandor over 2 years
    Easier to type from memory: nvidia-smi -L | wc -l