Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rknn device check #1363

Merged
merged 6 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mmdeploy/apis/rknn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmdeploy.backend.rknn import is_available
from mmdeploy.backend.rknn import device_available, is_available, package_info

__all__ = ['is_available']
__all__ = ['is_available', 'device_available', 'package_info']

if is_available():
from mmdeploy.backend.rknn.onnx2rknn import onnx2rknn as _onnx2rknn
Expand Down
17 changes: 14 additions & 3 deletions mmdeploy/backend/rknn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,26 @@ def is_available():
return importlib.util.find_spec('rknn') is not None


def package_info():
import pkg_resources
for p in pkg_resources.working_set:
AllentDan marked this conversation as resolved.
Show resolved Hide resolved
if p.project_name.startswith('rknn-toolkit'):
return dict(name=p.project_name, version=p.version)
return dict(name=None, version=None)


def device_available():
"""Check whether device available.

Returns:
bool: True if the device is available.
"""
ret = subprocess.check_output('adb devices', shell=True)
match = re.search(r'\\n\w+\\tdevice', str(ret))
return match is not None
try:
ret = subprocess.check_output('adb devices', shell=True)
AllentDan marked this conversation as resolved.
Show resolved Hide resolved
match = re.search(r'\\n\w+\\tdevice', str(ret))
return match is not None
except Exception:
return False


__all__ = []
Expand Down
4 changes: 4 additions & 0 deletions tools/check_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def check_backend():
logger.info(f'ncnn: {ncnn_version}\tops_is_avaliable : '
f'{ncnn_apis.is_custom_ops_available()}')

import mmdeploy.apis.rknn as rknn_apis
logger.info(f'rknn: {rknn_apis.package_info()}\t'
f'adb_device_available: {rknn_apis.device_available()}')

import mmdeploy.apis.pplnn as pplnn_apis
logger.info(f'pplnn_is_avaliable: {pplnn_apis.is_available()}')

Expand Down