@@ -213,15 +213,18 @@ def _collect_cpu_info(run_info):
213
213
214
214
cpu_info ["num_cores" ] = multiprocessing .cpu_count ()
215
215
216
- # Note: cpuinfo is not installed in the TensorFlow OSS tree.
217
- # It is installable via pip.
218
- import cpuinfo # pylint: disable=g-import-not-at-top
216
+ try :
217
+ # Note: cpuinfo is not installed in the TensorFlow OSS tree.
218
+ # It is installable via pip.
219
+ import cpuinfo # pylint: disable=g-import-not-at-top
219
220
220
- info = cpuinfo .get_cpu_info ()
221
- cpu_info ["cpu_info" ] = info ["brand" ]
222
- cpu_info ["mhz_per_cpu" ] = info ["hz_advertised_raw" ][0 ] / 1.0e6
221
+ info = cpuinfo .get_cpu_info ()
222
+ cpu_info ["cpu_info" ] = info ["brand" ]
223
+ cpu_info ["mhz_per_cpu" ] = info ["hz_advertised_raw" ][0 ] / 1.0e6
223
224
224
- run_info ["machine_config" ]["cpu_info" ] = cpu_info
225
+ run_info ["machine_config" ]["cpu_info" ] = cpu_info
226
+ except ImportError :
227
+ tf .logging .warn ("'cpuinfo' not imported. CPU info will not be logged." )
225
228
226
229
227
230
def _collect_gpu_info (run_info ):
@@ -243,12 +246,15 @@ def _collect_gpu_info(run_info):
243
246
244
247
245
248
def _collect_memory_info (run_info ):
246
- # Note: psutil is not installed in the TensorFlow OSS tree.
247
- # It is installable via pip.
248
- import psutil # pylint: disable=g-import-not-at-top
249
- vmem = psutil .virtual_memory ()
250
- run_info ["machine_config" ]["memory_total" ] = vmem .total
251
- run_info ["machine_config" ]["memory_available" ] = vmem .available
249
+ try :
250
+ # Note: psutil is not installed in the TensorFlow OSS tree.
251
+ # It is installable via pip.
252
+ import psutil # pylint: disable=g-import-not-at-top
253
+ vmem = psutil .virtual_memory ()
254
+ run_info ["machine_config" ]["memory_total" ] = vmem .total
255
+ run_info ["machine_config" ]["memory_available" ] = vmem .available
256
+ except ImportError :
257
+ tf .logging .warn ("'psutil' not imported. Memory info will not be logged." )
252
258
253
259
254
260
def _parse_gpu_model (physical_device_desc ):
0 commit comments