Keras 3 and Tensorflow GPU does not have support on apple silicon

hi,

I am currently running LSTM on TensorFlow. However, when i switched from keras2 to keras3. code running time has increased 10 times -- it seems there is no GPU acceleration.

Here is my code:

batch size = 256
optimiser = adam
activation = tanh
_______________________________________________
 Layer (type)                Output Shape              Param #   
=============================================
 input_1 (InputLayer)        [(None, 7, 16)]           0         
                                                                 
 bidirectional (Bidirection  (None, 7, 320)            226560    
 al)                                                             
                                                                 
 bidirectional_1 (Bidirecti  (None, 7, 512)            1181696   
 onal)                                                           
                                                                 
 bidirectional_2 (Bidirecti  (None, 256)            656384    
 onal)                                                           
                                                                 
 dense (Dense)               (None, 1)              257       
                                                                 
==============================================
Total params: 2064897 (7.88 MB)
Trainable params: 2064897 (7.88 MB)
Non-trainable params: 0 (0.00 Byte)
______________________________________________

This is keras 3.6.0 + tensorflow 2.17.0 + tensorflow-metal 1.1.0 training status:

Training------------
Epoch 1/200
 28/681 ━━━━━━━━━━━━━━━━━━━━ 8:13 756ms/step - loss: 0.5901 - mape: 338.6876 - mse: 0.8591

This is keras 2.14.0 + tensorflow 2.14.0 + tensorflow-metal 1.1.0 training status:

Training------------
Epoch 1/200
681/681 [==============================] - 37s 49ms/step - loss: 3.6345 - mape: 499038.7500 - mse: 34.4148 - val_loss: 3.5452 - val_mape: 41.7964 - val_mse: 32.0133 - lr: 0.0010

Is that because keras3 has no GPU support on macos?

Apart from that, if I change LSTM activation from tanh to sigmoid in keras2, it does not have GPU support as well.

My system is 15.0.1 and the code was running on python3.11

I am not sure why these happen.

Thanks

I further inspected my code. If I removed the bidirectional layer, the GPU computing speed returned to normal (keras 3)

for the activation function, I saw posts that said only using 'tanh' will enable CuDNNLSTM, which is faster than lstm.

It worked well on my m2 mac mini when I used the workaround suggested in another thread: https://forums.developer.apple.com/forums/thread/761529

pip uninstall tensorflow tensorflow-macos tensorflow-metal numpy
pip install tensorflow-macos==2.15 tensorflow-metal

Python 3.9
Keras 2.15.0
tensorflow-macos 2.15.0
tensorflow-metal 1.1.0
Keras 3 and Tensorflow GPU does not have support on apple silicon
 
 
Q