From 0495eb207755133e67dfea0752be4df80d7fd51e Mon Sep 17 00:00:00 2001 From: Chris Freehill Date: Mon, 27 Apr 2020 21:14:06 -0500 Subject: [PATCH] Handle rsmi app running on machine with no AMD gpus This fixes a seg fault that would happen in release builds when there are no KFD nodes on a system, which occurs when there are not AMD gpus present in the system. This use case occurs for higher application code that is meant to be gpu agnostic. Change-Id: If374930bc2e62f9898f337349cde3ebb16091ff0 [ROCm/amdsmi commit: 806f665a85d51b60ab265e861ac6c2138a1eb82b] --- projects/amdsmi/src/rocm_smi_kfd.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/amdsmi/src/rocm_smi_kfd.cc b/projects/amdsmi/src/rocm_smi_kfd.cc index 2292d3ad82..5d9a13d4f3 100755 --- a/projects/amdsmi/src/rocm_smi_kfd.cc +++ b/projects/amdsmi/src/rocm_smi_kfd.cc @@ -429,7 +429,9 @@ int DiscoverKFDNodes(std::map> *nodes) { uint32_t node_indx; auto kfd_node_dir = opendir(kKFDNodesPathRoot); - assert(kfd_node_dir != nullptr); + if (kfd_node_dir == nullptr) { + return errno; + } auto dentry = readdir(kfd_node_dir); while (dentry != nullptr) {