Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions cuda_memtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,12 @@ main(int argc, char** argv)
exit(ERR_BAD_STATE);
}

active_update_temperature = 0;

for(i=0;i < num_gpus;i++){
pthread_join(pid[i], NULL);
}

active_update_temperature = 0;

printf("main thread: Program exits\n");

return 0;
Expand Down
13 changes: 12 additions & 1 deletion misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@ void update_temperature(void)
unsigned int deviceCount;
NVML_CHECK(nvmlDeviceGetCount( &deviceCount ));

for( unsigned int devIdx = 0; devIdx < deviceCount; ++devIdx )
unsigned int monitoredCount = (deviceCount > MAX_GPU_NUM) ? MAX_GPU_NUM : deviceCount;
if (deviceCount > MAX_GPU_NUM) {
fprintf(stderr, "WARNING: Found %u GPUs, but MAX_GPU_NUM is %u. Clamping to maximum supported.\n", deviceCount, MAX_GPU_NUM);
}

for( unsigned int devIdx = 0; devIdx < monitoredCount; ++devIdx )
{
nvmlDevice_t devHandle;
NVML_CHECK(nvmlDeviceGetHandleByIndex( devIdx, &devHandle ));

unsigned int devTemperature;
#if (NVML_API_VERSION >= 13)
nvmlTemperature_t temperature = {nvmlTemperature_v1, NVML_TEMPERATURE_GPU};
NVML_CHECK(nvmlDeviceGetTemperatureV( devHandle, &temperature ));
devTemperature = temperature.temperature;
#else
NVML_CHECK(nvmlDeviceGetTemperature( devHandle, NVML_TEMPERATURE_GPU, &devTemperature ));
#endif
gpu_temp[devIdx] = devTemperature;

DEBUG_PRINTF("temperature updated: (gpu %d) %d \n", devIdx, devTemperature);
Expand Down