Created
April 3, 2018 16:24
-
-
Save rsnemmen/5880e1de6c9394904797e5c523ca142a to your computer and use it in GitHub Desktop.
Gets useful information about your NVIDIA GPU with CUDA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 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