'use_cuda' set to True when cuda is unavailable. Make sure CUDA is available or set use_cuda=False

Question:

I am trying to create a Bert model for classifying Turkish Lan. here is my code:

import pandas as pd
import torch
df = pd.read_excel (r'preparedDataNoId.xlsx')
df = df.sample(frac = 1)

from sklearn.model_selection import train_test_split

train_df, test_df = train_test_split(df, test_size=0.10)

print('train shape: ',train_df.shape)
print('test shape: ',test_df.shape)
from simpletransformers.classification import ClassificationModel

# define hyperparameter
train_args ={"reprocess_input_data": True,
             "fp16":False,
             "num_train_epochs": 4}

# Create a ClassificationModel
model = ClassificationModel(
    "bert", "dbmdz/bert-base-turkish-cased",
    num_labels=4,
    args=train_args
)

I am using Anaconda and Spyder. I think every thing is correct but when I run this I got the following error:

'use_cuda' set to True when cuda is unavailable. Make sure CUDA is available or set use_cuda=False.

how can I fix this exactly?

Asked By: matjar trk

||

Answers:

I ran into the same problem. If you have CUDA available, then set both use_cuda and fp16 to True. If not, then set both to False.

Answered By: fremonta

If your GPU is unavailable on your computer. Make sure to check CUDA or try use_cuda=False in args of your model. This error will be throw since CUDA does not exist on your computer.

Answered By: nllibi

CUDA is a parallel computing platform and programming model developed by Nvidia for general computing on its own GPUs.

If your computer does not have GPU, this error will be thrown to you.
Don’t forget to include this parameter

use_cuda= False

This will not affect your result, just take a few more seconds than usual to process.

Answered By: Prasant kumar

model = ClassificationModel(
"bert", "dbmdz/bert-base-turkish-cased",
num_labels=4,
args=train_args,
use_cuda=False
)

Adding "use_cuda=False" will help if GPU is not available

Answered By: NaveedHakim
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.