From 4b2582e084a690aef2f55b1e1295d31d8ec35c75 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Mon, 28 Mar 2022 13:33:31 +0800 Subject: [PATCH 1/4] Revise collect_env for win platform --- mmflow/utils/collect_env.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mmflow/utils/collect_env.py b/mmflow/utils/collect_env.py index 6c96772..7971b1f 100644 --- a/mmflow/utils/collect_env.py +++ b/mmflow/utils/collect_env.py @@ -48,9 +48,12 @@ def collect_env() -> dict: for name, devids in devices.items(): env_info['GPU ' + ','.join(devids)] = name - gcc = subprocess.check_output('gcc --version | head -n1', shell=True) - gcc = gcc.decode('utf-8').strip() - env_info['GCC'] = gcc + try: + gcc = subprocess.check_output('gcc --version | head -n1', shell=True) + gcc = gcc.decode('utf-8').strip() + env_info['GCC'] = gcc + except subprocess.CalledProcessError: # gcc is unavailable + env_info['GCC'] = 'n/a' env_info['PyTorch'] = torch.__version__ env_info['PyTorch compiling details'] = get_build_config() From bbf162378823d82ef29f96486e9b646dacf8f949 Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Mon, 28 Mar 2022 13:46:53 +0800 Subject: [PATCH 2/4] add ut --- tests/test_utils/test_set_env.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/test_utils/test_set_env.py b/tests/test_utils/test_set_env.py index fb77234..374404d 100644 --- a/tests/test_utils/test_set_env.py +++ b/tests/test_utils/test_set_env.py @@ -2,11 +2,14 @@ import multiprocessing as mp import os import platform +import sys import cv2 +import mmcv import pytest from mmcv import Config +import mmflow from mmflow.utils import setup_multi_processes @@ -85,3 +88,32 @@ def test_setup_multi_processes(workers_per_gpu, valid, env_cfg): assert cv2.getNumThreads() == sys_cv_threads assert 'OMP_NUM_THREADS' not in os.environ assert 'MKL_NUM_THREADS' not in os.environ + + +def test_collect_env(): + try: + import torch # noqa: F401 + except ModuleNotFoundError: + pytest.skip('skipping tests that require PyTorch') + + from mmflow.utils import collect_env + env_info = collect_env() + expected_keys = [ + 'sys.platform', 'Python', 'CUDA available', 'PyTorch', + 'PyTorch compiling details', 'OpenCV', 'MMCV', 'MMCV Compiler', + 'MMCV CUDA Compiler', 'MMFlow', 'GCC', 'NVCC' + ] + for key in expected_keys: + assert key in env_info + + if env_info['CUDA available']: + for key in ['CUDA_HOME', 'NVCC']: + assert key in env_info + + if sys.platform == 'win32': + assert env_info['GCC'] == 'n/a' + + assert env_info['sys.platform'] == sys.platform + assert env_info['Python'] == sys.version.replace('\n', '') + assert env_info['MMCV'] == mmcv.__version__ + assert mmflow.__version__ in env_info['MMFlow'] From 982b36a8d757af6022d039d565f1ba94f20060bb Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Mon, 28 Mar 2022 14:34:16 +0800 Subject: [PATCH 3/4] fix ut --- tests/test_utils/test_set_env.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_utils/test_set_env.py b/tests/test_utils/test_set_env.py index 374404d..d709779 100644 --- a/tests/test_utils/test_set_env.py +++ b/tests/test_utils/test_set_env.py @@ -101,7 +101,7 @@ def test_collect_env(): expected_keys = [ 'sys.platform', 'Python', 'CUDA available', 'PyTorch', 'PyTorch compiling details', 'OpenCV', 'MMCV', 'MMCV Compiler', - 'MMCV CUDA Compiler', 'MMFlow', 'GCC', 'NVCC' + 'MMCV CUDA Compiler', 'MMFlow', 'GCC' ] for key in expected_keys: assert key in env_info From 9d6a85c6d663560ad23163009f8120ad602b5bfd Mon Sep 17 00:00:00 2001 From: MeowZheng Date: Mon, 28 Mar 2022 21:48:29 +0800 Subject: [PATCH 4/4] remove win ut --- tests/test_utils/test_set_env.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_utils/test_set_env.py b/tests/test_utils/test_set_env.py index d709779..57d3417 100644 --- a/tests/test_utils/test_set_env.py +++ b/tests/test_utils/test_set_env.py @@ -110,9 +110,6 @@ def test_collect_env(): for key in ['CUDA_HOME', 'NVCC']: assert key in env_info - if sys.platform == 'win32': - assert env_info['GCC'] == 'n/a' - assert env_info['sys.platform'] == sys.platform assert env_info['Python'] == sys.version.replace('\n', '') assert env_info['MMCV'] == mmcv.__version__