Skip to content

Correct the setting of profiler to nvprof to get precise gpu_time. #1214

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

Merged
merged 1 commit into from
Dec 24, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
31 changes: 15 additions & 16 deletions api/common/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ def run(self, cmd):
parse_status, gpu_time = self._parse_logs(stdout.split("\n"))
if parse_status:
return gpu_time
print("Runing Error:\n {}".format(stdout))
print("Running Error:\n {}".format(stdout))
return 0.0

def _nvprof(self, cmd):
#return system.run_command("nvprof --profile-from-start off {}".format(
# cmd))
return system.run_command("nvprof {}".format(cmd))
return system.run_command("nvprof --profile-from-start off {}".format(
cmd))

def _parse_logs(self, logs):
line_from = None
Expand Down Expand Up @@ -98,13 +97,12 @@ def run(self, cmd):
parse_status, gpu_time = self._parse_logs(stdout.split("\n"))
if parse_status:
return gpu_time
print("Runing Error:\n {}".format(stdout))
print("Running Error:\n {}".format(stdout))
return 0.0

def _nsight(self, cmd):
#return system.run_command(
# "nsys nvprof --profile-from-start=off -o tmp.qdrep {}".format(cmd))
return system.run_command("nsys nvprof -o tmp.qdrep {}".format(cmd))
return system.run_command(
"nsys nvprof --profile-from-start=off -o tmp.qdrep {}".format(cmd))

def _parse_logs(self, logs):
kernel_line_from = None
Expand Down Expand Up @@ -176,16 +174,17 @@ def launch(benchmark_script, benchmark_script_args, with_nvprof=False):
"""

def _set_profiler(args, value):
for i in range(len(args)):
if args[i] == "--profiler":
args[i + 1] = value
break
if i >= len(args):
if "--profiler" in args:
for i in range(len(args)):
if args[i] == "--profiler":
args[i + 1] = value
break
else:
args.append("--profiler")
args.append(value)

#if with_nvprof:
# _set_profiler(benchmark_script_args, "nvprof")
if with_nvprof:
_set_profiler(benchmark_script_args, "nvprof")
cmd = "{} {} {}".format(sys.executable, benchmark_script,
" ".join(benchmark_script_args))
if with_nvprof:
Expand All @@ -194,7 +193,7 @@ def _set_profiler(args, value):
else:
runner = NvprofRunner()
gpu_time = runner.run(cmd)
#_set_profiler(benchmark_script_args, "none")
_set_profiler(benchmark_script_args, "none")
return gpu_time
else:
stdout, exit_code = system.run_command(cmd)
Expand Down
2 changes: 1 addition & 1 deletion api/run_op_benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ install_package() {
installed_version=`python -c "import ${package_name}; print(${package_name}.__version__)"`
if [ "${installed_version}" > "${package_version}" ]; then
echo "-- ${package_name} ${installed_version} (newer than ${package_version}) is already installed."
elif [ "${installed_version}" = "${package_version}" ]; then
elif [ "${installed_version}" == "${package_version}" ]; then
echo "-- ${package_name} ${package_version} is already installed."
else
echo "-- Update ${package_name}: ${installed_version} -> ${package_version}"
Expand Down