Skip to content

Commit

Permalink
Make sure diagnostic variables aren't set when benchmarking (#238)
Browse files Browse the repository at this point in the history
* check env

* check environment

* fixes

* address feedback
  • Loading branch information
Krovatkin committed Feb 5, 2021
1 parent 8d46e8f commit 2b4f5f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def set_fuser(fuser):

def pytest_sessionstart(session):
try:
check_environment()
check_machine_configured()
except Exception as e:
if not session.config.getoption('ignore_machine_config'):
Expand Down
13 changes: 13 additions & 0 deletions torchbenchmark/util/machine_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def get_machine_config():
return config

def check_machine_configured(check_process_affinity=True):
check_environment()
if MACHINE.AMAZON_LINUX == get_machine_type():
assert 1 == check_intel_no_turbo_state(), "Turbo Boost is not disabled"
assert False == hyper_threading_enabled(), "HyperThreading is not disabled"
Expand Down Expand Up @@ -318,3 +319,15 @@ def get_machine_state():
# doesn't make too much sense to ask the user to run this configure script with the isolated cpu cores
# that check is more important to be done at runtime of benchmark, and is checked by conftest.py
#assert is_using_isolated_cpus(), "Not using isolated CPUs for this process"

def check_environment():
checks = [
# VAR_NAME, blacklist
("DEBUG", None),
("MKLDNN_VERBOSE", None),
("PYTORCH_JIT_LOG_LEVEL", None)
]

for check in checks:
if check[0] in os.environ and (check[1] == None or os.environ[check[0]] in check[1]):
raise RuntimeError(f"{check[0]} is set")

0 comments on commit 2b4f5f3

Please sign in to comment.