体育游戏app平台在 start 函数之后的恣意位置添加-开云·kaiyun(全站)体育官方网站/网页版 登录入口
一、问题描写体育游戏app平台
1.在进行sam模子挪动到昇腾的时辰存在精度问题,模子相连:
https://github.com/facebookresearch/segment-anything
2 .两台机器上磨练loss图对比,发现从一滥觞磨练的时辰就出现了判袂,从图中对比看出来npu第一步就滥觞莫得向下不休,而gpu是向下不休。
二、问题分析进程
1.准备dump精度对比望望辩别,使用Ascend开源仓的msprobe器用进行精度对比
debug/accuracy_tools/msprobe/docs/01.installation.md · Ascend/mstt - Gitee.com
器用安设高歌:
pip install mindstudio-probe
2.然后在磨练剧本部分加代码,按照示例添加代码
使用示例可参见Ascend开源仓的PyTorch 场景的精度数据集会示例代码 2.1 快速上手和 2.2 集会无缺的前反向数据。
3.添加start函数
功能讲明:启动精度数据集会,在模子启动化之后的位置添加,需要与 stop 函数全部添加在 for 轮回内。
debugger.start(model=None)
model:指定具体的 torch.nn.Module,默许未成立,level 成立为"L0"或"mix"时,必须在该接口或 PrecisionDebugger 接口中成立该参数。 本接口中的 model 比 PrecisionDebugger 中 model 参数优先级更高,会粉饰 PrecisionDebugger 中的 model 参数。
4.添加stop函数
功能讲明:罢手精度数据集会,在 start 函数之后的恣意位置添加,若需要 dump 反向数据,则需要添加在反向计较代码(如,loss.backward)之后。
debugger.stop()from msprobe.pytorch import PrecisionDebuggedebugger = PrecisionDebugger(config_path='./config.json')debugger.start() # 一般在磨练轮回发轫启动器用 # 轮回体debugger.stop() # 一般在磨练轮回末尾适度器用debugger.step() # 在磨练轮回的终末需要重置器用,非轮回场景不需要
这里的config.json也不错开采好多种类型,这里采选tensor花式和mix级。
{ "task": "tensor", "dump_path": "/home/data_dump", "rank": [], "step": [], "level": "mix", "tensor": { "scope": [], "list":[], "data_mode": ["all"] }}
5.凯旋运行磨练剧本,在数据dump下来之后 跟gpu的精度进行对比。
npu在这里丢了image_embedding的梯度,因为该模子用到了Reg_op(RepeatInterleaveGrad)这个算子,接下来分析cann包是否有这个算子 发现是有的 然则通过插足python后调用torch_npu.repeat_interleave_backward_tensor这个函数,发现调用失败。
调用失败闪现 :AttributeError: module 'torch_npu' has no attribute 'repeat_interleave_backward_tensor'
6.稽查torch_npu版块,发现是2.1post3和pytorch2.1版块不配套。
三、科罚要道
通过稽查昇腾torch_npu的版块与pytorch的配套表,遴荐对应的torch_npu版块:https://gitee.com/ascend/pytorch
采选配套版块后,函数调用得胜体育游戏app平台,loss图也开阔。