Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
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
23 changes: 22 additions & 1 deletion 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 @@ -1040,7 +1041,27 @@ int CheckInitialState(void) {
if (fread (buf, 1, sizeof (buf), fd) <= 0) {
printf("%sROCk module is NOT loaded, possibly no GPU devices%s\n",
COL_RED, COL_RESET);
return -1;
// Check if rocminfo is executed within a docker environment (where this is OK)
std::ifstream cgroups( "/proc/self/cgroup" );
if (cgroups) {
std::stringstream buffer;
buffer << cgroups.rdbuf();
cgroups.close();

std::string line;
bool docker_env = false;
while ( std::getline(buffer, line) ) {
if ( line.find( "docker" )) {
docker_env = true;
printf("Docker environment detected - missing ROCk module expected.\n");
break;
}
}
if ( !docker_env ) return -1;
} else {
// this is certainly weird - error
return -1;
}
} else {
printf("%sROCk module is loaded%s\n", COL_WHT, COL_RESET);
}
Expand Down