"docs/basic_usage/sampling_params.md" did not exist on "8c3b420eec03ea94e4ccce04681891558ca892ca"
Unverified Commit 03781c74 authored by Qianli Scott Zhu's avatar Qianli Scott Zhu Committed by GitHub
Browse files

Update the importing logic for cpuinfo and psutil. (#3781)

* Update the importing logic for cpuinfo and psutil.

Those two libs are usually not installed by default, and we should
not force people to install them if they just want to run resnet.

* Add pylint warning suppression.
parent 092c9662
...@@ -28,13 +28,6 @@ import multiprocessing ...@@ -28,13 +28,6 @@ import multiprocessing
import numbers import numbers
import os import os
# pylint: disable=g-bad-import-order
# Note: cpuinfo and psutil are not installed in the TensorFlow OSS tree.
# They are installable via pip.
import cpuinfo
import psutil
# pylint: enable=g-bad-import-order
import tensorflow as tf import tensorflow as tf
from tensorflow.python.client import device_lib from tensorflow.python.client import device_lib
...@@ -149,6 +142,10 @@ def _collect_cpu_info(run_info): ...@@ -149,6 +142,10 @@ def _collect_cpu_info(run_info):
cpu_info["num_cores"] = multiprocessing.cpu_count() cpu_info["num_cores"] = multiprocessing.cpu_count()
# Note: cpuinfo is not installed in the TensorFlow OSS tree.
# It is installable via pip.
import cpuinfo # pylint: disable=g-import-not-at-top
info = cpuinfo.get_cpu_info() info = cpuinfo.get_cpu_info()
cpu_info["cpu_info"] = info["brand"] cpu_info["cpu_info"] = info["brand"]
cpu_info["mhz_per_cpu"] = info["hz_advertised_raw"][0] / 1.0e6 cpu_info["mhz_per_cpu"] = info["hz_advertised_raw"][0] / 1.0e6
...@@ -175,6 +172,9 @@ def _collect_gpu_info(run_info): ...@@ -175,6 +172,9 @@ def _collect_gpu_info(run_info):
def _collect_memory_info(run_info): def _collect_memory_info(run_info):
# Note: psutil is not installed in the TensorFlow OSS tree.
# It is installable via pip.
import psutil # pylint: disable=g-import-not-at-top
vmem = psutil.virtual_memory() vmem = psutil.virtual_memory()
run_info["memory_total"] = vmem.total run_info["memory_total"] = vmem.total
run_info["memory_available"] = vmem.available run_info["memory_available"] = vmem.available
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment