Bert For Sequence Classification with Keras fine tuning on GPU error

Dear all,

i try to move to GPU to fine tune a BERT classification model with Keras (like this hugginface tutorial).

I use TFAutoModelForSequenceClassification to load the model, but this class not have .to() function to move to GPU.

If I move to the general AutoModelForSequenceClassification i cannot have .compile() function to set

    optimizer=tf.keras.optimizers.Adam(learning_rate=2e-5),
    loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
    metrics=tf.metrics.SparseCategoricalAccuracy(),

Any solutions?
Thanks in advance

I found in another post that tensorflow and keras use as default gpu when there is. Then there is no need for.to() method.
My problem was i didn’t cuda and cudnn install on docker. I fixed using the gpu version of tensorflow and keras.

1 Like