Difference between revisions of "GPU: NVML"
Jump to navigation
Jump to search
(Created page with "==Example NVML C program== <syntaxhighlight> #include <stdio.h> #include "nvml.h" int main() { nvmlReturn_t result; unsigned int device_count, i; char version[80...") |
|||
| Line 1: | Line 1: | ||
| + | == Installation == | ||
| + | |||
| + | https://developer.nvidia.com/tesla-deployment-kit | ||
| + | |||
| + | ''' Do Not overwrite libraries from Cuda ''' | ||
| + | |||
| + | #Download and Untar | ||
| + | # Add the files from the include / libary folders or copy them to a folder already on the path. | ||
| + | |||
| + | ==Compilation== | ||
| + | |||
| + | <syntaxhighlight> | ||
| + | gcc -o nvml_test nvml_test.c -lnvidia-ml -I | ||
| + | </syntaxhighlight> | ||
| + | |||
==Example NVML C program== | ==Example NVML C program== | ||
| Line 26: | Line 41: | ||
result = nvmlShutdown(); | result = nvmlShutdown(); | ||
} | } | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | |||
| + | == Output == | ||
| + | |||
| + | <syntaxhighlight> | ||
| + | [root@compute022 ~]# ./nvml_test | ||
| + | |||
| + | Driver version: 304.54 | ||
| + | |||
| + | Found 3 devices | ||
| + | |||
| + | Listing devices: | ||
| + | 0. Tesla K20m | ||
| + | 1. Tesla K20m | ||
| + | 2. Tesla K20m | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 13:49, 19 April 2013
Installation
https://developer.nvidia.com/tesla-deployment-kit
Do Not overwrite libraries from Cuda
- Download and Untar
- Add the files from the include / libary folders or copy them to a folder already on the path.
Compilation
gcc -o nvml_test nvml_test.c -lnvidia-ml -IExample NVML C program
#include <stdio.h>
#include "nvml.h"
int main() {
nvmlReturn_t result;
unsigned int device_count, i;
char version[80];
result = nvmlInit();
result = nvmlSystemGetDriverVersion(version,80);
printf("\n Driver version: %s \n\n", version);
result = nvmlDeviceGetCount(&device_count);
printf("Found %d device%s\n\n", device_count,
device_count != 1 ? "s" : "");
printf("Listing devices:\n");
for (i = 0; i < device_count; i++) {
nvmlDevice_t device;
char name[64];
nvmlComputeMode_t compute_mode;
result = nvmlDeviceGetHandleByIndex(i, &device);
result = nvmlDeviceGetName(device, name,
sizeof(name)/sizeof(name[0]));
printf("%d. %s \n", i, name);
}
result = nvmlShutdown();
}
Output
[root@compute022 ~]# ./nvml_test
Driver version: 304.54
Found 3 devices
Listing devices:
0. Tesla K20m
1. Tesla K20m
2. Tesla K20m