Unverified Commit 013000d1 authored by RunningLeon's avatar RunningLeon Committed by GitHub
Browse files

Add check env sub command (#654)

* add check env

* update issue template'

* remove some reqs from check env

* resolve comment
parent 9febf610
......@@ -25,6 +25,18 @@ body:
A placeholder for the command.
validations:
required: true
- type: textarea
attributes:
label: Environment
description: |
1. Please run `lmdeploy check_env` to collect necessary environment information and paste it here.
2. You may add addition that may be helpful for locating the problem, such as
- How you installed PyTorch \[e.g., pip, conda, source\]
- Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)
placeholder: Environment here.
render: Shell
validations:
required: true
- type: textarea
attributes:
label: Error traceback
......
# Copyright (c) OpenMMLab. All rights reserved.
import os
import fire
from .chat import SubCliChat
......@@ -77,6 +79,50 @@ class CLI(object):
print('Supported model names:')
print('\n'.join(model_names))
def check_env(self, dump_file: str = None):
"""Check env information.
Args:
dump_file (str): Output file to save env info.
"""
import importlib
import mmengine
from mmengine.utils import get_git_hash
from mmengine.utils.dl_utils import collect_env
from lmdeploy.version import __version__
env_info = collect_env()
env_info['LMDeploy'] = __version__ + '+' + get_git_hash()[:7]
# remove some unnecessary info
remove_reqs = ['MMEngine', 'OpenCV']
for req in remove_reqs:
if req in env_info:
env_info.pop(req)
# extra important dependencies
extra_reqs = ['transformers', 'gradio', 'fastapi', 'pydantic']
for req in extra_reqs:
try:
env_info[req] = importlib.import_module(req).__version__
except Exception:
env_info[req] = 'Not Found'
# print env info
for k, v in env_info.items():
print(f'{k}: {v}')
# dump to local file
if dump_file is not None:
work_dir, _ = os.path.split(dump_file)
if work_dir:
os.makedirs(work_dir, exist_ok=True)
mmengine.dump(env_info, dump_file)
def run():
"""The entry point of running LMDeploy CLI."""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment