Skip to content

Commit e3f6d57

Browse files
authored
[Enhance] Use MMCV collect_env (open-mmlab#137)
1 parent b8c2f91 commit e3f6d57

File tree

2 files changed

+4
-59
lines changed

2 files changed

+4
-59
lines changed

mmseg/utils/collect_env.py

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,13 @@
1-
import os.path as osp
2-
import subprocess
3-
import sys
4-
from collections import defaultdict
5-
6-
import cv2
7-
import mmcv
8-
import torch
9-
import torchvision
10-
from mmcv.utils import get_build_config, get_git_hash
1+
from mmcv.utils import collect_env as collect_base_env
2+
from mmcv.utils import get_git_hash
113

124
import mmseg
135

146

157
def collect_env():
168
"""Collect the information of the running environments."""
17-
env_info = {}
18-
env_info['sys.platform'] = sys.platform
19-
env_info['Python'] = sys.version.replace('\n', '')
20-
21-
cuda_available = torch.cuda.is_available()
22-
env_info['CUDA available'] = cuda_available
23-
24-
if cuda_available:
25-
from mmcv.utils.parrots_wrapper import CUDA_HOME
26-
env_info['CUDA_HOME'] = CUDA_HOME
27-
28-
if CUDA_HOME is not None and osp.isdir(CUDA_HOME):
29-
try:
30-
nvcc = osp.join(CUDA_HOME, 'bin/nvcc')
31-
nvcc = subprocess.check_output(
32-
'"{}" -V | tail -n1'.format(nvcc), shell=True)
33-
nvcc = nvcc.decode('utf-8').strip()
34-
except subprocess.SubprocessError:
35-
nvcc = 'Not Available'
36-
env_info['NVCC'] = nvcc
37-
38-
devices = defaultdict(list)
39-
for k in range(torch.cuda.device_count()):
40-
devices[torch.cuda.get_device_name(k)].append(str(k))
41-
for name, devids in devices.items():
42-
env_info['GPU ' + ','.join(devids)] = name
43-
try:
44-
gcc = subprocess.check_output('gcc --version | head -n1', shell=True)
45-
gcc = gcc.decode('utf-8').strip()
46-
env_info['GCC'] = gcc
47-
except subprocess.CalledProcessError:
48-
env_info['GCC'] = 'n/a'
49-
50-
env_info['PyTorch'] = torch.__version__
51-
env_info['PyTorch compiling details'] = get_build_config()
52-
53-
env_info['TorchVision'] = torchvision.__version__
54-
55-
env_info['OpenCV'] = cv2.__version__
56-
57-
env_info['MMCV'] = mmcv.__version__
9+
env_info = collect_base_env()
5810
env_info['MMSegmentation'] = f'{mmseg.__version__}+{get_git_hash()[:7]}'
59-
try:
60-
from mmcv.ops import get_compiler_version, get_compiling_cuda_version
61-
env_info['MMCV Compiler'] = get_compiler_version()
62-
env_info['MMCV CUDA Compiler'] = get_compiling_cuda_version()
63-
except ImportError:
64-
env_info['MMCV Compiler'] = 'n/a'
65-
env_info['MMCV CUDA Compiler'] = 'n/a'
6611

6712
return env_info
6813

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ line_length = 79
88
multi_line_output = 0
99
known_standard_library = setuptools
1010
known_first_party = mmseg
11-
known_third_party = PIL,cityscapesscripts,cv2,matplotlib,mmcv,numpy,onnxruntime,pytablewriter,pytest,scipy,torch,torchvision
11+
known_third_party = PIL,cityscapesscripts,matplotlib,mmcv,numpy,onnxruntime,pytablewriter,pytest,scipy,torch
1212
no_lines_before = STDLIB,LOCALFOLDER
1313
default_section = THIRDPARTY

0 commit comments

Comments
 (0)