Beispiel #1
0
    def __init__(self, args, custom_args, platform_util):
        super(ModelInitializer, self).__init__(args, custom_args, platform_util)

        set_env_var("OMP_NUM_THREADS", "1")

        if args.batch_size == -1:
            args.batch_size = 1
            if args.verbose:
                print("Setting batch_size to 1 since it is not supplied.")

        if args.batch_size == 1:
            if args.verbose:
                print("Running Wide_Deep model Inference in Latency mode")
        else:
            if args.verbose:
                print("Running Wide_Deep model Inference in Throughput mode")

        # Select script based on batch size
        if args.batch_size == 1:
            executable = os.path.join(args.mode, args.precision,
                                      "wide_deep_inference_bs1_latency.py")
        else:
            executable = os.path.join(args.mode, args.precision,
                                      "wide_deep_inference.py")

        self.run_cmd = " OMP_NUM_THREADS=1" + \
                       " numactl --cpunodebind=0 --membind=0 " + \
                       " python " + executable + \
                       " --data_dir=" + self.args.data_location + \
                       " --model_dir=" + self.args.checkpoint + \
                       " --batch_size=" + str(self.args.batch_size)
Beispiel #2
0
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args, platform_util)
        self.perf_script_path = os.path.join(
            self.args.intelai_models, self.args.mode, self.args.precision,
            self.RFCN_PERF_SCRIPT)
        self.accuracy_script_path = os.path.join(
            self.args.intelai_models, self.args.mode, self.args.precision,
            self.RFCN_ACCURACY_SCRIPT)

        # remove intelai models path, so that imports don't conflict
        if "MOUNT_BENCHMARK" in os.environ and \
                os.environ["MOUNT_BENCHMARK"] in sys.path:
            sys.path.remove(os.environ["MOUNT_BENCHMARK"])
        if self.args.intelai_models in sys.path:
            sys.path.remove(self.args.intelai_models)

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        # set num_inter_threads and num_intra_threds
        self.set_num_inter_intra_threads(num_inter_threads=self.args.num_inter_threads,
                                         num_intra_threads=self.args.num_intra_threads)
        omp_num_threads = self.args.num_intra_threads if self.args.num_cores == -1 else self.args.num_cores
        set_env_var("OMP_NUM_THREADS", omp_num_threads)

        self.parse_args()
Beispiel #3
0
    def __init__(self, args, custom_args, platform_util):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        self.command = ""
        command_prefix = "{} generate.py".format(self.python_exe)

        # Set default KMP env vars, except for KMP_SETTINGS
        self.set_kmp_vars(kmp_settings=None)

        self.parse_custom_args()
        # Set the num_inter_threads and num_intra_threads (override inter threads to 1)
        self.set_num_inter_intra_threads(num_inter_threads=1)
        set_env_var("OMP_NUM_THREADS", self.args.num_cores)

        if self.args.socket_id != -1:
            command_prefix = "numactl --physcpubind=0-{} --membind={} {}".\
                format(str(int(self.args.num_cores) - 1), self.args.socket_id,
                       command_prefix)
        else:
            command_prefix = "numactl --physcpubind=0-{} -l {}".format(
                str(int(self.args.num_cores) - 1), command_prefix)

        checkpoint_path = os.path.join(self.args.checkpoint,
                                       self.args.checkpoint_name)

        # create command to run benchmarking
        self.command = ("{} {} --num_inter_threads={} "
                        "--num_intra_threads={} --sample={}").format(
                            command_prefix, checkpoint_path,
                            str(self.args.num_inter_threads),
                            str(self.args.num_intra_threads),
                            str(self.args.sample))
Beispiel #4
0
    def __init__(self, args, custom_args, platform_util):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        self.run_inference_sanity_checks(self.args, self.custom_args)
        self.set_kmp_vars()
        self.set_num_inter_intra_threads()

        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)

        self.model_dir = os.path.join(self.args.intelai_models, self.args.mode,
                                      self.args.precision)

        # get benchmark command
        benchmark_script = os.path.join(self.model_dir, "infer_detections.py")

        # get command with numactl
        self.run_cmd = self.get_numactl_command(self.args.socket_id)
        self.run_cmd += "{0} {1}".format(self.python_exe, benchmark_script)
        self.run_cmd += " --input-graph {0}".format(self.args.input_graph)
        self.run_cmd += " --batch-size {0}".format(args.batch_size)
        self.run_cmd += " --inter-op-parallelism-threads {0}".format(
            self.args.num_inter_threads)
        self.run_cmd += " --intra-op-parallelism-threads {0}".format(
            self.args.num_intra_threads)

        if self.args.accuracy_only:
            self.run_cmd += " --accuracy-only "
            self.run_cmd += " --data-location {0}".format(
                self.args.data_location)
Beispiel #5
0
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        self.perf_script_path = os.path.join(self.args.intelai_models,
                                             self.args.mode,
                                             self.args.precision,
                                             self.RFCN_PERF_SCRIPT)
        self.accuracy_script_path = os.path.join(self.args.intelai_models,
                                                 self.args.mode,
                                                 self.args.precision,
                                                 self.RFCN_ACCURACY_SCRIPT)

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        # set num_inter_threads and num_intra_threds
        self.set_num_inter_intra_threads(
            num_inter_threads=self.args.num_inter_threads,
            num_intra_threads=self.args.num_intra_threads)
        omp_num_threads = self.args.num_intra_threads if self.args.num_cores == -1 else self.args.num_cores
        set_env_var("OMP_NUM_THREADS", omp_num_threads)

        self.parse_args()
        self.validate_args()
    def run_benchmark(self):
        command_prefix = self.get_command_prefix(self.args.socket_id) + \
            self.python_exe + " " + self.benchmark_script

        # set num_inter_threads and num_intra_threads
        self.set_num_inter_intra_threads()

        if self.args.socket_id == -1:
            if self.args.num_cores == 1:
                command_prefix = "taskset -c 0 " + \
                                 command_prefix
                self.args.num_intra_threads = 1
            else:
                command_prefix = "taskset -c 0-" + \
                                 str(self.args.num_cores - 1) + \
                                 " " + command_prefix

        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)
        config_file_path = os.path.join(self.args.checkpoint,
                                        self.args.config_file)

        run_cmd = command_prefix + \
            " --inter_op " + str(self.args.num_inter_threads) + \
            " --intra_op " + str(self.args.num_intra_threads) + \
            " --omp " + str(self.args.num_intra_threads) + \
            " --pipeline_config_path " + config_file_path + \
            " --checkpoint_dir " + str(self.args.checkpoint) + \
            " --eval_dir " + self.research_dir + \
            "/object_detection/models/rfcn/eval " + \
            " --logtostderr " + \
            " --blocktime=0 " + \
            " --run_once=True"
        self.run_command(run_cmd)
Beispiel #7
0
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        self.set_num_inter_intra_threads()
        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)
        set_env_var("KMP_HW_SUBSET",
                    "{}c,1T".format(self.args.num_intra_threads))
        script_path = os.path.join(self.args.intelai_models, self.args.mode,
                                   self.args.precision, "brats", "predict.py")

        # add numactl prefix to the command
        self.command_prefix = self.get_command_prefix(self.args.socket_id) + \
            "python " + script_path

        # add additional args to the command
        self.command_prefix += \
            " --inter {} --intra {} --nw 1 --nb 5 --bs {}".\
            format(self.args.num_inter_threads, self.args.num_intra_threads,
                   self.args.batch_size)
Beispiel #8
0
    def __init__(self, args, custom_args=[], platform_util=None):
        self.args = args
        self.custom_args = custom_args
        self.platform_util = platform_util

        # Set KMP env vars, if they haven't already been set
        self.set_kmp_vars()
        set_env_var("KMP_HW_SUBSET", "1T")

        if self.args.accuracy_only:
            print("Accuracy testing for DRAW inference is not supported yet.")
            sys.exit(1)

        # Set the num_inter_threads and num_intra_threads
        self.set_default_inter_intra_threads(self.platform_util)

        # Create the command prefix with numactl and executing the script
        script_path = os.path.join(self.args.intelai_models, self.args.mode,
                                   self.args.precision, "draw_inf.py")
        self.command_prefix = self.get_numactl_command(args.socket_id) + \
            " python {} ".format(script_path)

        # Add additional args to the command
        self.command_prefix += "--cp {} --num_inter_threads {} " \
                               "--num_intra_threads {} --bs {} --dl {} " \
                               "--nw 100 --nb 200".\
            format(self.args.checkpoint, self.args.num_inter_threads,
                   self.args.num_intra_threads, self.args.batch_size,
                   self.args.data_location)
Beispiel #9
0
    def __init__(self, args, custom_args, platform_util):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        self.accuracy_script_path = os.path.join(self.args.intelai_models,
                                                 self.args.mode,
                                                 self.args.precision,
                                                 self.accuracy_script)
        self.perf_script_path = os.path.join(self.args.intelai_models,
                                             self.args.mode,
                                             self.args.precision,
                                             self.benchmark_script)

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        # set num_inter_threads and num_intra_threds
        self.set_num_inter_intra_threads(
            num_inter_threads=self.args.num_inter_threads,
            num_intra_threads=self.args.num_intra_threads)
        self.omp_num_threads = self.args.num_intra_threads if self.args.num_cores == -1 else self.args.num_cores
        set_env_var("OMP_NUM_THREADS", self.omp_num_threads)

        self.parse_custom_args()
        self.run_inference_sanity_checks(self.args, self.custom_args)
        self.research_dir = os.path.join(self.args.model_source_dir,
                                         "research")
Beispiel #10
0
    def __init__(self, args, custom_args, platform_util):
        super(ModelInitializer, self).__init__(args, custom_args, platform_util)

        self.command = ""
        command_prefix = "{} generate.py".format(self.python_exe)

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        self.parse_custom_args()
        # Set the num_inter_threads and num_intra_threads (override inter threads to 1)
        self.set_num_inter_intra_threads(num_inter_threads=1)
        set_env_var("OMP_NUM_THREADS", self.args.num_cores)

        if self.args.socket_id != -1:
            command_prefix = "numactl --physcpubind=0-{} --membind={} {}".\
                format(str(int(self.args.num_cores) - 1), self.args.socket_id,
                       command_prefix)
        else:
            command_prefix = "numactl --physcpubind=0-{} -l {}".format(
                str(int(self.args.num_cores) - 1), command_prefix)

        checkpoint_path = os.path.join(self.args.checkpoint,
                                       self.args.checkpoint_name)

        # create command to run benchmarking
        self.command = ("{} {} --num_inter_threads={} "
                        "--num_intra_threads={} --sample={}").format(
            command_prefix, checkpoint_path, str(self.args.num_inter_threads),
            str(self.args.num_intra_threads), str(self.args.sample))
Beispiel #11
0
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args, platform_util)

        # Set the num_inter_threads and num_intra_threads
        # if user did not provide then default value based on platform will be set
        self.set_num_inter_intra_threads(self.args.num_inter_threads,
                                         self.args.num_intra_threads)

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        benchmark_script = os.path.join(self.args.intelai_models, self.args.mode,
                                        "infer_detections.py")
        self.command_prefix = self.get_command_prefix(self.args.socket_id) \
            + "{} {}".format(self.python_exe, benchmark_script)
        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)

        self.command_prefix += " -g {0}".format(self.args.input_graph)
        self.command_prefix += " -i 1000"
        self.command_prefix += " -w 200"
        self.command_prefix += " -a {0}".format(self.args.num_intra_threads)
        self.command_prefix += " -e {0}".format(self.args.num_inter_threads)
        if self.args.data_location:
            self.command_prefix += " -d {0}".format(self.args.data_location)

        if self.args.accuracy_only:
            self.command_prefix += " -r"
            assert self.args.data_location, "accuracy must provide the data."
        else:
            # Did not support multi-batch accuracy check.
            self.command_prefix += " -b {0}".format(self.args.batch_size)
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        # set num_inter_threads and num_intra_threads
        self.set_num_inter_intra_threads()

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        benchmark_script = os.path.join(self.args.intelai_models, args.mode,
                                        args.precision, "inference_bench.py")
        self.benchmark_command = self.get_command_prefix(args.socket_id) + \
            self.python_exe + " " + benchmark_script

        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)
        self.cifar10_dir = os.path.join(args.model_source_dir, "research",
                                        "gan", "cifar")

        self.benchmark_command = self.benchmark_command + \
            " -ckpt " + str(self.args.checkpoint) + \
            " -dl " + str(self.args.data_location) + \
            " --num_inter_threads " + str(self.args.num_inter_threads) + \
            " --num_intra_threads " + str(self.args.num_intra_threads) + \
            " -nw 100 -nb 500" + \
            " --bs " + str(self.args.batch_size) + \
            " --kmp_blocktime " + os.environ["KMP_BLOCKTIME"] + \
            " --kmp_settings " + os.environ["KMP_SETTINGS"]
Beispiel #13
0
    def __init__(self, args, custom_args, platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        self.benchmark_command = ""  # use default batch size if -1
        self.results_file_path = ""

        if self.args.batch_size == -1:
            self.args.batch_size = 1024

        # get number of cores if there is no core info passed in.
        if self.args.num_cores == -1:
            self.args.num_cores = self.platform_util.num_cores_per_socket()

        num_of_parallel_batches = self.platform_util.num_cores_per_socket()
        kmp_blocktime = "0"
        # Set KMP env vars, if they haven't already been set
        self.set_kmp_vars(
            kmp_settings="1",
            kmp_blocktime=kmp_blocktime,
            kmp_affinity="noverbose,warnings,respect,granularity=core,none")
        # set num_inter_threads and num_intra_threads
        self.set_num_inter_intra_threads(num_inter_threads=self.args.num_cores,
                                         num_intra_threads=1)

        benchmark_script = os.path.join(self.args.intelai_models,
                                        self.args.mode, "inference.py")

        self.benchmark_command = self.get_numactl_command(self.args.socket_id)\
            + "python " + benchmark_script

        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)
        self.benchmark_command += " --input-graph=" + \
                                  self.args.input_graph + \
                                  " --inter-op-parallelism-threads=" + \
                                  str(self.args.num_inter_threads) + \
                                  " --intra-op-parallelism-threads=" + \
                                  str(self.args.num_intra_threads) + \
                                  " --omp-num-threads=" + \
                                  str(self.args.num_intra_threads) + \
                                  " --batch-size=" + \
                                  str(self.args.batch_size) + \
                                  " --num-of-parallel-batches=" + \
                                  str(num_of_parallel_batches) + \
                                  " --kmp-blocktime=" + \
                                  str(kmp_blocktime)

        # if the data location directory is not empty, then include the arg
        if self.args.data_location:
            self.benchmark_command += " --datafile-path=" + \
                                      self.args.data_location
            # if output results is enabled, generate a results file name and pass it to the inference script
            if self.args.output_results:
                self.results_filename = "{}_{}_{}_results_{}.txt".format(
                    self.args.model_name, self.args.precision, self.args.mode,
                    time.strftime("%Y%m%d_%H%M%S", time.gmtime()))
                self.results_file_path = os.path.join(self.args.output_dir,
                                                      self.results_filename)
                self.benchmark_command += " --results-file-path {}".format(
                    self.results_file_path)
Beispiel #14
0
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args, platform_util)

        # Set the num_inter_threads and num_intra_threads
        self.set_num_inter_intra_threads()
        # Set env vars, if they haven't already been set
        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads, overwrite_existing=True)
Beispiel #15
0
    def __init__(self, args, custom_args=[], platform_util=None):
        self.args = args
        self.custom_args = custom_args
        self.platform_util = platform_util

        # set num_inter_threads and num_intra_threads
        self.set_default_inter_intra_threads(self.platform_util)

        # Set KMP env vars, if they haven't already been set
        self.set_kmp_vars()
        set_env_var("KMP_HW_SUBSET", "1T")

        benchmark_script = os.path.join(self.args.intelai_models, args.mode,
                                        args.precision, "inference_bench.py")
        self.benchmark_command = self.get_numactl_command(args.socket_id) + \
            "python " + benchmark_script

        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)
        self.cifar10_dir = os.path.join(args.model_source_dir, "research",
                                        "gan", "cifar")

        self.benchmark_command = self.benchmark_command + \
            " -ckpt " + str(self.args.checkpoint) + \
            " -dl " + str(self.args.data_location) + \
            " --num_inter_threads " + str(self.args.num_inter_threads) + \
            " --num_intra_threads " + str(self.args.num_intra_threads) + \
            " -nw 100 -nb 500" + \
            " --bs " + str(self.args.batch_size) + \
            " --kmp_blocktime " + os.environ["KMP_BLOCKTIME"] + \
            " --kmp_settings " + os.environ["KMP_SETTINGS"]
    def __init__(self, args, custom_args, platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        # set num_inter_threads and num_intra_threads
        self.set_num_inter_intra_threads()

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)

        benchmark_script = os.path.join(self.args.intelai_models,
                                        self.args.mode, self.args.precision,
                                        "one_image_test.py")
        self.command_prefix = \
            self.get_command_prefix(self.args.socket_id) + \
            "{} ".format(self.python_exe) + benchmark_script

        self.run_cmd = \
            self.command_prefix + \
            " --num_inter_threads " + str(self.args.num_inter_threads) + \
            " --num_intra_threads " + str(self.args.num_intra_threads) + \
            " -ckpt " + self.args.checkpoint + \
            " -dl " + self.args.data_location
Beispiel #17
0
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        # use default batch size if -1
        if self.args.batch_size == -1:
            self.args.batch_size = 128

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        # set num_inter_threads and num_intra_threads (override inter threads to 2)
        self.set_num_inter_intra_threads(num_inter_threads=2)

        script_name = "accuracy.py" if self.args.accuracy_only \
            else "eval_image_classifier.py"
        script_path = os.path.join(self.args.intelai_models, self.args.mode,
                                   self.args.precision, script_name)
        self.command_prefix = "{} {}".format(self.python_exe, script_path)

        if self.args.socket_id != -1:
            self.command_prefix = "numactl --cpunodebind={} -l {}".format(
                str(self.args.socket_id), self.command_prefix)

        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)

        if not self.args.accuracy_only:
            self.command_prefix = ("{prefix} "
                                   "--dataset_name imagenet "
                                   "--checkpoint_path {checkpoint} "
                                   "--dataset_split_name=validation "
                                   "--clone_on_cpu=True "
                                   "--model_name {model} "
                                   "--inter_op_parallelism_threads {inter} "
                                   "--intra_op_parallelism_threads {intra} "
                                   "--batch_size {bz}").format(
                                       prefix=self.command_prefix,
                                       checkpoint=self.args.checkpoint,
                                       model=self.args.model_name,
                                       inter=self.args.num_inter_threads,
                                       intra=self.args.num_intra_threads,
                                       bz=self.args.batch_size)

            if self.args.data_location:
                self.command_prefix += " --dataset_dir {}".format(
                    self.args.data_location)
        else:
            # add args for the accuracy script
            script_args_list = [
                "input_graph", "data_location", "input_height", "input_width",
                "batch_size", "input_layer", "output_layer",
                "num_inter_threads", "num_intra_threads"
            ]
            self.command_prefix = self.add_args_to_command(
                self.command_prefix, script_args_list)
Beispiel #18
0
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)
        self.cmd = self.get_numactl_command(self.args.socket_id) + \
            self.python_exe + " "

        # Set KMP env vars, if they haven't already been set
        self.set_kmp_vars()

        pairs_file = os.path.join(self.args.model_source_dir, "data/pairs.txt")
        arg_parser = ArgumentParser(description='Parse custom args')
        arg_parser.add_argument(
            "--lfw_pairs",
            type=str,
            help="The file containing the pairs to use for validation.",
            dest="lfw_pairs",
            default=pairs_file)
        self.args = arg_parser.parse_args(self.custom_args,
                                          namespace=self.args)

        # use default batch size if -1
        if self.args.batch_size == -1 or self.args.accuracy_only:
            self.args.batch_size = 100

        # set num_inter_threads and num_intra_threads
        if self.args.batch_size > 32:
            self.set_num_inter_intra_threads(num_inter_threads=2)
        else:
            self.set_num_inter_intra_threads(num_inter_threads=1)

        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)

        run_script = os.path.join(self.args.model_source_dir,
                                  "src/validate_on_lfw.py")

        warmup_steps = 40
        max_steps = 1000
        if self.args.batch_size == 1:
            warmup_steps = 200

        cmd_args = ' ' + self.args.data_location + \
                   ' ' + self.args.checkpoint + ' --distance_metric 1' + \
                   ' --use_flipped_images' + ' --subtract_mean' + \
                   ' --use_fixed_image_standardization' + \
                   ' --num_inter_threads=' + \
                   str(self.args.num_inter_threads) + \
                   ' --num_intra_threads=' + \
                   str(self.args.num_intra_threads) + \
                   ' --lfw_batch_size=' + str(self.args.batch_size) + \
                   ' --lfw_pairs=' + self.args.lfw_pairs + \
                   ' --warmup_steps=' + str(warmup_steps) + \
                   ' --max_steps=' + str(max_steps)

        self.cmd = self.cmd + run_script + cmd_args
Beispiel #19
0
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args, platform_util)
        # Set the num_inter_threads and num_intra_threads
        self.set_num_inter_intra_threads(num_inter_threads=platform_util.num_cores_per_socket,
                                         num_intra_threads=1)
        # Use default KMP AFFINITY values, override KMP_BLOCKTIME & enable KMP SETTINGS
        self.set_kmp_vars(kmp_settings="1", kmp_blocktime="0",
                          kmp_affinity="noverbose,warnings,respect,granularity=core,none")

        # Set env vars, if they haven't already been set
        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)
Beispiel #20
0
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args, platform_util)

        # Set the num_inter_threads and num_intra_threads
        self.set_num_inter_intra_threads()

        # Set env vars, if they haven't already been set
        set_env_var("OMP_NUM_THREADS", platform_util.num_cores_per_socket()
                    if args.num_cores == -1 else args.num_cores)

        # Set KMP env vars, but override default KMP_BLOCKTIME value
        self.set_kmp_vars(kmp_blocktime="0")
    def __init__(self, args, custom_args, platform_util):
        super(SSDVGG16ModelInitializer, self).__init__(args, custom_args,
                                                       platform_util)

        self.parse_custom_args()
        self.run_inference_sanity_checks(self.args, self.custom_args)

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        self.set_num_inter_intra_threads(
            num_inter_threads=self.args.num_inter_threads,
            num_intra_threads=self.args.num_intra_threads)

        omp_num_threads = str(int(platform_util.num_cores_per_socket / 2))\
            if self.args.precision == "int8" else platform_util.num_cores_per_socket

        set_env_var(
            "OMP_NUM_THREADS", omp_num_threads
            if self.args.num_cores == -1 else self.args.num_cores)

        script_path = os.path.join(self.args.intelai_models, self.args.mode,
                                   "eval_ssd.py")

        self.run_cmd = self.get_command_prefix(
            self.args.socket_id) + "{} {}".format(self.python_exe, script_path)

        self.run_cmd += " --input-graph={} " \
                        " --num-inter-threads={} --num-intra-threads={} ". \
            format(self.args.input_graph, self.args.num_inter_threads,
                   self.args.num_intra_threads)

        if self.args.data_num_inter_threads:
            self.run_cmd += " --data-num-inter-threads={} ".format(
                self.args.data_num_inter_threads)

        if self.args.data_num_intra_threads:
            self.run_cmd += " --data-num-intra-threads={} ".format(
                self.args.data_num_intra_threads)

        if self.args.benchmark_only:
            self.run_cmd += " --warmup-steps={} --steps={} ". \
                format(self.args.warmup_steps, self.args.steps)

        # if the data location directory is not empty, then include the arg
        if self.args.data_location and os.listdir(self.args.data_location):
            self.run_cmd += " --data-location={} ".format(
                self.args.data_location)

        if self.args.accuracy_only:
            self.run_cmd += "--accuracy-only "
Beispiel #22
0
    def run_accuracy_command(self):
        num_cores = str(self.platform_util.num_cores_per_socket())
        if self.args.num_cores != -1:
            num_cores = str(self.args.num_cores)

        set_env_var("OMP_NUM_THREADS", num_cores)

        command = "{} {} {} {}".format(self.accuracy_script_path,
                                       self.args.input_graph,
                                       self.args.data_location,
                                       self.args.model_source_dir)
        self.run_command(command)
    def __init__(self, args, custom_args=[], platform_util=None):
        super(InceptionV4ModelInitializer,
              self).__init__(args, custom_args, platform_util)

        # Environment variables
        set_env_var(
            "OMP_NUM_THREADS", platform_util.num_cores_per_socket
            if self.args.num_cores == -1 else self.args.num_cores)
        self.set_kmp_vars(kmp_blocktime="0")
        self.set_num_inter_intra_threads(
            num_inter_threads=platform_util.num_threads_per_core,
            num_intra_threads=platform_util.num_cores_per_socket)
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args, platform_util)
        # Set the num_inter_threads and num_intra_threads
        self.set_num_inter_intra_threads(num_inter_threads=platform_util.num_cores_per_socket,
                                         num_intra_threads=1)

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        # Set env vars, if they haven't already been set
        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)
Beispiel #25
0
    def __init__(self, args, custom_args, platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        self.research_dir = os.path.join(self.args.model_source_dir,
                                         "research")
        self.run_inference_sanity_checks(self.args, self.custom_args)

        # set num_inter_threads and num_intra_threads
        self.set_num_inter_intra_threads()

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)

        if self.args.accuracy_only:
            accuracy_script = os.path.join(self.args.intelai_models,
                                           self.args.mode, self.args.precision,
                                           "coco_accuracy.sh")
            if not os.path.exists(accuracy_script):
                raise ValueError("Unable to locate the Faster R-CNN accuracy "
                                 "script: {}".format(accuracy_script))
            self.run_cmd = "sh {} {} {}/coco_val.record {}".format(
                accuracy_script, self.args.input_graph,
                self.args.data_location, self.args.model_source_dir)
        else:
            self.parse_custom_args()

            benchmark_script = os.path.join(self.args.intelai_models,
                                            self.args.mode,
                                            self.args.precision, "eval.py")
            self.command_prefix = \
                self.get_command_prefix(self.args.socket_id) + self.python_exe + " " + \
                benchmark_script

            config_file_path = os.path.join(self.args.checkpoint,
                                            self.args.config_file)
            self.run_cmd = \
                self.command_prefix + \
                " --num_inter_threads " + \
                str(self.args.num_inter_threads) + \
                " --num_intra_threads " + \
                str(self.args.num_intra_threads) + \
                " --pipeline_config_path " + \
                config_file_path + \
                " --checkpoint_dir " + \
                str(args.checkpoint) + \
                " --eval_dir " + self.research_dir + \
                "/object_detection/log/eval"
Beispiel #26
0
    def __init__(self, args, custom_args, platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        self.benchmark_command = ""  # use default batch size if -1
        self.results_file_path = ""

        if self.args.batch_size == -1:
            self.args.batch_size = 128

        # Set KMP env vars, if they haven't already been set
        self.set_kmp_vars()

        # set num_inter_threads and num_intra_threads
        self.set_num_inter_intra_threads()

        benchmark_script = os.path.join(self.args.intelai_models,
                                        self.args.precision,
                                        "eval_image_classifier_inference.py")

        self.benchmark_command = self.get_numactl_command(self.args.socket_id)\
            + "python " + benchmark_script

        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)

        self.benchmark_command += " --input-graph=" + \
                                  self.args.input_graph + \
                                  " --model-name=" + \
                                  str(self.args.model_name) + \
                                  " --inter-op-parallelism-threads=" + \
                                  str(self.args.num_inter_threads) + \
                                  " --intra-op-parallelism-threads=" + \
                                  str(self.args.num_intra_threads) + \
                                  " --batch-size=" + \
                                  str(self.args.batch_size)

        # if the data location directory is not empty, then include the arg
        if self.args.data_location and os.listdir(self.args.data_location):
            self.benchmark_command += " --data-location=" + \
                                      self.args.data_location
        if self.args.accuracy_only:
            self.benchmark_command += " --accuracy-only"

            # if output results is enabled, generate a results file name and pass it to the inference script
            if self.args.output_results:
                self.results_filename = "{}_{}_{}_results_{}.txt".format(
                    self.args.model_name, self.args.precision, self.args.mode,
                    time.strftime("%Y%m%d_%H%M%S", time.gmtime()))
                self.results_file_path = os.path.join(self.args.output_dir,
                                                      self.results_filename)
                self.benchmark_command += " --results-file-path {}".format(
                    self.results_file_path)
Beispiel #27
0
    def __init__(self, args, custom_args, platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        self.research_dir = os.path.join(self.args.model_source_dir,
                                         "research")
        self.run_inference_sanity_checks(self.args, self.custom_args)

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        # set num_inter_threads and num_intra_threds
        self.set_num_inter_intra_threads(
            num_inter_threads=self.args.num_inter_threads,
            num_intra_threads=self.args.num_intra_threads)
        omp_num_threads = self.args.num_intra_threads if self.args.num_cores == -1 else self.args.num_cores
        set_env_var("OMP_NUM_THREADS", omp_num_threads)

        self.parse_custom_args()

        if self.args.accuracy_only:
            accuracy_script = os.path.join(self.args.intelai_models,
                                           self.args.mode, self.args.precision,
                                           "coco_accuracy.sh")
            if not os.path.exists(accuracy_script):
                raise ValueError("Unable to locate the Faster R-CNN accuracy "
                                 "script: {}".format(accuracy_script))
            self.run_cmd = "sh {} {} {} {}".format(accuracy_script,
                                                   self.args.input_graph,
                                                   self.args.data_location,
                                                   self.args.model_source_dir)
        else:
            benchmark_script = os.path.join(self.args.intelai_models,
                                            self.args.mode,
                                            self.args.precision,
                                            "run_frozen_graph_rcnn.py")
            self.command_prefix = \
                self.get_command_prefix(self.args.socket_id) + self.python_exe + " " + \
                benchmark_script

            self.run_cmd = \
                self.command_prefix + \
                " --num-inter-threads " + \
                str(self.args.num_inter_threads) + \
                " --num-intra-threads " + \
                str(self.args.num_intra_threads) + \
                " -g " + self.args.input_graph + \
                " -d " + self.args.data_location + \
                " -n " + str(self.args.steps)
Beispiel #28
0
    def __init__(self, args, custom_args=[], platform_util=None):
        self.args = args
        self.custom_args = custom_args
        if not platform_util:
            raise ValueError("Did not find any platform info.")

        # Set env vars, if they haven't already been set
        set_env_var(
            "OMP_NUM_THREADS",
            platform_util.num_cores_per_socket()
            if self.args.num_cores == -1 else self.args.num_cores)

        # Use default KMP variable values, but override the default KMP_BLOCKTIME value
        self.set_kmp_vars(kmp_blocktime="0")
    def run_perf_command(self):
        # Get the command previx, but numactl is added later in run_perf_command()
        self.command.append(
            self.get_command_prefix(self.args.socket_id, numactl=False))
        num_cores = str(self.platform_util.num_cores_per_socket)
        if self.args.num_cores != -1:
            num_cores = str(self.args.num_cores)

        set_env_var("OMP_NUM_THREADS", num_cores)

        if self.args.socket_id != -1:
            self.command.append("numactl")
            if self.args.socket_id:
                socket_id = self.args.socket_id
            else:
                socket_id = "0"

            if self.args.num_cores != -1:
                self.command.append("-C")
                self.command.append("+0")
                i = 1
                while i < self.args.num_cores:
                    self.command.append(",{}".format(i))
                    i += i

            self.command.append("-N")
            self.command.append("{}".format(socket_id))
            self.command.append("-m")
            self.command.append("{}".format(socket_id))

        self.command += (self.python_exe, self.perf_script_path)
        self.command += ("-m", self.args.model_source_dir)
        self.command += ("-g", self.args.input_graph)
        self.command += ("--num-intra-threads",
                         str(self.args.num_intra_threads))
        self.command += ("--num-inter-threads",
                         str(self.args.num_inter_threads))
        if self.args.number_of_steps:
            self.command += ("-x", "{}".format(self.args.number_of_steps))
        if self.args.visualize:
            self.command += ("-v")
        if self.args.timeline:
            self.command += ("-t", self.args.timeline)
        if self.args.data_location:
            self.command += ("-d", self.args.data_location)
        if self.args.evaluate_tensor:
            self.command += ("-e", self.args.evaluate_tensor)
        if self.args.print_accuracy:
            self.command += ("-p")
        self.run_command(" ".join(self.command))
Beispiel #30
0
    def __init__(self, args, custom_args=[], platform_util=None):
        super(ModelInitializer, self).__init__(args, custom_args,
                                               platform_util)

        # use default batch size if -1
        if self.args.batch_size == -1:
            self.args.batch_size = 128

        # Set KMP env vars, if they haven't already been set
        config_file_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "config.json")
        self.set_kmp_vars(config_file_path)

        # set num_inter_threads and num_intra_threads (override inter threads to 2)
        self.set_num_inter_intra_threads(num_inter_threads=2)

        script_name = "accuracy.py" if self.args.accuracy_only \
            else "benchmark.py"
        script_path = os.path.join(self.args.intelai_models, self.args.mode,
                                   script_name)
        self.command_prefix = "{} {}".format(self.python_exe, script_path)

        num_numas = self.platform_util.num_numa_nodes
        if self.args.socket_id != -1 and num_numas > 0:
            self.command_prefix = "numactl --cpunodebind={} -l {}".format(
                str(self.args.socket_id), self.command_prefix)

        set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads)

        self.parse_args()

        if not self.args.accuracy_only:
            # add args for the benchmark script
            script_args_list = [
                "input_graph", "input_height", "input_width", "batch_size",
                "input_layer", "output_layer", "num_inter_threads",
                "num_intra_threads", "warmup_steps", "steps", "precision"
            ]
            self.command_prefix = self.add_args_to_command(
                self.command_prefix, script_args_list)
        else:
            # add args for the accuracy script
            script_args_list = [
                "input_graph", "data_location", "input_height", "input_width",
                "batch_size", "input_layer", "output_layer",
                "num_inter_threads", "num_intra_threads", "precision"
            ]
            self.command_prefix = self.add_args_to_command(
                self.command_prefix, script_args_list)