提交 de795dac 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!206 fix bug: [Bug]{MI]{Profiler]device_target not verified in profilling

Merge pull request !206 from WeibiaoYu/r0.3
...@@ -65,21 +65,29 @@ class Profiler: ...@@ -65,21 +65,29 @@ class Profiler:
def __init__(self, subgraph='all', is_detail=True, is_show_op_path=False, output_path='./data', def __init__(self, subgraph='all', is_detail=True, is_show_op_path=False, output_path='./data',
optypes_to_deal='', optypes_not_deal='Variable', job_id=""): optypes_to_deal='', optypes_not_deal='Variable', job_id=""):
# get device_id # get device_id and device_target
device_target = ""
try: try:
import mindspore.context as context import mindspore.context as context
dev_id = context.get_context("device_id") dev_id = str(context.get_context("device_id"))
device_target = context.get_context("device_target")
except ImportError: except ImportError:
logger.error("Profiling: fail to import context from mindspore.") logger.error("Profiling: fail to import context from mindspore.")
except ValueError as err: except ValueError as err:
logger.error("Profiling: fail to get context %s", err.message) logger.error("Profiling: fail to get context %s", err.message)
if not dev_id: if not dev_id:
dev_id = os.getenv('DEVICE_ID') dev_id = str(os.getenv('DEVICE_ID'))
if not dev_id: if not dev_id:
dev_id = "0" dev_id = "0"
logger.error("Fail to get DEVICE_ID, use 0 instead.") logger.error("Fail to get DEVICE_ID, use 0 instead.")
if device_target and device_target != "Davinci" \
and device_target != "Ascend":
msg = ("Profiling: unsupport backend: %s" \
% device_target)
raise RuntimeError(msg)
self._dev_id = dev_id self._dev_id = dev_id
self._container_path = os.path.join(self._base_profiling_container_path, dev_id) self._container_path = os.path.join(self._base_profiling_container_path, dev_id)
data_path = os.path.join(self._container_path, "data") data_path = os.path.join(self._container_path, "data")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册