tensorflow-metal

RSS for tag

TensorFlow accelerates machine learning model training with Metal on Mac GPUs.

tensorflow-metal Documentation

Posts under tensorflow-metal tag

249 Posts
Sort by:
Post not yet marked as solved
1 Replies
282 Views
Hi all, I was experimenting with the tf-metal (v0.4) framework and noticed some odd interactions with the tensorflow_probability package: import tensorflow as tf import numpy as np from tensorflow_probability.python.stats import percentile if __name__ == "__main__": data = np.array([0.12941672, 0.22039098, 0.33956015, 0.3787993, 0.5329178, 0.62175393, 0.5906472, 0.97234255, 0.7709932, 0.76639813, 1.0468946, 1.1515584, 1.0470238, 1.1140094, 1.2083299, 1.051311, 1.0782655, 1.0192754, 0.8690998, 0.9439713, 0.6992503, 0.7017522, 0.6524739, 0.536425, 0.47863948, 0.46657538, 0.45757294, 0.2988146, 0.19273241, 0.1494804, 0., 0.], dtype=np.float64) data16 = tf.convert_to_tensor(data, dtype=tf.float16) data32 = tf.convert_to_tensor(data, dtype=tf.float32) data64 = tf.convert_to_tensor(data, dtype=tf.float64) p = percentile(data, 99, keepdims=True, interpolation="lower") print(f"Percentile based on Numpy array (float64): {p}") p = percentile(data16, 99, keepdims=True, interpolation="lower") print(f"Percentile based on TF (float16): {p}") p = percentile(data32, 99, keepdims=True, interpolation="lower") print(f"Percentile based on TF (float32): {p}") p = percentile(data64, 99, keepdims=True, interpolation="lower") print(f"Percentile based on TF (float64): {p}") This results in: Percentile based on Numpy array (float64): [1.1515584] Percentile based on TF (float16): [1.151] Percentile based on TF (float32): [-0.] Percentile based on TF (float64): [1.1515584] The float32 value here is obviously corrupted, whereas the others are fine (presumably because only float32 is sent to the gpu?). When I uninstall tf-metal the float32 values are computed correctly. Any thoughts on when a fix might be available? Also, is there any timeline for supporting float16 on gpu?
Posted Last updated
.
Post not yet marked as solved
1 Replies
251 Views
Today I upgraded tensorflow-macos to 2.9.0 and tensorflow-metal to 0.5.0, and found my old notebook failed to run. It ran well with tensorflow-macos 2.8.0 and tensorflow-metal 0.4.0. Specifically, I found that the groups arg of Conv2d layer was the cause. Here is a demo: import tensorflow as tf from tensorflow import keras as tfk # tf.config.set_visible_devices([], 'GPU') Xs = tf.random.normal((32, 64, 48, 4)) ys = tf.random.normal((32,)) tf.random.set_seed(0) model = tfk.Sequential([ tfk.layers.Conv2D( filters=16, kernel_size=(4, 3), groups=4, # groups arg activation='relu', ), tfk.layers.Flatten(), tfk.layers.Dense(1, activation='sigmoid'), ]) model.compile( loss=tfk.losses.BinaryCrossentropy(), metrics=[ tfk.metrics.BinaryAccuracy(), ], ) model.fit(Xs, ys, epochs=2, verbose=1) The error is: W tensorflow/core/framework/op_kernel.cc:1745] OP_REQUIRES failed at xla_ops.cc:296 : UNIMPLEMENTED: Could not find compiler for platform METAL: NOT_FOUND: could not find registered compiler for platform METAL -- check target linkage Removing groups arg would make the code run again. Training on CPU, by uncommenting line 4, gives different error: 'apple-m1' is not a recognized processor for this target (ignoring processor) LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it! And removing groups arg also would make training on CPU work. However I didn't test training on CPU before the upgrade. My device is a MacBook Pro 14' running macOS 12.4.
Posted
by wangcheng.
Last updated
.
Post marked as solved
1 Replies
302 Views
Normally when a model is instantiated multiple times, it gets different weights each time (important for statistical significance testing). The current version of TF-Metal (0.4) seems to cache the model weights or something, resulting in the weights being equal for multiple model instantiations: from tensorflow.keras import Sequential, layers def get_model(): model = Sequential() model.add(layers.Dense(5, activation='relu', input_shape=(4, 4))) return model if __name__ == "__main__": model1 = get_model() model2 = get_model() print(model1.weights[0] - model2.weights[0]) Response without TF-Metal (as desired, weights for the two models are different): tf.Tensor( [[ 1.0636648 -0.10816181 0.8423695 1.3752697 0.38691664] [ 0.2402662 0.38139135 -0.19254395 -0.24551326 0.13166189] [-0.24854952 1.3374841 0.9716329 -0.21249878 -0.34604508] [ 0.5040202 0.120031 0.13515717 -0.40721053 0.29544616]], shape=(4, 5), dtype=float32) Response with TF-Metal (weights are all equal): tf.Tensor( [[0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.]], shape=(4, 5), dtype=float32) Any ideas on the root cause or timeline for a fix?
Posted Last updated
.
Post marked as solved
13 Replies
16k Views
Following the instructions at https://developer.apple.com/metal/tensorflow-plugin/ I got as far as python -m pip install tensorflow-macos and it responded "ERROR: Could not find a version that satisfies the requirement tensorflow-macos (from versions: none) ERROR: No matching distribution found for tensorflow-macos" I'd be grateful for any suggestions
Posted Last updated
.
Post not yet marked as solved
1 Replies
336 Views
Hi, OS: macOS 12.4 CPU: Apple M1 I cannot import the new TensorFlow 2.9.0 on Apple M1. I got an error: --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Users/martin/Documents/Projects/Solar-Transformer/Testing.ipynb Cell 3' in <cell line: 1>() ----> 1 from tensorflow.keras.layers import Add, Dense, Dropout, Layer, LayerNormalization, MultiHeadAttention, Normalization 2 from tensorflow.keras.models import Model 3 from tensorflow.keras.initializers import TruncatedNormal File ~/miniforge3/lib/python3.9/site-packages/tensorflow/__init__.py:37, in <module> 34 import sys as _sys 35 import typing as _typing ---> 37 from tensorflow.python.tools import module_util as _module_util 38 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader 40 # Make sure code inside the TensorFlow codebase can use tf2.enabled() at import. File ~/miniforge3/lib/python3.9/site-packages/tensorflow/python/__init__.py:42, in <module> 37 from tensorflow.python.eager import context 39 # pylint: enable=wildcard-import 40 41 # Bring in subpackages. ---> 42 from tensorflow.python import data 43 from tensorflow.python import distribute 44 # from tensorflow.python import keras File ~/miniforge3/lib/python3.9/site-packages/tensorflow/python/data/__init__.py:21, in <module> 15 """`tf.data.Dataset` API for input pipelines. 16 17 See [Importing Data](https://tensorflow.org/guide/data) for an overview. 18 """ 20 # pylint: disable=unused-import ---> 21 from tensorflow.python.data import experimental 22 from tensorflow.python.data.ops.dataset_ops import AUTOTUNE 23 from tensorflow.python.data.ops.dataset_ops import Dataset File ~/miniforge3/lib/python3.9/site-packages/tensorflow/python/data/util/structure.py:22, in <module> 19 import six 20 import wrapt ---> 22 from tensorflow.python.data.util import nest 23 from tensorflow.python.framework import composite_tensor 24 from tensorflow.python.framework import ops File ~/miniforge3/lib/python3.9/site-packages/tensorflow/python/data/util/nest.py:36, in <module> 16 """## Functions for working with arbitrarily nested sequences of elements. 17 18 NOTE(mrry): This fork of the `tensorflow.python.util.nest` module (...) 31 arrays. 32 """ 34 import six as _six ---> 36 from tensorflow.python.framework import sparse_tensor as _sparse_tensor 37 from tensorflow.python.util import _pywrap_utils 38 from tensorflow.python.util import nest File ~/miniforge3/lib/python3.9/site-packages/tensorflow/python/framework/sparse_tensor.py:24, in <module> 22 from tensorflow.python import tf2 23 from tensorflow.python.framework import composite_tensor ---> 24 from tensorflow.python.framework import constant_op 25 from tensorflow.python.framework import dtypes 26 from tensorflow.python.framework import ops File ~/miniforge3/lib/python3.9/site-packages/tensorflow/python/framework/constant_op.py:25, in <module> 23 from tensorflow.core.framework import types_pb2 24 from tensorflow.python.eager import context ---> 25 from tensorflow.python.eager import execute 26 from tensorflow.python.framework import dtypes 27 from tensorflow.python.framework import op_callbacks File ~/miniforge3/lib/python3.9/site-packages/tensorflow/python/eager/execute.py:23, in <module> 21 from tensorflow.python import pywrap_tfe 22 from tensorflow.python.eager import core ---> 23 from tensorflow.python.framework import dtypes 24 from tensorflow.python.framework import ops 25 from tensorflow.python.framework import tensor_shape File ~/miniforge3/lib/python3.9/site-packages/tensorflow/python/framework/dtypes.py:29, in <module> 26 from tensorflow.python.lib.core import _pywrap_bfloat16 27 from tensorflow.python.util.tf_export import tf_export ---> 29 _np_bfloat16 = _pywrap_bfloat16.TF_bfloat16_type() 32 @tf_export("dtypes.DType", "DType") 33 class DType(_dtypes.DType): 34 """Represents the type of the elements in a `Tensor`. 35 36 `DType`'s are used to specify the output data type for operations which (...) 46 See `tf.dtypes` for a complete list of `DType`'s defined. 47 """ Example code: from tensorflow.keras.layers import Add, Dense, Dropout, Layer, LayerNormalization, MultiHeadAttention, Normalization from tensorflow.keras.models import Model from tensorflow.keras.initializers import TruncatedNormal from tensorflow.keras.utils import timeseries_dataset_from_array import tensorflow as tf import tensorflow_probability as tfp import numpy as np
Posted Last updated
.
Post marked as solved
2 Replies
233 Views
Hello everyone I found some problem in tf built-in function (tf.signal.stft) when I type the code below, it will cause problem. Device is MacBookPro with M1 Pro chip in jupyterlab However, the problem won't cause on linux with CUDA. Does anyone know how to fix the problem ? Thanks. code: import numpy as np import tensorflow as tf random_waveform = np.random.normal(size=(16000)) tf_waveform = tf.constant(random_waveform) tf_stft_waveform = tf.signal.stft(tf_waveform, frame_length=255, frame_step=128) error message: InvalidArgumentError Traceback (most recent call last) Input In [1], in <cell line: 6>() 4 random_waveform = np.random.normal(size=(16000)) 5 tf_waveform = tf.constant(random_waveform) ----> 6 tf_stft_waveform = tf.signal.stft(tf_waveform, frame_length=255, frame_step=128) File ~/miniconda3/envs/AI/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py:153, in filter_traceback.<locals>.error_handler(*args, **kwargs) 151 except Exception as e: 152 filtered_tb = _process_traceback_frames(e.__traceback__) --> 153 raise e.with_traceback(filtered_tb) from None 154 finally: 155 del filtered_tb File ~/miniconda3/envs/AI/lib/python3.9/site-packages/tensorflow/python/framework/ops.py:7164, in raise_from_not_ok_status(e, name) 7162 def raise_from_not_ok_status(e, name): 7163 e.message += (" name: " + name if name is not None else "") -> 7164 raise core._status_to_exception(e) from None InvalidArgumentError: Multiple Default OpKernel registrations match NodeDef '{{node ZerosLike}}': 'op: "ZerosLike" device_type: "DEFAULT" constraint { name: "T" allowed_values { list { type: DT_INT32 } } } host_memory_arg: "y"' and 'op: "ZerosLike" device_type: "DEFAULT" constraint { name: "T" allowed_values { list { type: DT_INT32 } } } host_memory_arg: "y"' [Op:ZerosLike] 1
Posted Last updated
.
Post not yet marked as solved
5 Replies
338 Views
I am noticing huge memory usage with TensorFlow. The memory usage will keep on increasing up to 36GB of memory usage only after one epoch. The following is the dataset preprocessing process: with tf.device('CPU: 0'): data_augmentation = keras.Sequential([ keras.layers.experimental.preprocessing.RandomFlip("horizontal"), keras.layers.experimental.preprocessing.RandomRotation(0.2), keras.layers.experimental.preprocessing.RandomHeight(0.2), keras.layers.experimental.preprocessing.RandomWidth(0.2), keras.layers.experimental.preprocessing.RandomZoom(0.2), ], name="data_augmentation") train_data = train_data.map(map_func=lambda x, y: (data_augmentation(x), y), num_parallel_calls=tf.data.AUTOTUNE).prefetch(buffer_size=tf.data.AUTOTUNE) test_data = test_data.prefetch(buffer_size=tf.data.AUTOTUNE) And the following is the model I used base_model = keras.applications.EfficientNetB0(include_top=False) base_model.trainable = False inputs = keras.layers.Input(shape=(224, 224, 3), name='input_layer') x = base_model(inputs, training=False) x = keras.layers.GlobalAveragePooling2D(name='global_average_pooling')(x) outputs = keras.layers.Dense(101, activation='softmax', name='output_layer')(x) model = keras.Model(inputs, outputs) # Compile model.compile(loss="categorical_crossentropy", optimizer=tf.keras.optimizers.Adam(), # use Adam with default settings metrics=["accuracy"]) from tqdm.keras import TqdmCallback tqdm_callback = TqdmCallback() # Fit history_all_classes_10_percent = model.fit(train_data, verbose=0, epochs=5, validation_data=test_data, validation_steps=int(0.15 * len(test_data)), callbacks=[checkpoint_callback, tqdm_callback]) # save best model weights to file
Posted
by Leozz99.
Last updated
.
Post marked as solved
3 Replies
286 Views
Hi, I am reliably able to get the following results after running pip install tensorflow-metal. Note I did not cull anything (including some device registration messages that only appear the first time you use tensorflow - hopefully not too distracting, but thought it would provide helpful context about my environment in case something is fishy). Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:14) [Clang 12.0.1 ] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> tf.config.list_physical_devices('GPU') [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')] >>> tf.zeros_like([1]) Metal device set to: Apple M1 systemMemory: 8.00 GB maxCacheSize: 2.67 GB 2022-06-05 18:54:29.515755: 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. 2022-06-05 18:54:29.516007: 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: <undefined>) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler raise e.with_traceback(filtered_tb) from None File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.8/site-packages/tensorflow/python/framework/ops.py", line 7164, in raise_from_not_ok_status raise core._status_to_exception(e) from None # pylint: disable=protected-access tensorflow.python.framework.errors_impl.InvalidArgumentError: Multiple Default OpKernel registrations match NodeDef '{{node ZerosLike}}': 'op: "ZerosLike" device_type: "DEFAULT" constraint { name: "T" allowed_values { list { type: DT_INT32 } } } host_memory_arg: "y"' and 'op: "ZerosLike" device_type: "DEFAULT" constraint { name: "T" allowed_values { list { type: DT_INT32 } } } host_memory_arg: "y"' [Op:ZerosLike] Whereas after uninstalling tensorflow-metal (pip uninstall tensorflow-metal) the same commands produce: Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:14) [Clang 12.0.1 ] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> tf.config.list_physical_devices('GPU') [] >>> tf.zeros_like([1]) <tf.Tensor: shape=(1,), dtype=int32, numpy=array([0], dtype=int32)> It looks like a simple double registration issue, but I've only just found out about the 'PluggableDevice' API, so I don't know if it has recommendations for resolving multiple registrations. If I had to guess it is unexpected in the extreme for a pluggable device extension to contain default device op registrations, but without being able to see the code I cannot guess further about what might be wrong.
Posted
by emdeefive.
Last updated
.
Post not yet marked as solved
2 Replies
1.2k Views
I want to install tensorflow_addons, but I found some errors as below. ➜ pip install tensorflow-addons-macos ERROR: Could not find a version that satisfies the requirement tensorflow_addons (from versions: none) ERROR: No matching distribution found for tensorflow_addons ➜ pip install tensorflow-addons-macos ERROR: Could not find a version that satisfies the requirement tensorflow_addons (from versions: none) ERROR: No matching distribution found for tensorflow_addons ➜ pip install --upgrade --force --no-dependencies ./tensorflow_addons_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl ERROR: tensorflow_addons_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl is not a supported wheel on this platform. And I confirm that I have installed tensorflow-metal correctly. ➜ pip list | grep tensorflow tensorflow-estimator 2.7.0 tensorflow-macos 2.7.0 tensorflow-metal 0.3.0
Posted
by ZedRover.
Last updated
.
Post not yet marked as solved
2 Replies
366 Views
error message I ran the following notebook with tensorflow-metal--0.5.0 import tensorflow as tf from tensorflow import keras import numpy as np (X_train_full, y_train_full), (X_test, y_test) = keras.datasets.fashion_mnist.load_data() X_train, X_valid = X_train_full[:-5000], X_train_full[-5000:] y_train, y_valid = y_train_full[:-5000], y_train_full[-5000:] X_mean = X_train.mean(axis=0, keepdims=True) X_std = X_train.std(axis=0, keepdims=True) + 1e-7 X_train = (X_train - X_mean) / X_std X_valid = (X_valid - X_mean) / X_std X_test = (X_test - X_mean) / X_std X_train = X_train[..., np.newaxis] X_valid = X_valid[..., np.newaxis] X_test = X_test[..., np.newaxis] from functools import partial DefaultConv2D = partial(keras.layers.Conv2D, kernel_size=3, activation='relu', padding="SAME") input_ = keras.layers.Input(shape=[28, 28, 1]) conv0 = DefaultConv2D(filters=64, kernel_size=7)(input_) pool1 = keras.layers.MaxPooling2D(pool_size=2)(conv0) conv1 = DefaultConv2D(filters=128)(pool1) conv2 = DefaultConv2D(filters=128)(conv1) pool2 = keras.layers.MaxPooling2D(pool_size=2)(conv2) conv3 = DefaultConv2D(filters=256)(pool2) conv4 = DefaultConv2D(filters=256)(conv3) pool3 = keras.layers.MaxPooling2D(pool_size=2)(conv4) flatten = keras.layers.Flatten()(conv4) hidden1 = keras.layers.Dense(units=128, activation='relu')(flatten) dropout1 = keras.layers.Dropout(0.5)(hidden1) hidden2 = keras.layers.Dense(units=64, activation='relu')(dropout1) dropout2 = keras.layers.Dropout(0.5)(hidden2) output = keras.layers.Dense(units=10, activation='softmax')(dropout2) model = keras.Model(inputs=[input_], outputs=[output]) model.compile(loss="sparse_categorical_crossentropy", optimizer="nadam", metrics=["accuracy"]) model.fit(X_train, y_train, epochs=20, validation_data=(X_valid, y_valid)) However I got the error message the kernel appears to have died. it will restart automatically. in the 3rd cell. I also ran this python script from terminal one line at a time, and I got the error message I attached above when I tried to run the code conv0 = DefaultConv2D(filters=64, kernel_size=7)(input_) With tensorflow-metal uninstalled, this code runs without any error messages.
Posted
by ishibashi.
Last updated
.
Post not yet marked as solved
2 Replies
648 Views
I have followed all the instructions to install tensorflow for my M1 mac from "https://developer.apple.com/metal/tensorflow-plugin/". Despite of showing a successful installation, there is an error when I am trying to import the tensorflow library. --------------------------------------------------------------------------- OSError Traceback (most recent call last) Input In [1], in <cell line: 1>() ----> 1 import tensorflow as tf 2 tf.__version__ File ~/.local/lib/python3.9/site-packages/tensorflow/__init__.py:37, in <module> 34 import sys as _sys 35 import typing as _typing ---> 37 from tensorflow.python.tools import module_util as _module_util 38 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader 40 # Make sure code inside the TensorFlow codebase can use tf2.enabled() at import. File ~/.local/lib/python3.9/site-packages/tensorflow/python/__init__.py:36, in <module> 27 import traceback 29 # We aim to keep this file minimal and ideally remove completely. 30 # If you are adding a new file with @tf_export decorators, 31 # import it in modules_with_exports.py instead. 32 33 # go/tf-wildcard-import 34 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top ---> 36 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow 37 from tensorflow.python.eager import context 39 # pylint: enable=wildcard-import 40 41 # Bring in subpackages. File ~/.local/lib/python3.9/site-packages/tensorflow/python/pywrap_tensorflow.py:24, in <module> 21 from tensorflow.python.platform import self_check 23 # Perform pre-load sanity checks in order to produce a more actionable error. ---> 24 self_check.preload_check() 26 # pylint: disable=wildcard-import,g-import-not-at-top,unused-import,line-too-long 28 try: 29 # This import is expected to fail if there is an explicit shared object 30 # dependency (with_framework_lib=true), since we do not need RTLD_GLOBAL. File ~/.local/lib/python3.9/site-packages/tensorflow/python/platform/self_check.py:65, in preload_check() 58 else: 59 # Load a library that performs CPU feature guard checking as a part of its 60 # static initialization. Doing this here as a preload check makes it more 61 # likely that we detect any CPU feature incompatibilities before we trigger 62 # them (which would typically result in SIGILL). 63 cpu_feature_guard_library = os.path.join( 64 os.path.dirname(__file__), "../../core/platform/_cpu_feature_guard.so") ---> 65 ctypes.CDLL(cpu_feature_guard_library) File ~/miniforge3/envs/tfm1/lib/python3.9/ctypes/__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode) 371 self._FuncPtr = _FuncPtr 373 if handle is None: --> 374 self._handle = _dlopen(self._name, mode) 375 else: 376 self._handle = handle OSError: dlopen(/Users/k_krishna/.local/lib/python3.9/site-packages/tensorflow/python/platform/../../core/platform/_cpu_feature_guard.so, 0x0006): tried: '/Users/k_krishna/.local/lib/python3.9/site-packages/tensorflow/python/platform/../../core/platform/_cpu_feature_guard.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/Users/k_krishna/.local/lib/python3.9/site-packages/tensorflow/core/platform/_cpu_feature_guard.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) I have tried stack-overflow but non of the solutions worked. Please help me resolve the issue.
Posted
by K_Krishna.
Last updated
.
Post not yet marked as solved
1 Replies
540 Views
Setting up a model with inputs = tf.keras.Input(shape=imageShape) x = inputs x = layers.RandomFlip('horizontal')(x) x = layers.RandomRotation(0.2)(x) x = layers.Dropout(0.2)(x) outputs = layers.Dense(1)(x) Produces this output 2021-12-06 18:19:57.709106: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz 2021-12-06 18:19:57.709239: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:112] Plugin optimizer for device_type GPU is enabled. 4/4 [==============================] - 1s 99ms/step - loss: 0.6075 - accuracy: 0.6613 Initial loss: 0.61 Initial accuracy: 0.66 Epoch 1/2 Traceback (most recent call last): <... etc ...> tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation model/random_flip_1/stateful_uniform_full_int/RngReadAndSkip: Could not satisfy explicit device specification '' because the node {{colocation_node model/random_flip_1/stateful_uniform_full_int/RngReadAndSkip}} was colocated with a group of nodes that required incompatible device '/job:localhost/replica:0/task:0/device:GPU:0'. All available devices [/job:localhost/replica:0/task:0/device:CPU:0, /job:localhost/replica:0/task:0/device:GPU:0]. Colocation Debug Info: Colocation group had the following types and supported devices: Root Member(assigned_device_name_index_=2 requested_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' assigned_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' resource_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' supported_device_types_=[CPU] possible_devices_=[] RngReadAndSkip: CPU _Arg: GPU CPU Colocation members, user-requested devices, and framework assigned devices, if any: model_random_flip_1_stateful_uniform_full_int_rngreadandskip_resource (_Arg) framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0 model/random_flip_1/stateful_uniform_full_int/RngReadAndSkip (RngReadAndSkip) [[{{node model/random_flip_1/stateful_uniform_full_int/RngReadAndSkip}}]] [Op:__inference_train_function_11281] But, running the model without the following layers: x = layers.RandomFlip('horizontal')(x) x = layers.RandomRotation(0.2)(x) works without any issues. I don't quite understand all the details here in the error message. But looks like it's complaining about GPU problems. Any ideas?
Posted
by josiahsrc.
Last updated
.
Post not yet marked as solved
1 Replies
186 Views
I completed till the step of installing tensor flow dependencies which itself posed so many errors, but when I try to run python -m pip install tensorflow-metal or python -m pip install tensorflow-macos I get the following error, ERROR: Could not find a version that satisfies the requirement tensorflow-metal (from versions: none) ERROR: No matching distribution found for tensorflow-metal ERROR: Could not find a version that satisfies the requirement tensorflow-macos (from versions: none) ERROR: No matching distribution found for tensorflow-macos What am I supposed to do now to install tensor flow directly?
Posted Last updated
.
Post marked as solved
1 Replies
339 Views
I followed steps:https://developer.apple.com/metal/tensorflow-plugin/ and installed the tensor flow. But when I tried to import tensorflow on python in my shell I got errors, And not installing TF to the base environment, uninstall numpy, reinstall numpy, all these methods can not work. Appreciate your patience. ImportError Traceback (most recent call last) File ~/miniforge3/lib/python3.9/site-packages/numpy/core/init.py:22, in 21 try: ---> 22 from . import multiarray 23 except ImportError as exc: File ~/miniforge3/lib/python3.9/site-packages/numpy/core/multiarray.py:12, in 10 import warnings ---> 12 from . import overrides 13 from . import _multiarray_umath File ~/miniforge3/lib/python3.9/site-packages/numpy/core/overrides.py:7, in 5 import textwrap ----> 7 from numpy.core._multiarray_umath import ( 8 add_docstring, implement_array_function, _get_implementing_args) 9 from numpy.compat._inspect import getargspec ImportError: dlopen(/Users/myname/miniforge3/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/libcblas.3.dylib Referenced from: /Users/myname/miniforge3/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so Reason: tried: '/Users/myname/miniforge3/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/myname/miniforge3/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/myname/miniforge3/bin/../lib/libcblas.3.dylib' (no such file), '/Users/myname/miniforge3/bin/../lib/libcblas.3.dylib' (no such file), '/usr/local/lib/libcblas.3.dylib' (no such file), '/usr/lib/libcblas.3.dylib' (no such file) During handling of the above exception, another exception occurred: ImportError Traceback (most recent call last) Input In [1], in <cell line: 1>() ----> 1 import tensorflow as tf File ~/miniforge3/lib/python3.9/site-packages/tensorflow/init.py:37, in 34 import sys as _sys 35 import typing as _typing ---> 37 from tensorflow.python.tools import module_util as _module_util 38 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader 40 # Make sure code inside the TensorFlow codebase can use tf2.enabled() at import. File ~/miniforge3/lib/python3.9/site-packages/tensorflow/python/init.py:37, in 29 # We aim to keep this file minimal and ideally remove completely. 30 # If you are adding a new file with @tf_export decorators, 31 # import it in modules_with_exports.py instead. 32 33 # go/tf-wildcard-import 34 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top 36 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow ---> 37 from tensorflow.python.eager import context 39 # pylint: enable=wildcard-import 40 41 # Bring in subpackages. 42 from tensorflow.python import data File ~/miniforge3/lib/python3.9/site-packages/tensorflow/python/eager/context.py:26, in 23 import threading 25 from absl import logging ---> 26 import numpy as np 27 import six 29 from tensorflow.core.framework import function_pb2 File ~/miniforge3/lib/python3.9/site-packages/numpy/init.py:150, in 147 # Allow distributors to run custom init code 148 from . import _distributor_init --> 150 from . import core 151 from .core import * 152 from . import compat File ~/miniforge3/lib/python3.9/site-packages/numpy/core/init.py:48, in 24 import sys 25 msg = """ 26 27 IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! (...) 46 """ % (sys.version_info[0], sys.version_info[1], sys.executable, 47 version, exc) ---> 48 raise ImportError(msg) 49 finally: 50 for envkey in env_added: ImportError: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following: The Python version is: Python3.9 from "/Users/myname/miniforge3/bin/python" The NumPy version is: "1.21.6" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. Original error was: dlopen(/Users/myname/miniforge3/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/libcblas.3.dylib Referenced from: /Users/myname/miniforge3/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so Reason: tried: '/Users/myname/miniforge3/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/myname/miniforge3/lib/python3.9/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/myname/miniforge3/bin/../lib/libcblas.3.dylib' (no such file), '/Users/myname/miniforge3/bin/../lib/libcblas.3.dylib' (no such file), '/usr/local/lib/libcblas.3.dylib' (no such file), '/usr/lib/libcblas.3.dylib' (no such file)
Posted
by jbingl.
Last updated
.
Post not yet marked as solved
1 Replies
974 Views
Hi, I am trying to import keras as followed on my Mac M1 running on MacOS 11.6 but the kernel died during the process. from keras.models import Sequential from keras.layers import Dense The error message in the terminal: [I 15:44:39.003 NotebookApp] Kernel started: e0bec9a2-cde8-42ed-be9d-747ea2841818, name: python3 2022-01-27 15:44:43.203092: F tensorflow/c/c_api_experimental.cc:739] Non-OK-status: tensorflow::RegisterPluggableDevicePlugin(lib_handle->lib_handle) status: FAILED_PRECONDITION: 'host_callback' field in SP_StreamExecutor must be set. Not sure if it's related, I have read the documentation on https://developer.apple.com/metal/tensorflow-plugin/ and the OS requirement is MacOS 12.0+. Is there anyway to solve this issue on my current OS?
Posted
by Zen26.
Last updated
.