You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-util/rocminfo/files/rocminfo-4.3.0-detect-built...

26 lines
936 B

/sys/module/amdgpu instead of lsmod for builtin amdgpu kernel module
https://github.com/RadeonOpenCompute/rocminfo/pull/43
https://github.com/RadeonOpenCompute/rocminfo/issues/42
--- a/rocminfo.cc
+++ b/rocminfo.cc
@@ -1035,14 +1035,15 @@ AcquireAndDisplayAgentInfo(hsa_agent_t agent, void* data) {
int CheckInitialState(void) {
// Check kernel module for ROCk is loaded
- FILE *fd = popen("lsmod | grep amdgpu", "r");
- char buf[16];
- if (fread (buf, 1, sizeof (buf), fd) <= 0) {
+ int module_dir;
+ module_dir = open("/sys/module/amdgpu", O_DIRECTORY);
+ if (module_dir < 0) {
printf("%sROCk module is NOT loaded, possibly no GPU devices%s\n",
COL_RED, COL_RESET);
return -1;
} else {
printf("%sROCk module is loaded%s\n", COL_WHT, COL_RESET);
+ close(module_dir);
}
// Check if user belongs to the group for /dev/kfd (e.g. "video" or