Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rocminfo when run within docker environments. #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions rocminfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include <unistd.h>
#include <pwd.h>

#include <fstream>
#include <vector>
#include <string>
#include <sstream>
Expand Down Expand Up @@ -1035,14 +1036,31 @@ 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) {
std::ifstream amdgpu_initstate( "/sys/module/amdgpu/initstate" );
if (amdgpu_initstate){
std::stringstream buffer;
buffer << amdgpu_initstate.rdbuf();
amdgpu_initstate.close();

std::string line;
bool is_live = false;
while (std::getline(buffer, line)){
if (line.find( "live" ) != std::string::npos){
is_live = true;
break;
}
}
if (is_live){
printf("%sROCk module is loaded%s\n", COL_WHT, COL_RESET);
} else {
printf("%sROCk module is NOT live, possibly no GPU devices%s\n",
COL_RED, COL_RESET);
return -1;
}
} else {
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);
}

// Check if user belongs to the group for /dev/kfd (e.g. "video" or
Expand Down