torch_npu.profiler.profile采集不到npu的信息
收藏回复举报
torch_npu.profiler.profile采集不到npu的信息
新人帖
发表于2024-01-16 19:29:01
0 查看

 

import mindspore 

import torch_npu 

from mindformers import AutoConfig, AutoModel, AutoTokenizer, TextStreamer 

path="/home/ma-user/work/files/chatglm3-6b_ms" 

mindspore.set_context(mode=0, device_id=0,device_target="Ascend") 

tokenizer = AutoTokenizer.from_pretrained(path) 

 

model = AutoModel.from_pretrained(path) 

streamer = TextStreamer(tokenizer) 

 

def inference(): 

    inputs = tokenizer("请用python实现加法")["input_ids"] 

    outputs = model.generate(inputs, streamer=streamer, max_length=512, do_sample=False, top_k=3) 

    response = tokenizer.decode(outputs) 

    print(response) 

 

experimental_config = torch_npu.profiler._ExperimentalConfig(profiler_level=torch_npu.profiler.ProfilerLevel.Level2,  

aic_metrics=torch_npu.profiler.AiCMetrics.Memory, 

l2_cache=True)  

 

with torch_npu.profiler.profile( 

  activities=[ 

    torch_npu.profiler.ProfilerActivity.CPU,    # 采集框架侧数据开关 

    torch_npu.profiler.ProfilerActivity.NPU     # 采集NPU数据开关 

    ], 

    with_stack=True,   #采集torch 算子的函数调用栈的开关,该参数选填,默认关闭 

    record_shapes=True,   #采集torch 算子的input shape和input type的开关,该参数选填,默认关闭  

    profile_memory=True,   #采集memory相关数据的开关,该参数选填,默认关闭     

    experimental_config=experimental_config,   #该参数选填,默认为Level0     

    on_trace_ready=torch_npu.profiler.tensorboard_trace_handler("/home/ma-user/work/files/profile_llm/result_Memory")    #导出tensorboard可呈现的数据形式,可指定worker_name,默认为:{host名称}_{进程id} 

) as prof: 

    inference() 

    prof.step() 

collection_device_0.log

2024-01-16 19:16:55 [WARNING] [base_model.py:59] - Failed to connect database, please check database of step_trace.  

2024-01-16 19:16:55 [WARNING] [base_model.py:59] - Failed to connect database, please check database of step_trace.  

2024-01-16 19:16:55 [INFO] [profiling_scene.py:38] - Current scene of data is based on single_op 

2024-01-16 19:16:55 [WARNING] [base_model.py:59] - Failed to connect database, please check database of step_trace.  

2024-01-16 19:16:55 [WARNING] [base_model.py:59] - Failed to connect database, please check database of step_trace.  

2024-01-16 19:16:55 [INFO] [profiling_scene.py:38] - Current scene of data is based on single_op 

2024-01-16 19:16:55 [WARNING] [base_model.py:63] - Table step_trace_data not found. 

2024-01-16 19:16:55 [WARNING] [base_model.py:63] - Table step_trace_data not found. 

2024-01-16 19:16:55 [WARNING] [meta_condition_manager.py:341] - The accumulated result of comparison fields is equal to 0. 

2024-01-16 19:16:55 [WARNING] [meta_condition_manager.py:341] - The accumulated result of comparison fields is equal to 0. 

2024-01-16 19:16:55 [INFO] [msprof_job_summary.py:64] - Host data not exists, won't export summary timeline data 

2024-01-16 19:16:56 [WARNING] [base_model.py:63] - Table step_trace_data not found. 

2024-01-16 19:16:56 [WARNING] [base_model.py:63] - Table step_trace_data not found. 

2024-01-16 19:16:56 [INFO] [profiling_scene.py:38] - Current scene of data is based on single_op 

2024-01-16 19:16:56 [WARNING] [base_model.py:63] - Table step_trace_data not found. 

2024-01-16 19:16:56 [WARNING] [base_model.py:63] - Table step_trace_data not found. 

2024-01-16 19:16:56 [INFO] [profiling_scene.py:38] - Current scene of data is based on single_op 

2024-01-16 19:16:56 [WARNING] [base_model.py:63] - Table step_trace_data not found. 

2024-01-16 19:16:56 [WARNING] [base_model.py:63] - Table step_trace_data not found. 

2024-01-16 19:16:57 [WARNING] [pipeline_overlap_viewer.py:47] - Op summary data not found, no need to calculate the overlap. 

2024-01-16 19:16:57 [INFO] [msprof_job_summary.py:64] - Host data not exists, won't export summary timeline data 

本帖最后由 匿名用户2024/01/16 19:34:56 编辑

我要发帖子