pytorch

Форк
0
/
process_metrics.py 
50 строк · 1.8 Кб
1
"""
2
This file will take the csv outputs from server.py, calculate the mean and
3
variance of the warmup_latency, average_latency, throughput and gpu_util
4
and write these to the corresponding `results/output_{batch_size}_{compile}.md`
5
file, appending to the file if it exists or creatng a new one otherwise.
6
"""
7

8
import argparse
9
import os
10

11
import pandas as pd
12

13
if __name__ == "__main__":
14
    parser = argparse.ArgumentParser(description="Parse output files")
15
    parser.add_argument("--csv", type=str, help="Path to csv file")
16
    parser.add_argument("--name", type=str, help="Name of experiment")
17
    args = parser.parse_args()
18

19
    input_csv = "./results/" + args.csv
20
    df = pd.read_csv(input_csv)
21

22
    batch_size = int(os.path.basename(args.csv).split("_")[1])
23
    compile = os.path.basename(args.csv).split("_")[-1].split(".")[0]
24

25
    # Calculate mean and standard deviation for a subset of metrics
26
    metrics = ["warmup_latency", "average_latency", "throughput", "gpu_util"]
27
    means = dict()
28
    stds = dict()
29

30
    for metric in metrics:
31
        means[metric] = df[metric].mean()
32
        stds[metric] = df[metric].std()
33

34
    output_md = f"results/output_{batch_size}_{compile}.md"
35
    write_header = os.path.isfile(output_md) is False
36

37
    with open(output_md, "a+") as f:
38
        if write_header:
39
            f.write(f"## Batch Size {batch_size} Compile {compile}\n\n")
40
            f.write(
41
                "| Experiment | Warmup_latency (s) | Average_latency (s) | Throughput (samples/sec) | GPU Utilization (%) |\n"
42
            )
43
            f.write(
44
                "| ---------- | ------------------ | ------------------- | ------------------------ | ------------------- |\n"
45
            )
46

47
        line = f"| {args.name} |"
48
        for metric in metrics:
49
            line += f" {means[metric]:.3f} +/- {stds[metric]:.3f} |"
50
        f.write(line + "\n")
51

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.