Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get card specs programmatically in CUDA

Tags:

cuda

nvidia

specs

I'm just starting out with CUDA. Is there a way of getting the card specs programmatically?

like image 526
cookM Avatar asked Apr 16 '11 19:04

cookM


People also ask

How do I know what CUDA graphics card I have?

You can verify that you have a CUDA-capable GPU through the Display Adapters section in the Windows Device Manager. Here you will find the vendor name and model of your graphics card(s). If you have an NVIDIA card that is listed in http://developer.nvidia.com/cuda-gpus, that GPU is CUDA-capable.

What is SM in CUDA?

GPU Architecture This GPU has 16 streaming multiprocessor (SM), which contains 32 cuda cores each. Every cuda is an execute unit for integer and float numbers.

How do I find CUDA cores in Linux?

If you have the nvidia-settings utilities installed, you can query the number of CUDA cores of your gpus by running nvidia-settings -q CUDACores -t . If that's not working, try nvidia-settings -q :0/CUDACores . :0 is the gpu slot/ID: In this case 0 is refering to the first GPU.


1 Answers

You can use the cudaGetDeviceCount and cudaGetDeviceProperties APIs.

void DisplayHeader()
{
    const int kb = 1024;
    const int mb = kb * kb;
    wcout << "NBody.GPU" << endl << "=========" << endl << endl;

    wcout << "CUDA version:   v" << CUDART_VERSION << endl;    
    wcout << "Thrust version: v" << THRUST_MAJOR_VERSION << "." << THRUST_MINOR_VERSION << endl << endl; 

    int devCount;
    cudaGetDeviceCount(&devCount);
    wcout << "CUDA Devices: " << endl << endl;

    for(int i = 0; i < devCount; ++i)
    {
        cudaDeviceProp props;
        cudaGetDeviceProperties(&props, i);
        wcout << i << ": " << props.name << ": " << props.major << "." << props.minor << endl;
        wcout << "  Global memory:   " << props.totalGlobalMem / mb << "mb" << endl;
        wcout << "  Shared memory:   " << props.sharedMemPerBlock / kb << "kb" << endl;
        wcout << "  Constant memory: " << props.totalConstMem / kb << "kb" << endl;
        wcout << "  Block registers: " << props.regsPerBlock << endl << endl;

        wcout << "  Warp size:         " << props.warpSize << endl;
        wcout << "  Threads per block: " << props.maxThreadsPerBlock << endl;
        wcout << "  Max block dimensions: [ " << props.maxThreadsDim[0] << ", " << props.maxThreadsDim[1]  << ", " << props.maxThreadsDim[2] << " ]" << endl;
        wcout << "  Max grid dimensions:  [ " << props.maxGridSize[0] << ", " << props.maxGridSize[1]  << ", " << props.maxGridSize[2] << " ]" << endl;
        wcout << endl;
    }
}

If you have installed the GPU Computing SDK, have a look at the deviceQuery project which can be found in the %NVSDKCOMPUTE_ROOT%\C\src directory. It shows how to query for all the device properties using CUDA Runtime API calls.

The CUDA Programming guide has more detail in section 3.2.3.

like image 139
Ade Miller Avatar answered Oct 19 '22 01:10

Ade Miller