Open edwin-yan opened 3 years ago
I have exactly the same issue on a macbook pro 13 mit 2020 with intel i5. much slower with tensorflow macos. Running the code from edwin-yan I get:
Hope it will improve in future!!
Thank you very much for reporting this issue. We will investigate and report back.
Anything?
Same problem on MacBook pro 16.
Tensorflow standard
Tensorflow for mac
I saw 0.1-alpha3 is out, so I gave a try today. Unfortunately, I did not see any improvements using either GPU or CPU. Both are much slower than the standard TF.
However, I noticed a new function added in 0.1a3 is to disable ML Compute acceleration by adding environment variable: %env TF_DISABLE_MLC=1
Interestingly enough & believe or not, it runs significant faster than the standard TF, although it only uses CPU. (my standard TF may be on a different version than the tf_macos). I will play around and find out more details when I have time over the weekend.
*Update: I upgraded my standard TF library from 2.0 to 2.4. Now, there is no difference in terms of speed comparing the standard TF and TF MacOS after disabling MLC. That being said, TF 2.4 is about 40% faster than TF2.0 on CPU...Interesting...
I have the same issue with my gpu performance. Any leads on this issue?
@anna-tikhonova have you guys looked into this issue yet?
@anna-tikhonova have you guys looked into this issue yet?
Current version is still 0.1-alpha3, so I guess they have not resolved the issue yet...
I did a quick experiment using MNIST dataset. I noticed the performance of Tensorflow MacOS is pretty bad comparing to the CPU version/PlaidML.
Quick Stats
Tensorflow CPU (Standard): 2m44s PlaidML: 1m9s Tensorflow MacOS CPU: 10m27s Tensorflow MacOS GPU: 5m28s
In addition, I wonder how can I enable multiple GPU? I tried to use tf.distribute.MirroredStrategy(), but it can only recognize 1 GPU (the EGPU, although my discrete GPU has the same 8G memory as the EGPU). I wonder if Tensorflow MacOS supports multiple GPUs? If so, any requirements? (eg: same model?)
Details
Tensorflow CPU (Standard):
PlaidML:
Tensorflow MacOS CPU:
Tensorflow MacOS GPU:
Code
CPU Version
import tensorflow as tf from tensorflow import keras
PlaidML
import keras import os os.environ["KERAS_BACKEND"] = "plaidml.keras.backend"
Tensorflow MacOS - CPU
import tensorflow as tf from tensorflow import keras from tensorflow.python.compiler.mlcompute import mlcompute mlcompute.set_mlc_device(device_name='cpu')
Tensorflow MacOS - GPU
import tensorflow as tf from tensorflow import keras print('tensorflow version:',tf.version) from tensorflow.python.compiler.mlcompute import mlcompute from tensorflow.python.framework.ops import disable_eager_execution disable_eager_execution() mlcompute.set_mlc_device(device_name='gpu') # Available options are 'cpu', 'gpu', and 'any'. tf.config.run_functions_eagerly(False) print(tf.executing_eagerly())
Example
mnist = keras.datasets.mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0, x_test / 255.0 model = keras.models.Sequential([ keras.layers.Flatten(input_shape=(28, 28)), keras.layers.Dense(2048,activation='relu'), keras.layers.Dense(4096,activation='relu'), keras.layers.Dense(2048,activation='relu'), keras.layers.Dense(10, activation='softmax') ]) model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'], ) model.summary() model.fit(x_train, y_train, epochs=5, batch_size=512)