Skip to content

Commit

Permalink
nvml: add missing nvml available check
Browse files Browse the repository at this point in the history
  • Loading branch information
Etaash-mathamsetty authored and flightlessmango committed Nov 17, 2024
1 parent b12b698 commit e8a51ae
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/nvidia.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ class NVIDIA {
#ifdef HAVE_NVML
std::vector<int> pids() {
std::vector<int> vec;
auto& nvml = get_libnvml_loader();
unsigned int infoCount = 0;
nvmlProcessInfo_t *process_info = new nvmlProcessInfo_t[infoCount];
nvml.nvmlDeviceGetGraphicsRunningProcesses(device, &infoCount, process_info);
process_info = new nvmlProcessInfo_t[infoCount];
nvml.nvmlDeviceGetGraphicsRunningProcesses(device, &infoCount, process_info);
for (size_t i = 0; i < infoCount; i++)
vec.push_back(static_cast<int> (process_info[i].pid));
if(nvml_available) {
auto& nvml = get_libnvml_loader();
unsigned int infoCount = 0;
nvmlProcessInfo_t *process_info = new nvmlProcessInfo_t[infoCount];
nvml.nvmlDeviceGetGraphicsRunningProcesses(device, &infoCount, process_info);
process_info = new nvmlProcessInfo_t[infoCount];
nvml.nvmlDeviceGetGraphicsRunningProcesses(device, &infoCount, process_info);
for (size_t i = 0; i < infoCount; i++)
vec.push_back(static_cast<int> (process_info[i].pid));
}

return vec;
};
Expand Down

0 comments on commit e8a51ae

Please sign in to comment.