Skip to content

Commit

Permalink
nvidia: check that logger isn't null before accessing
Browse files Browse the repository at this point in the history
  • Loading branch information
flightlessmango committed Oct 15, 2024
1 parent 024cf21 commit 29898db
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/nvidia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,32 +88,32 @@ void NVIDIA::get_instant_metrics_nvml(struct gpu_metrics *metrics) {
}
metrics->load = nvml_utilization.gpu;

if (params->enabled[OVERLAY_PARAM_ENABLED_gpu_temp] || logger->is_active()) {
if (params->enabled[OVERLAY_PARAM_ENABLED_gpu_temp] || (logger && logger->is_active())) {
unsigned int temp;
nvml.nvmlDeviceGetTemperature(device, NVML_TEMPERATURE_GPU, &temp);
metrics->temp = temp;
}

if (params->enabled[OVERLAY_PARAM_ENABLED_vram] || logger->is_active()) {
if (params->enabled[OVERLAY_PARAM_ENABLED_vram] || (logger && logger->is_active())) {
struct nvmlMemory_st nvml_memory;
nvml.nvmlDeviceGetMemoryInfo(device, &nvml_memory);
metrics->memoryTotal = nvml_memory.total / (1024.f * 1024.f * 1024.f);
metrics->memoryUsed = nvml_memory.used / (1024.f * 1024.f * 1024.f);
}

if (params->enabled[OVERLAY_PARAM_ENABLED_gpu_core_clock] || logger->is_active()) {
if (params->enabled[OVERLAY_PARAM_ENABLED_gpu_core_clock] || (logger && logger->is_active())) {
unsigned int core_clock;
nvml.nvmlDeviceGetClockInfo(device, NVML_CLOCK_GRAPHICS, &core_clock);
metrics->CoreClock = core_clock;
}

if (params->enabled[OVERLAY_PARAM_ENABLED_gpu_mem_clock] || logger->is_active()) {
if (params->enabled[OVERLAY_PARAM_ENABLED_gpu_mem_clock] || (logger && logger->is_active())) {
unsigned int memory_clock;
nvml.nvmlDeviceGetClockInfo(device, NVML_CLOCK_MEM, &memory_clock);
metrics->MemClock = memory_clock;
}

if (params->enabled[OVERLAY_PARAM_ENABLED_gpu_power] || logger->is_active()) {
if (params->enabled[OVERLAY_PARAM_ENABLED_gpu_power] || (logger && logger->is_active())) {
unsigned int power;
nvml.nvmlDeviceGetPowerUsage(device, &power);
metrics->powerUsage = power / 1000;
Expand All @@ -129,7 +129,7 @@ void NVIDIA::get_instant_metrics_nvml(struct gpu_metrics *metrics) {
throttling->indep_throttle_status = nvml_throttle_reasons;
}

if (params->enabled[OVERLAY_PARAM_ENABLED_gpu_fan] || logger->is_active()){
if (params->enabled[OVERLAY_PARAM_ENABLED_gpu_fan] || (logger && logger->is_active())){
unsigned int fan_speed;
nvml.nvmlDeviceGetFanSpeed(device, &fan_speed);
metrics->fan_speed = fan_speed;
Expand Down

0 comments on commit 29898db

Please sign in to comment.