From c507d6f1763bbd6ff00953b369d86bdef2160022 Mon Sep 17 00:00:00 2001 From: Xin Qiu Date: Tue, 3 Nov 2020 10:12:33 +0800 Subject: [PATCH] update Torch example (#3022) * update example * Update README.md * update resnet_finetune.py * delete some file * Create README.md * Update README.md * Update README.md * Update README.md * add detect conda env name * some change * update run example scripte * update init orca context --- python/dllib/src/bigdl/dllib/utils/utils.py | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/python/dllib/src/bigdl/dllib/utils/utils.py b/python/dllib/src/bigdl/dllib/utils/utils.py index 586d47eb6f9..d848ba2a15a 100644 --- a/python/dllib/src/bigdl/dllib/utils/utils.py +++ b/python/dllib/src/bigdl/dllib/utils/utils.py @@ -77,6 +77,29 @@ def detect_python_location(): return out.strip() +def detect_conda_env_name(): + import subprocess + pro = subprocess.Popen( + "conda info", + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + out, err = pro.communicate() + out = out.decode("utf-8") + err = err.decode("utf-8") + errorcode = pro.returncode + if 0 != errorcode: + raise EnvironmentError(err + + "Cannot find conda info.") + for line in out.split('\n'): + item = line.split(':') + if len(item) == 2: + if item[0].strip() == "active environment": + return item[1].strip() + raise EnvironmentError(err + + "Failed to detect conda env name.") + + # This is adopted from conda-pack. def pack_conda_main(conda_name, tmp_path): import subprocess