Commit 55a1340 1 parent 816b4de commit 55a1340 Copy full SHA for 55a1340
File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,11 @@ void GPU_fdinfo::find_intel_hwmon() {
113
113
device += pci_dev;
114
114
device += " /hwmon" ;
115
115
116
+ if (!fs::exists (device)) {
117
+ SPDLOG_DEBUG (" Intel hwmon directory {} doesn't exist." , device);
118
+ return ;
119
+ }
120
+
116
121
auto dir_iterator = fs::directory_iterator (device);
117
122
auto hwmon = dir_iterator->path ().string ();
118
123
@@ -123,7 +128,13 @@ void GPU_fdinfo::find_intel_hwmon() {
123
128
124
129
hwmon += " /energy1_input" ;
125
130
131
+ if (!fs::exists (hwmon)) {
132
+ SPDLOG_DEBUG (" Intel hwmon: file {} doesn't exist." , hwmon);
133
+ return ;
134
+ }
135
+
126
136
SPDLOG_DEBUG (" Intel hwmon found: hwmon = {}" , hwmon);
137
+
127
138
energy_stream.open (hwmon);
128
139
129
140
if (!energy_stream.good ())
@@ -138,7 +149,12 @@ float GPU_fdinfo::get_power_usage() {
138
149
uint64_t energy_input;
139
150
140
151
energy_stream.seekg (0 );
152
+
141
153
std::getline (energy_stream, energy_input_str);
154
+
155
+ if (energy_input_str.empty ())
156
+ return 0 .f ;
157
+
142
158
energy_input = std::stoull (energy_input_str);
143
159
144
160
return energy_input / 1'000'000 ;
You can’t perform that action at this time.
0 commit comments