Created
February 26, 2024 02:26
-
-
Save dangra/ea827d7de7bddf0523fdddcff197fda5 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 <assert.h> | |
#include <dlfcn.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main() { | |
void *handle; | |
int (*nvmlInit)(void); | |
char *error; | |
handle = dlopen("libnvidia-ml.so", RTLD_LAZY); | |
if (!handle) { | |
fprintf(stderr, "%s\n", dlerror()); | |
exit(EXIT_FAILURE); | |
} | |
dlerror(); | |
nvmlInit = (int (*)(void)) dlsym(handle, "nvmlInit"); | |
error = dlerror(); | |
if (error != NULL) { | |
fprintf(stderr, "%s\n", error); | |
exit(EXIT_FAILURE); | |
} | |
assert(nvmlInit() == 0); | |
dlclose(handle); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment