apple / tensorflow_macos

TensorFlow for macOS 11.0+ accelerated using Apple's ML Compute framework.
Other
3.67k stars 308 forks source link

M1 Mac zsh: abort python in training model #210

Closed tetuomi closed 3 years ago

tetuomi commented 3 years ago

information

I set up environment by following #153

code

import tensorflow as tf
from tensorflow.python.platform import build_info as tf_build_info
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("TensorFlow version: {}".format(tf.__version__))
print("Eager execution: {}".format(tf.executing_eagerly()))
print("Keras version: {}".format(tf.keras.__version__))
#print("Cuda version: {}".format(tf_build_info.cuda_version_number))
#print("Cudnn version: {}".format(tf_build_info.cudnn_version_number))
print("Num Physical GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
print("Num Logical GPUs Available: ", len(tf.config.experimental.list_logical_devices('GPU')))

mnist = tf.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 = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(128, activation='relu'),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(
  optimizer='adam',
  loss='sparse_categorical_crossentropy',
  metrics=['accuracy']
)

model.compile(
  optimizer='adam',
  loss='sparse_categorical_crossentropy',
  metrics=['accuracy']
)

model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test, verbose=2)

output

TensorFlow version: 2.4.0-rc0
Eager execution: False
Keras version: 2.4.0
Num Physical GPUs Available:  0
Num Logical GPUs Available:  0
Train on 60000 samples
2021-03-22 16:26:58.380661: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:196] None of the MLIR optimization passes are enabled (registered 0 passes)
2021-03-22 16:26:58.383619: W tensorflow/core/platform/profile_utils/cpu_utils.cc:126] Failed to get CPU frequency: 0 Hz
Epoch 1/5
zsh: abort      python test.py

finally

if information is not enough or you don't understand what i say(i'm not good at English), please notify me.

tetuomi commented 3 years ago

I remade conda environment. this error is solved!!!!

ManuelSchneid3r commented 3 years ago

print("Num Logical GPUs Available: ", len(tf.config.experimental.list_logical_devices('GPU')))

Does this list the GPU now?

tetuomi commented 3 years ago

sorry, I’m at home, so I can’t know the result of print. As far as I remember, the result of print is maybe 0. After May.7, I can know the real result, very very sorry.