Deleting a branch is permanent. It CANNOT be undone. Continue?
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》
问题描述
怎么在网络集群的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)
in
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的教程,或者在官方镜像源中安装相应的环境
同问
torch可以使用npu吗?呃,我一直以为npu只能使用华为的mindspore...
pytorch是较为流行的一个框架,华为肯定会接入,这是教程,但是我还没有整明白,你可以试着看看。https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/63RC1alpha002/softwareinstall/instg/instg_000035.html
好的,我看看
我也是才知道
感谢分享,我也是现在才知道
我也是
哈哈哈,可以的
我才知道这个,666
不知道楼主解决这个问题没有
不知道楼主解决这个问题没有
pytorch DDP提交训练任务的时候,怎么用shell或者torchrun进行多机多卡的任务提交啊,难道只能手动创建进程么?
1