# Error from CUDA on audio classification

**URL:** <https://discuss.huggingface.co/t/error-from-cuda-on-audio-classification/33234>\
**Category:** Beginners\
**Created:** [March 7, 2023, 10:37am UTC](https://discuss.huggingface.co/t/error-from-cuda-on-audio-classification/33234 "2023-03-07T10:37:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmoti](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@dmoti](https://discuss.huggingface.co/u/dmoti)\
**Post date:** [March 7, 2023, 10:37am UTC](https://discuss.huggingface.co/t/error-from-cuda-on-audio-classification/33234/1 "2023-03-07T10:37:07Z")

</div>

Hi,

I’m trying to follow the instructions in this page:

> **[Audio classification](https://huggingface.co/docs/transformers/tasks/audio_classification)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

and I encounter an error when I try to train:  
`RuntimeError: "nll_loss_forward_reduce_cuda_kernel_2d_index" not implemented for 'Int'`

the error is in this function:  
return torch.\_C.\_nn.cross\_entropy\_loss(input, target, weight, \_Reduction.get\_enum(reduction), ignore\_index, label\_smoothing

I tried to cast the label to ‘int64’ and got the same error (the cast works, when I try to change to float32 I see that the error is changed to float)

I’m running with  
windows server 2022  
python 3.10.10  
pytorch 1.13.1  
cuda 11.7 (the gpu is a10)  
transformers 4.26.1

thanks

---

<div class="post-metadata">

**Author:** ![dmoti](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@dmoti](https://discuss.huggingface.co/u/dmoti)\
**Post date:** [March 8, 2023, 1:24pm UTC](https://discuss.huggingface.co/t/error-from-cuda-on-audio-classification/33234/2 "2023-03-08T13:24:10Z")

</div>

I’ve found a workaround, I installed WSL and run everything from there, it works

---

<div class="post-metadata">

**Author:** ![xavialex](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/xavialex/32/33920_2.png) [@xavialex](https://discuss.huggingface.co/u/xavialex)\
**Post date:** [August 19, 2023, 7:21pm UTC](https://discuss.huggingface.co/t/error-from-cuda-on-audio-classification/33234/3 "2023-08-19T19:21:42Z")

</div>

Hi @dmoti:

I’ve ran into the same issue in a similar environment (W11). In my case, even switching to CPU (setting the TrainingArguments parameter no\_cuda to True) resulted in an error like [this](https://discuss.huggingface.co/t/runtimeerror-when-training-starts-expected-scalar-type-long-but-found-int/16920). In the Trainer, using the datasets with\_format(‘torch’) made it work with and without CUDA enabled. Example below:

```python
trainer = Trainer(
    model,
    training_args,
    train_dataset=dataset_encoded["train"].with_format("torch"),
    eval_dataset=dataset_encoded["test"].with_format("torch"),
    tokenizer=feature_extractor,
    compute_metrics=compute_metrics,
)

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![codekingwu](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@codekingwu](https://discuss.huggingface.co/u/codekingwu)\
**Post date:** [September 18, 2024, 5:11am UTC](https://discuss.huggingface.co/t/error-from-cuda-on-audio-classification/33234/4 "2024-09-18T05:11:26Z")

</div>

Thank you so much
