diff --git a/src/program/generate.cpp b/src/program/generate.cpp index db6e97d0d7..68e8f89b53 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -3872,8 +3872,24 @@ int main(int argc, char** argv) { // #468 #461: which HIP runtime was loaded - the bundled one beside the exe, or an AMD driver's System32 copy if (HMODULE h = GetModuleHandleA("amdhip64_7.dll")) { char path[MAX_PATH] = {}; - if (GetModuleFileNameA(h, path, MAX_PATH) > 0) + if (GetModuleFileNameA(h, path, MAX_PATH) > 0) { std::fprintf(stderr, "strata generate: HIP runtime %s\n", path); + // #1261: the bundled runtime sits beside the exe, but Windows bound the import to another copy (the AMD + // driver's, in System32, was seen with a different build): kernels of this engine can then fail + // (hipErrorInvalidDeviceFunction in the prompt GEMMs). Said, not changed - the import is bound before main. + char exe[MAX_PATH] = {}; + if (GetModuleFileNameA(nullptr, exe, MAX_PATH) > 0) { + std::string beside(exe); + const size_t cut = beside.find_last_of("\\/"); + beside = (cut == std::string::npos ? std::string() : beside.substr(0, cut + 1)) + "amdhip64_7.dll"; + if (GetFileAttributesA(beside.c_str()) != INVALID_FILE_ATTRIBUTES && + _stricmp(beside.c_str(), path) != 0) + std::fprintf(stderr, "strata generate: WARNING: the HIP runtime in use is not the bundled one beside " + "the engine (%s): if prompts fail with hipErrorInvalidDeviceFunction, tell the " + "maintainers with this log (#1261)\n", + beside.c_str()); + } + } } #endif #else