How to choose whether I use M1 CPU or GPU in tensorflow-metal?

I'd like to control whether the network training happens on CPU or GPU when using tensorflow-metal.

How to do this?

Thanks!

Hi @dmitry-kabanov!

This can be done for example by putting parts of the python script within a block of with with tf.device('CPU: 0'): and with tf.device('GPU: 0'): respectively. Another way if you want to disable GPU from the whole script would be to put the following line at the beginning of your script after importing tensorflow: tf.config.set_visible_devices([], 'GPU').

It seems that tf.config.set_visible_devices([], "GPU") works in tensorflow but not with tensorflow-metal

RuntimeError: Visible devices cannot be modified after being initialized

Sorry, missed the part about placement of the call

How to choose whether I use M1 CPU or GPU in tensorflow-metal?
 
 
Q