What do you think about my results?
Now it looks M1 max GPU works without mlcompute.
my test program is as follows
------------------------------
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
(train_images, train_labels), (test_images, test_labels) = datasets.cifar10.load_data()
train_images, test_images = train_images / 255.0, test_images / 255.0
#from tensorflow.python.compiler.mlcompute import mlcompute
#mlcompute.set_mlc_device(device_name='gpu')
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.Flatten())
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(10))
model.compile(
optimizer='adam',
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=['accuracy']
)
history = model.fit(
train_images,
train_labels,
epochs=10,
validation_data=(test_images, test_labels)
)
the results from the code is as follows
---------------------------------------
Metal device set to: Apple M1 Max
2021-11-30 13:05:12.085180: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2021-11-30 13:05:12.085560: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: )
2021-11-30 13:05:13.115918: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:185] None of the MLIR Optimization Passes are enabled (registered 2)
2021-11-30 13:05:13.118560: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
2021-11-30 13:05:13.256877: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:112] Plugin optimizer for device_type GPU is enabled.
Epoch 1/10
1563/1563 [==============================] - ETA: 0s - loss: 1.4715 - accuracy: 0.4650
2021-11-30 13:05:27.622014: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:112] Plugin optimizer for device_type GPU is enabled.
1563/1563 [==============================] - 16s 9ms/step - loss: 1.4715 - accuracy: 0.4650 - val_loss: 1.2344 - val_accuracy: 0.5623
Epoch 2/10
1563/1563 [==============================] - 14s 9ms/step - loss: 1.1120 - accuracy: 0.6048 - val_loss: 1.0613 - val_accuracy: 0.6261
Epoch 3/10
1563/1563 [==============================] - 14s 9ms/step - loss: 0.9570 - accuracy: 0.6646 - val_loss: 0.9228 - val_accuracy: 0.6778
Epoch 4/10
1563/1563 [==============================] - 14s 9ms/step - loss: 0.8554 - accuracy: 0.6993 - val_loss: 0.9274 - val_accuracy: 0.6766
Epoch 5/10
1563/1563 [==============================] - 14s 9ms/step - loss: 0.7799 - accuracy: 0.7273 - val_loss: 0.8858 - val_accuracy: 0.6945
Epoch 6/10
1563/1563 [==============================] - 14s 9ms/step - loss: 0.7126 - accuracy: 0.7508 - val_loss: 0.8594 - val_accuracy: 0.7021
Epoch 7/10
1563/1563 [==============================] - 14s 9ms/step - loss: 0.6618 - accuracy: 0.7685 - val_loss: 0.8287 - val_accuracy: 0.7161
Epoch 8/10
1563/1563 [==============================] - 14s 9ms/step - loss: 0.6097 - accuracy: 0.7863 - val_loss: 0.8918 - val_accuracy: 0.7053
Epoch 9/10
1563/1563 [==============================] - 14s 9ms/step - loss: 0.5659 - accuracy: 0.7997 - val_loss: 0.8921 - val_accuracy: 0.7072
Epoch 10/10
1563/1563 [==============================] - 14s 9ms/step - loss: 0.5211 - accuracy: 0.8160 - val_loss: 0.9404 - val_accuracy: 0.7065
In [ ]: