I am trying to get the AMD Radeon Pro 5700 XT GPU on my iMac 27" 2021 running Big Sur 11.4 to work with tensorflow-macos.
If I disable eager execution I get an exception, if I don't, tensorflow-macos choses the CPU and not the GPU.
Here's a simple example which shows the exception:
import tensorflow as tf import tensorflow_hub as hub import tensorflow_text import numpy as np from sklearn.preprocessing import normalize from tensorflow.python.framework.ops import disable_eager_execution disable_eager_execution() m4 = hub.load("/Users/davidlaxer/Downloads/universal-sentence-encoder_4") english_sentences = ["dog", "Puppies are nice.", "I enjoy taking long walks along the beach with my dog."] r4 = np.array(m4(english_sentences)) print(r4) print(m4) type(r4) type(m4) --------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) <ipython-input-4-8b0ba0e4c28c> in <module> 1 m4 = hub.load("/Users/davidlaxer/Downloads/universal-sentence-encoder_4") 2 english_sentences = ["dog", "Puppies are nice.", "I enjoy taking long walks along the beach with my dog."] ----> 3 r4 = np.array(m4(english_sentences)) 4 print(r4) 5 print(m4) ~/anaconda3/envs/tensorflow_mac/lib/python3.8/site-packages/tensorflow/python/framework/ops.py in __array__(self) 850 851 def __array__(self): --> 852 raise NotImplementedError( 853 "Cannot convert a symbolic Tensor ({}) to a numpy array." 854 " This error may indicate that you're trying to pass a Tensor to" NotImplementedError: Cannot convert a symbolic Tensor (StatefulPartitionedCall_1:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported
And commenting out disable_eager_execution():
from tensorflow.python.framework.ops import disable_eager_execution #disable_eager_execution() m4 = hub.load("/Users/davidlaxer/Downloads/universal-sentence-encoder_4") english_sentences = ["dog", "Puppies are nice.", "I enjoy taking long walks along the beach with my dog."] r4 = np.array(m4(english_sentences)) print(r4) print(m4) type(r4) type(m4) [-0.06334164 -0.01812314 0.03680531 ... -0.02809388 0.02786911 -0.04715428] [ 0.01975714 -0.02284616 0.04316505 ... -0.01376714 -0.00614742 -0.00124967] [-0.02169351 -0.003993 0.06716524 ... 0.05952153 0.02262796 0.03501643]] <tensorflow.python.saved_model.load.Loader._recreate_base_user_object.<locals>._UserObject object at 0x7fbb3892a9a0> [5]: tensorflow.python.saved_model.load.Loader._recreate_base_user_object.<locals>._UserObject
The tensorflow group does not support this GPU and the tensorflow-mac repository is now read-only.
https://github.com/tensorflow/tensorflow/issues/50353
https://github.com/apple/tensorflow_macos
Any ideas?