简体   繁体   English

拥抱面孔 - PyTorch RuntimeError:nll_loss_forward_reduce_cuda_kernel_2d_index 未为 Int 实现

[英]Hugging Face - PyTorch RuntimeError : nll_loss_forward_reduce_cuda_kernel_2d_index not implemented for Int

I attempted to fine-tune the Wav2vec2 model for an audio classification task by following the tutorial at https://huggingface.co/docs/transformers/tasks/audio_classification and copying and pasting the code provided.我试图通过遵循https://huggingface.co/docs/transformers/tasks/audio_classification上的教程并复制和粘贴所提供的代码来为音频分类任务微调Wav2vec2 model。

However, when I trained the model, I encountered the following error:但是,我在训练model的时候遇到了如下错误:

nll_loss_forward_reduce_cuda_kernel_2d_index not implemented for Int.

I believe the problem may lie with PyTorch .我相信问题可能在于PyTorch It seems to be working on Ubuntu WSL 22.04 , but not on Powershell .它似乎适用于Ubuntu WSL 22.04 ,但不适用于Powershell

My system specifications include:我的系统规格包括:

- Powershell
- datasets 2.8.0
- transformers 4.25.1
- torch                   1.13.1+cu117
- torchaudio              0.13.1+cu117
- torchvision             0.14.1+cu117

How can I resolve this issue?我该如何解决这个问题?

Convert your target dtype to torch.int64 .将您的目标 dtype 转换为torch.int64

I received the same error when my target dtype was torch.int32 .当我的目标 dtype 是torch.int32时,我收到了同样的错误。 I resolved the issue by adding the following line to my code:我通过在我的代码中添加以下行解决了这个问题:

target = target.to(torch.int64)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RuntimeError:“nll_loss_forward_reduce_cuda_kernel_2d_index”未为“Int”实现:Pytorch - RuntimeError: "nll_loss_forward_reduce_cuda_kernel_2d_index" not implemented for 'Int': Pytorch PyTorch RuntimeError:“nll_loss_forward_reduce_cuda_kernel_2d_index”未为“Int”实现 - PyTorch RuntimeError: "nll_loss_forward_reduce_cuda_kernel_2d_index" not implemented for 'Int' PyTorch:_thnn_nll_loss_forward未针对手电筒类型实现。 - PyTorch: _thnn_nll_loss_forward is not implemented for type torch.LongTensor Pytorch - 运行时错误:标量类型为 Long 的预期对象,但在调用 _thnn_nll_loss_forward 时参数 #2 'target' 的标量类型为 Float - Pytorch - RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'target' in call to _thnn_nll_loss_forward RuntimeError:没有为类型为torch.cuda.LongTensor实现_thnn_mse_loss_forward - RuntimeError: _thnn_mse_loss_forward is not implemented for type torch.cuda.LongTensor 拥抱面(pytorch 变压器)上的 GPT2 运行时错误:只能为标量输出隐式创建 grad - GPT2 on Hugging face(pytorch transformers) RuntimeError: grad can be implicitly created only for scalar outputs 在 PyTorch 中,nll_loss 的输入是什么? - In PyTorch, what is the input into nll_loss? RuntimeError: 预期 object 的标量类型 Long 但在调用 _thnn_nll_loss_forward 时获得了参数 #2 'target' 的标量类型 Float - RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'target' in call to _thnn_nll_loss_forward Pytorch nll_loss 在训练循环期间返回恒定损失 - Pytorch nll_loss returning a constant loss during training loop RuntimeError:pytorch中的cuda运行时错误(8) - RuntimeError: cuda runtime error (8) in pytorch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM