#1035 怎么在网络集群的Npu调试任务调用npu算力进行运算,模型是基于pytorch的

Open
created 1 year ago by muyidan · 13 comments
muyidan commented 1 year ago
<!-- 为了更有效地识别与解决您的问题,请尽可能的补充如下信息 --> ### 问题描述 怎么在网络集群的Npu调试任务调用npu算力进行运算,自然语言模型是基于pytorch的,安装了cann社区版以及torch_npu模块,但是显示torch不支持Npu ### 相关环境(GPU/NPU) npu ### 相关集群(启智/智算) 智算 ### 任务类型(调试/训练/推理) 调试 ### 任务名 muyid202304182229426 ### 日志说明或问题截图 '''import torch import torch.utils.data.distributed from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModelForCausalLM #from torch_npu.contrib import transfer_to_npu # 初始化tokenizer和model tokenizer = AutoTokenizer.from_pretrained("databricks/dolly-v2-12B") model = AutoModelForCausalLM.from_pretrained("/home/ma-user/work/modle-unzip/dolly2_model/dolly2") # 将模型和数据转换为Ascend格式 device = torch.device("npu" if torch.npu.is_available() else "cpu") model = model.to(device) input_text = "Hello, how are you?" input_ids = tokenizer.encode(input_text, return_tensors='pt').to(device) # 在Ascend AI芯片上进行计算 with torch.no_grad(): output = model.generate(input_ids) # 转换回CPU格式并输出结果 output_text = tokenizer.decode(output[0], skip_special_tokens=True) print(output_text) from torch_npu.contrib import transfer_to_npu''' 错误代码 '''--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-1-0d242d12becc> in <module> 9 10 # 将模型和数据转换为Ascend格式 ---> 11 device = torch.device("npu" if torch.npu.is_available() else "cpu") 12 model = model.to(device) 13 input_text = "Hello, how are you?" AttributeError: module 'torch' has no attribute 'npu'''' ### 期望的解决方案或建议 torch如何支持Npu的教程,或者在官方镜像源中安装相应的环境
muyidan started working 1 year ago
同问
torch可以使用npu吗?呃,我一直以为npu只能使用华为的mindspore...
muyidan commented 1 year ago
Poster
> torch可以使用npu吗?呃,我一直以为npu只能使用华为的mindspore... pytorch是较为流行的一个框架,华为肯定会接入,这是教程,但是我还没有整明白,你可以试着看看。https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/63RC1alpha002/softwareinstall/instg/instg_000035.html
> > torch可以使用npu吗?呃,我一直以为npu只能使用华为的mindspore... > > pytorch是较为流行的一个框架,华为肯定会接入,这是教程,但是我还没有整明白,你可以试着看看。https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/63RC1alpha002/softwareinstall/instg/instg_000035.html > 好的,我看看
> torch可以使用npu吗?呃,我一直以为npu只能使用华为的mindspore... 我也是才知道
> > torch可以使用npu吗?呃,我一直以为npu只能使用华为的mindspore... > > pytorch是较为流行的一个框架,华为肯定会接入,这是教程,但是我还没有整明白,你可以试着看看。https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/63RC1alpha002/softwareinstall/instg/instg_000035.html > 感谢分享,我也是现在才知道
> > torch可以使用npu吗?呃,我一直以为npu只能使用华为的mindspore... > > 我也是才知道 我也是
> > > torch可以使用npu吗?呃,我一直以为npu只能使用华为的mindspore... > > > > 我也是才知道 > > 我也是 哈哈哈,可以的
liuzx added the
need review
label 11 months ago
> > torch可以使用npu吗?呃,我一直以为npu只能使用华为的mindspore... > > pytorch是较为流行的一个框架,华为肯定会接入,这是教程,但是我还没有整明白,你可以试着看看。https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/63RC1alpha002/softwareinstall/instg/instg_000035.html > 我才知道这个,666
不知道楼主解决这个问题没有
不知道楼主解决这个问题没有
pytorch DDP提交训练任务的时候,怎么用shell或者torchrun进行多机多卡的任务提交啊,难道只能手动创建进程么?
Paradise commented 4 days ago
1
Sign in to join this conversation.
Loading…
There is no content yet.