Skip to content

Instantly share code, notes, and snippets.

@rsnemmen
Created April 3, 2018 16:24
Show Gist options
  • Select an option

  • Save rsnemmen/5880e1de6c9394904797e5c523ca142a to your computer and use it in GitHub Desktop.

Select an option

Save rsnemmen/5880e1de6c9394904797e5c523ca142a to your computer and use it in GitHub Desktop.
Gets useful information about your NVIDIA GPU with CUDA
/*
Queries NVIDIA GPU for useful information.
Please compile with nvcc.
*/
#include <stdio.h>
int main() {
int nDevices;
cudaGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++) {
cudaDeviceProp prop;
size_t free, total;
cudaGetDeviceProperties(&prop, i);
cudaMemGetInfo(&free, &total);
printf("Device Number: %d\n", i);
printf(" Device name: %s\n", prop.name);
printf(" Memory Clock Rate (KHz): %d\n", prop.memoryClockRate);
printf(" Memory Bus Width (bits): %d\n",
prop.memoryBusWidth);
printf(" Peak Memory Bandwidth (GB/s): %f\n",
2.0*prop.memoryClockRate*(prop.memoryBusWidth/8)/1.0e6);
printf(" Total global memory (GB): %f\n",
(float)prop.totalGlobalMem/1000000000.);
printf(" Free memory (GB): %f\n", (float)free/1000000000);
printf(" Max amount of shared memory available to a thread block (bytes): %zd\n",
prop.sharedMemPerBlock);
printf(" Max. threads per block: %d\n",
prop.maxThreadsPerBlock);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment