Created
September 4, 2014 11:25
-
-
Save moznion/6baa6995128a0ce5a18a to your computer and use it in GitHub Desktop.
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
#include <stdio.h> | |
int main(int argc, char** argv) { | |
cudaError_t err; | |
char *device_name = "Quadro K6000"; | |
int device_count; | |
err = cudaGetDeviceCount(&device_count); | |
if (err) { | |
fprintf(stderr, "Cannnot get device count\n"); | |
return err; | |
} | |
int *device_ids; | |
device_ids = (int *)malloc(sizeof(int) * device_count); | |
cudaDeviceProp device_prop; | |
int hits = 0; | |
for (int id = 0; id < device_count; id++) { | |
err = cudaGetDeviceProperties(&device_prop, id); | |
if (strcmp(device_prop.name, device_name) == 0) { | |
device_ids[hits] = id; | |
hits++; | |
} | |
} | |
for (int i = 0; i < hits; i++) { | |
printf("%d\n", device_ids[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment