从NVIDIA Nsight Compute内置的Sections中提取出所有的Metric及名称

从NVIDIA Nsight Compute内置的Sections中提取出所有的Metric及名称

从NVIDIA Nsight Compute内置的Sections中提取出所有的Metric及名称

1.获取存储路径

/usr/local/cuda/bin/ncu --list-sections --csv --log-file sections.csv
cat sections.csv

输出

"Identifier","Display Name","Enabled","Filename"
"ComputeWorkloadAnalysis","Compute Workload Analysis","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/ComputeWorkloadAnalysis.section"
"InstructionStats","Instruction Statistics","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/InstructionStatistics.section"
"LaunchStats","Launch Statistics","yes","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/LaunchStatistics.section"
"MemoryWorkloadAnalysis","Memory Workload Analysis","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/MemoryWorkloadAnalysis.section"
"MemoryWorkloadAnalysis_Chart","Memory Workload Analysis Chart","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/MemoryWorkloadAnalysis_Chart.section"
"MemoryWorkloadAnalysis_Tables","Memory Workload Analysis Tables","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/MemoryWorkloadAnalysis_Tables.section"
"NumaAffinity","NUMA Affinity","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/NumaAffinity.section"
"Nvlink","NVLink","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/Nvlink.section"
"Nvlink_Tables","NVLink Tables","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/Nvlink_Tables.section"
"Nvlink_Topology","NVLink Topology","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/Nvlink_Topology.section"
"Occupancy","Occupancy","yes","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/Occupancy.section"
"SchedulerStats","Scheduler Statistics","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/SchedulerStatistics.section"
"SourceCounters","Source Counters","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/SourceCounters.section"
"SpeedOfLight","GPU Speed Of Light Throughput","yes","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/SpeedOfLight.section"
"SpeedOfLight_HierarchicalDoubleRooflineChart","GPU Speed Of Light Hierarchical Roofline Chart (Double Precision)","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/SpeedOfLight_HierarchicalDoubleRooflineChart.section"
"SpeedOfLight_HierarchicalHalfRooflineChart","GPU Speed Of Light Hierarchical Roofline Chart (Half Precision)","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/SpeedOfLight_HierarchicalHalfRooflineChart.section"
"SpeedOfLight_HierarchicalSingleRooflineChart","GPU Speed Of Light Hierarchical Roofline Chart (Single Precision)","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/SpeedOfLight_HierarchicalSingleRooflineChart.section"
"SpeedOfLight_HierarchicalTensorRooflineChart","GPU Speed Of Light Hierarchical Roofline Chart (Tensor Core)","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/SpeedOfLight_HierarchicalTensorRooflineChart.section"
"SpeedOfLight_RooflineChart","GPU Speed Of Light Roofline Chart","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/SpeedOfLight_RooflineChart.section"
"WarpStateStats","Warp State Statistics","no","/root/Documents/NVIDIA Nsight Compute/2023.1.1/Sections/WarpStateStatistics.section"

2.解析脚本


import pandas as pd
import re

def find_all_label_name_pairs(_path):
    text=open(_path,"r").readlines()
    Identifier=""
    DisplayName=""
    Description=""
    
    Label=""
    Name=""
    Expression=""
    
    label_name_pairs=[]
    total_size=len(text)
    uuid_cache=set()
    for idx,line in enumerate(text):
        line=line.strip()
        if Identifier=="" and line.find("Identifier")>=0:
            Identifier="".join(line.split(":")[1:]).strip().replace(","," ").replace('"',"")        
        elif line.find("DisplayName")>=0:
            DisplayName="".join(line.split(":")[1:]).strip().replace(","," ").replace('"',"")
        elif line.find("Description")>=0:
            Description="".join(line.split(":")[1:]).strip().replace(","," ").replace('"',"")
        elif line.find("Label")>=0:
            Label=":".join(line.split(":")[1:]).strip().replace('"',"")
            Name=""
        elif line.find("Name")>=0:
            Name=":".join(line.split(":")[1:]).strip().replace('"',"")   
        elif line.find("Expression")>=0:
            Expression=":".join(line.split(":")[1:]).strip().replace('"',"")
            
        if Label!="" and Name!="":
            uuid=f"{Label}{Name}"
            if uuid not in uuid_cache:
                uuid_cache.add(uuid)
                MinArch=set()
                MaxArch=set()
                for i in range(idx+1,total_size):
                    if text[i].find("Label")>=0 or text[i].find("Name")>=0:
                        break
                    elif text[i].find("MinArch")>=0:
                        MinArch.add(text[i].split(":")[1].strip())
                    elif text[i].find("MaxArch")>=0:
                        MaxArch.add(text[i].split(":")[1].strip())
                MinArch="_".join(MinArch).strip()
                MaxArch="_".join(MaxArch).strip()
                label_name_pairs.append((Identifier,DisplayName,Description,Label,Name,Name.split(".")[0],MinArch,MaxArch))
            Label=""
            Name=""
            Description=""
        elif Expression!="" and Name!="":
            uuid=f"{Expression}{Name}"
            if uuid not in uuid_cache:
                uuid_cache.add(uuid)
                MinArch=set()
                MaxArch=set()
                MinArch="_".join(MinArch).strip()
                MaxArch="_".join(MaxArch).strip()
                label_name_pairs.append((Identifier,DisplayName,Description,Label,Name,Expression,MinArch,MaxArch))
            Expression=""
            Label=""
            Name=""
            Description=""
            
    return label_name_pairs

import glob
fo=open("NVIDIA Nsight Compute Sections.csv","w")
fo.write("Identifier,DisplayName,Description,Label,Name,Metric/Expression,MinArch,MaxArch\n")
for _path in glob.glob("/root/Documents/NVIDIA\ Nsight\ Compute/2023.1.1/Sections/*.section"):
    print(_path)
    label_name_pairs=find_all_label_name_pairs(_path)
    for pair in label_name_pairs:
        print(pair)
        fo.write(",".join(pair)+"\n")
fo.close()

相关推荐

  1. python04_找某个区间所有素数

    2024-07-13 21:22:03       47 阅读
  2. 字符串所有偶数个数

    2024-07-13 21:22:03       30 阅读
  3. 用python实现提取word所有图片

    2024-07-13 21:22:03       54 阅读
  4. 提取文本所有图片链接地址

    2024-07-13 21:22:03       23 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-13 21:22:03       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-13 21:22:03       71 阅读
  3. 在Django里面运行非项目文件

    2024-07-13 21:22:03       58 阅读
  4. Python语言-面向对象

    2024-07-13 21:22:03       69 阅读

热门阅读

  1. 3011.判断一个数组是否可以变为有序

    2024-07-13 21:22:03       23 阅读
  2. Spring是如何管理事务的?

    2024-07-13 21:22:03       24 阅读
  3. Kylin的智能优化:Cube自动优化的奥秘

    2024-07-13 21:22:03       18 阅读
  4. ES证书过期替换方案

    2024-07-13 21:22:03       24 阅读
  5. 深度学习调参

    2024-07-13 21:22:03       18 阅读
  6. 算法练习第29天|1005.K次取反后最大化的数组和

    2024-07-13 21:22:03       16 阅读
  7. C++ STL sort用法

    2024-07-13 21:22:03       19 阅读
  8. 什么是稀疏化

    2024-07-13 21:22:03       17 阅读
  9. centos清空history

    2024-07-13 21:22:03       12 阅读
  10. 宪法学学习笔记(个人向) Part.5

    2024-07-13 21:22:03       18 阅读