From 5a0f967be84c27450612342d1f82583862e073ea Mon Sep 17 00:00:00 2001 From: Bar <29775567+barrh@users.noreply.github.com> Date: Wed, 22 May 2019 17:36:21 +0300 Subject: [PATCH] Log pip freeze (#266) Log the version of all the python packages active in the python environment (instead of the the version of numpy and pytorch). This helps in recreating experiments, if you're not using the default versions prescribed in requirements.txt. --- distiller/apputils/execution_env.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/distiller/apputils/execution_env.py b/distiller/apputils/execution_env.py index 34cfafe..09b6d49 100755 --- a/distiller/apputils/execution_env.py +++ b/distiller/apputils/execution_env.py @@ -22,11 +22,13 @@ you want to understand the environment in which you execute the training. import logging import logging.config +import operator import os import platform import shutil import sys import time +import pkg_resources from git import Repo, InvalidGitRepositoryError import numpy as np @@ -83,8 +85,10 @@ def log_execution_env_state(config_paths=None, logdir=None, gitroot='.'): if HAVE_LSB: logger.debug("OS: %s", lsb_release.get_lsb_information()['DESCRIPTION']) logger.debug("Python: %s", sys.version) - logger.debug("PyTorch: %s", torch.__version__) - logger.debug("Numpy: %s", np.__version__) + def _pip_freeze(): + return {x.key:x.version for x in sorted(pkg_resources.working_set, + key=operator.attrgetter('key'))} + logger.debug("pip freeze: {}".format(_pip_freeze())) log_git_state() logger.debug("Command line: %s", " ".join(sys.argv)) -- GitLab