Skip to content

Add device information in the report json file #66

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 3 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def gen_basic_dict(library, algorithm, stage, params, data, alg_instance=None,
'library': library,
'algorithm': algorithm,
'stage': stage,
'device': params.device,
'input_data': {
'data_format': params.data_format,
'data_order': params.data_order,
Expand Down
38 changes: 28 additions & 10 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,37 +95,55 @@ def get_omp_env():
return omp_env


def parse_lscpu_lscl_info(command_output):
command_output = command_output.strip().split('\n')
for i in range(len(command_output)):
command_output[i] = command_output[i].split(':')
return {line[0].strip(): line[1].strip() for line in command_output}


def get_hw_parameters():
hw_params = {}

if 'Linux' in platform.platform():
# get CPU information
lscpu_info, _ = read_output_from_command('lscpu')
# remove excess spaces in CPU info output
while ' ' in lscpu_info:
lscpu_info = lscpu_info.replace(' ', ' ')
lscpu_info = lscpu_info.split('\n')
for i in range(len(lscpu_info)):
lscpu_info[i] = lscpu_info[i].split(': ')
hw_params.update(
{'CPU': {line[0]: line[1] for line in lscpu_info}})
hw_params.update({'CPU': parse_lscpu_lscl_info(lscpu_info)})
if 'CPU MHz' in hw_params['CPU'].keys():
del hw_params['CPU']['CPU MHz']

# get RAM size
mem_info, _ = read_output_from_command('free -b')
mem_info = mem_info.split('\n')[1]
while ' ' in mem_info:
mem_info = mem_info.replace(' ', ' ')
mem_info = int(mem_info.split(' ')[1]) / 2 ** 30
hw_params.update({'RAM size[GB]': mem_info})
# get GPU information

# get Intel GPU information
try:
lsgpu_info, _ = read_output_from_command(
'lscl --device-type=gpu --platform-vendor=Intel')
platform_num = 0
start_idx = lsgpu_info.find('Platform ')
while start_idx >= 0:
start_idx = lsgpu_info.find(':', start_idx) + 1
end_idx = lsgpu_info.find('Platform ', start_idx)
platform_info = parse_lscpu_lscl_info(lsgpu_info[start_idx:end_idx])
hw_params.update({f'GPU Intel platform {platform_num + 1}': platform_info})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why info about platform_num ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to device_num

platform_num += 1
start_idx = end_idx
except (FileNotFoundError, json.JSONDecodeError):
pass

# get Nvidia GPU information
try:
gpu_info, _ = read_output_from_command(
'nvidia-smi --query-gpu=name,memory.total,driver_version,pstate '
'--format=csv,noheader')
gpu_info = gpu_info.split(', ')
hw_params.update({
'GPU': {
'GPU Nvidia': {
'Name': gpu_info[0],
'Memory size': gpu_info[1],
'Performance mode': gpu_info[3]
Expand Down