[Enhance] Use MMCV collect_env (#137)

pull/149/head
Jerry Jiarui XU 2020-09-19 21:32:41 +08:00 committed by GitHub
parent b8c2f913e4
commit e3f6d575ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 59 deletions

View File

@ -1,68 +1,13 @@
import os.path as osp from mmcv.utils import collect_env as collect_base_env
import subprocess from mmcv.utils import get_git_hash
import sys
from collections import defaultdict
import cv2
import mmcv
import torch
import torchvision
from mmcv.utils import get_build_config, get_git_hash
import mmseg import mmseg
def collect_env(): def collect_env():
"""Collect the information of the running environments.""" """Collect the information of the running environments."""
env_info = {} env_info = collect_base_env()
env_info['sys.platform'] = sys.platform
env_info['Python'] = sys.version.replace('\n', '')
cuda_available = torch.cuda.is_available()
env_info['CUDA available'] = cuda_available
if cuda_available:
from mmcv.utils.parrots_wrapper import CUDA_HOME
env_info['CUDA_HOME'] = CUDA_HOME
if CUDA_HOME is not None and osp.isdir(CUDA_HOME):
try:
nvcc = osp.join(CUDA_HOME, 'bin/nvcc')
nvcc = subprocess.check_output(
'"{}" -V | tail -n1'.format(nvcc), shell=True)
nvcc = nvcc.decode('utf-8').strip()
except subprocess.SubprocessError:
nvcc = 'Not Available'
env_info['NVCC'] = nvcc
devices = defaultdict(list)
for k in range(torch.cuda.device_count()):
devices[torch.cuda.get_device_name(k)].append(str(k))
for name, devids in devices.items():
env_info['GPU ' + ','.join(devids)] = name
try:
gcc = subprocess.check_output('gcc --version | head -n1', shell=True)
gcc = gcc.decode('utf-8').strip()
env_info['GCC'] = gcc
except subprocess.CalledProcessError:
env_info['GCC'] = 'n/a'
env_info['PyTorch'] = torch.__version__
env_info['PyTorch compiling details'] = get_build_config()
env_info['TorchVision'] = torchvision.__version__
env_info['OpenCV'] = cv2.__version__
env_info['MMCV'] = mmcv.__version__
env_info['MMSegmentation'] = f'{mmseg.__version__}+{get_git_hash()[:7]}' env_info['MMSegmentation'] = f'{mmseg.__version__}+{get_git_hash()[:7]}'
try:
from mmcv.ops import get_compiler_version, get_compiling_cuda_version
env_info['MMCV Compiler'] = get_compiler_version()
env_info['MMCV CUDA Compiler'] = get_compiling_cuda_version()
except ImportError:
env_info['MMCV Compiler'] = 'n/a'
env_info['MMCV CUDA Compiler'] = 'n/a'
return env_info return env_info

View File

@ -8,6 +8,6 @@ line_length = 79
multi_line_output = 0 multi_line_output = 0
known_standard_library = setuptools known_standard_library = setuptools
known_first_party = mmseg known_first_party = mmseg
known_third_party = PIL,cityscapesscripts,cv2,matplotlib,mmcv,numpy,onnxruntime,pytablewriter,pytest,scipy,torch,torchvision known_third_party = PIL,cityscapesscripts,matplotlib,mmcv,numpy,onnxruntime,pytablewriter,pytest,scipy,torch
no_lines_before = STDLIB,LOCALFOLDER no_lines_before = STDLIB,LOCALFOLDER
default_section = THIRDPARTY default_section = THIRDPARTY