从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()