예제 #1
0
    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=""):
        # get device_id and device_target
        self._get_devid_and_devtarget()
        self._output_path = validate_and_normalize_path(output_path)
        self._output_path = os.path.join(self._output_path, "profiler")
        if not os.path.exists(self._output_path):
            os.makedirs(self._output_path, exist_ok=True)
        else:
            logger.warning(
                "The target dir already exists. "
                "There may be some old profiling data, and they will be rewrote in the end."
            )

        if self._device_target and self._device_target == "GPU":
            from mindspore._c_expression import GPUProfiler
            self._gpu_profiler = GPUProfiler.get_instance()
            self._gpu_profiler.init(self._output_path)
            self._gpu_profiler.step_profiling_enable(True)
        elif self._device_target and (self._device_target == "Ascend"
                                      or self._device_target != "Davinci"):
            self._container_path = os.path.join(
                self._base_profiling_container_path, self._dev_id)
            data_path = os.path.join(self._container_path, "data")
            if not os.path.exists(data_path):
                os.makedirs(data_path, exist_ok=True)

            os.environ['PROFILING_MODE'] = 'true'
            os.environ['PROFILING_OPTIONS'] = 'training_trace:task_trace'
            os.environ['MINDDATA_PROFILING_DIR'] = self._output_path
            os.environ['DEVICE_ID'] = self._dev_id
            os.environ['AICPU_PROFILING_MODE'] = 'true'
            os.environ['PROFILING_DIR'] = str(self._container_path)

            # use context interface to open profiling, for the new mindspore version(after 2020.5.21)
            context.set_context(enable_profiling=True,
                                profiling_options="training_trace:task_trace")

            self._subgraph = check_subgraph(subgraph)
            self._valid_optype_name = optypes_to_deal.split(
                ",") if optypes_to_deal else []
            self._filt_optype_names = optypes_not_deal.split(
                ",") if optypes_not_deal else []
            self._detail = check_bool(is_detail, 'is_detail')
            self._withfullpath = check_bool(is_show_op_path, 'is_show_op_path')
            self._profiling_job_id = job_id
            # add job id env through user input later
            self._job_id_env = 0
            self._start_time = int(time.time() * 10000000)
            logger.info("Profiling: profiling start time: %d",
                        self._start_time)
예제 #2
0
    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=""):
        # get device_id and device_target
        self._get_devid_and_devtarget()
        self._container_path = os.path.join(
            self._base_profiling_container_path, self._dev_id)
        data_path = os.path.join(self._container_path, "data")
        if not os.path.exists(data_path):
            os.makedirs(data_path, exist_ok=True)
        self._output_path = validate_and_normalize_path(output_path)
        self._output_path = os.path.join(self._output_path, "profiler")
        if not os.path.exists(self._output_path):
            os.makedirs(self._output_path, exist_ok=True)

        os.environ['PROFILING_MODE'] = 'true'
        os.environ['PROFILING_OPTIONS'] = 'training_trace:task_trace'
        os.environ['MINDDATA_PROFILING_DIR'] = self._output_path
        os.environ['DEVICE_ID'] = self._dev_id
        os.environ['AICPU_PROFILING_MODE'] = 'true'
        os.environ['PROFILING_DIR'] = str(self._container_path)

        # use context interface to open profiling, for the new mindspore version(after 2020.5.21)
        context.set_context(enable_profiling=True,
                            profiling_options="training_trace:task_trace")

        self._subgraph = check_subgraph(subgraph)
        self._valid_optype_name = optypes_to_deal.split(
            ",") if optypes_to_deal else []
        self._filt_optype_names = optypes_not_deal.split(
            ",") if optypes_not_deal else []
        self._detail = check_bool(is_detail, 'is_detail')
        self._withfullpath = check_bool(is_show_op_path, 'is_show_op_path')
        self._profiling_job_id = job_id
        # add job id env through user input later
        self._job_id_env = 0
        self._start_time = int(time.time() * 10000000)
        logger.info("Profiling: profiling start time: %d", self._start_time)