mindie推理大语言模型问题及解决方法汇总

问题说明

使用功能mindie 1.0 RC2推理大语言模型,遇到不少问题,记录下解决思路。

我的硬件是910B4。

问题及解决

问题1

在docker内启动mindie时终端报错

shell 复制代码
Fatal Python error: PyThreadState_Get: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL)

查看logs/pythonlog.log.xxxx

复制代码
File "/usr/local/Ascend/atb-models/atb_llm/utils/file_utils.py", line 110, in check_owner
raise argparse.ArgumentTypeError("The path is not owned by current user or root")
argparse.ArgumentTypeError: The path is not owned by current user or root

问题分析:模型目录是我从外部映射进去的,目录的所有者是一个叫guest的用户,而docker内的用户是root。

解决方法:将日志目录所有者和组改为root

复制代码
chown root:root /path/to/directory -R

问题2

在docker内启动mindie时终端报错

shell 复制代码
Fatal Python error: PyThreadState_Get: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL)
Python runtime state: finalizing (tstate=0x0000ffff8401d570)

查看logs/pythonlog.log.xxxx

shell 复制代码
File "/root/.cache/huggingface/modules/transformers_modules/Baichuan2-13B-Base/tokenization_baichuan.py", line 7, in <module>
import sentencepiece as spm
ModuleNotFoundError: No module named 'sentencepiece'

问题分析:我加载的事baichuan2-13b模型,该模型依赖sentencepiece这个组件

解决方法:

shell 复制代码
pip install sentencepiece

问题3

在docker内启动mindie时终端报错

shell 复制代码
Exception:unsupported type: torch.bfloat16

问题分析:我加载的模型是bfloat16的,而mindie貌似不支持,只能支持fp16.具体类型可以从模型下的config.json中看到

解决办法:将模型转换为fp16类型

python 复制代码
import argparse
import os
import torch


def convert_bin2st_from_pretrained(model_path, out_path):
    from transformers import AutoModelForCausalLM, AutoTokenizer
    tokenizer = AutoTokenizer.from_pretrained(model_path,
        revision="v2.0",
        use_fast=False,
        trust_remote_code=True)
    model = AutoModelForCausalLM.from_pretrained(
        pretrained_model_name_or_path=model_path,
        low_cpu_mem_usage=True,
        trust_remote_code=True,
        torch_dtype=torch.float16)  #这里指定float16格式
    print(f"Saving the target model to {out_path}")
    model.save_pretrained(out_path, safe_serialization=True)
    print(f"Saving the tokenizer to {out_path}")
    tokenizer.save_pretrained(out_path)

if __name__ == '__main__':
    print(f"covert  model  into safetensor")
    convert_bin2st_from_pretrained("./Qwen2-72B-Instruct", "./Qwen2-72B-Instruct_fp16")

转换完毕,将./Qwen2-72B-Instruct/tokenizer.json手动复制到./Qwen2-72B-Instruct_fp16。其它文件都全了。

问题4

在docker内启动mindie时终端报错

shell 复制代码
Fatal Python error: PyThreadState_Get: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL)
Python runtime state: finalizing (tstate=0x0000ffffac01d570)

查看logs/pythonlog.log.xxxx

复制代码
File "/usr/local/Ascend/atb-models/atb_llm/models/qwen2/router_qwen2.py", line 39, in checkout_config_qwen
if value < min_val or value > max_val:
TypeError: '<' not supported between instances of 'NoneType' and 'int'

跟踪发现是router_qwen2.py中获取的sliding_window为None.这个问题是我用上一步的方法转换模型引起的。

解决方法:在转换后的模型目录中config.json中将sliding_window字段设置为131072。

总结

很多问题表现为GIL相关的问题,实际都是业务进程出错了,真实原因往往在logs/pythonlog.log.xxxx中。

相关推荐
carpell15 分钟前
【语义分割专栏】先导篇:评价指标(PA,CPA,IoU,mIoU,FWIoU,F1)
人工智能·计算机视觉·语义分割
想要成为计算机高手18 分钟前
OpenVLA:开源的视觉-语言-动作模型
ai·自然语言处理·开源·大模型·视觉处理·openvla
狂奔solar1 小时前
Westlake-Omni 情感端音频生成式输出模型
人工智能
idkmn_1 小时前
Daily AI 20250513 (集成学习及其与联邦学习的区别)
人工智能·神经网络·机器学习·集成学习
微刻时光1 小时前
影刀RPA网页自动化总结
运维·人工智能·python·低代码·自动化·rpa·影刀rpa
三天不学习1 小时前
浅析AI大模型为何需要向量数据库?【入门基础】
数据库·人工智能·欧氏距离·向量数据库·余弦相似度
WenGyyyL2 小时前
研读论文——《用于3D工业异常检测的自监督特征自适应》
人工智能·python·深度学习·机器学习·计算机视觉·3d
fydw_7152 小时前
音频生成技术的前沿探索:从语音合成到智能Podcast
人工智能·音视频·语音识别
选型宝2 小时前
腾讯怎样基于DeepSeek搭建企业应用?怎样私有化部署满血版DS?直播:腾讯云X DeepSeek!
人工智能·ai·云计算·腾讯云·选型宝
多巴胺与内啡肽.2 小时前
OpenCV进阶操作:人脸检测、微笑检测
人工智能·opencv·计算机视觉