tensorflow-metal

RSS for tag

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

tensorflow-metal Documentation

Posts under tensorflow-metal tag

208 Posts
Sort by:
Post not yet marked as solved
1 Replies
102 Views
Since most developers use Mac m1 and all ML developers use TensorFlow why does TensorFlow now work on Mac M1 never? The so-called latest instructions from Apple don't work on Mac OS Ventura 13.2.1 M1 https://developer.apple.com/metal/tensorflow-plugin/ Get this error: RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf ImportError: numpy.core._multiarray_umath failed to import ImportError: numpy.core.umath failed to import Traceback (most recent call last): File "/Users/thomasmann/Downloads/junk.py", line 1, in import tensorflow as tf File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/init.py", line 37, in from tensorflow.python.tools import module_util as _module_util File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/init.py", line 42, in from tensorflow.python import data File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/data/init.py", line 21, in from tensorflow.python.data import experimental File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/data/experimental/init.py", line 96, in from tensorflow.python.data.experimental import service File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/data/experimental/service/init.py", line 419, in from tensorflow.python.data.experimental.ops.data_service_ops import distribute File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py", line 22, in from tensorflow.python.data.experimental.ops import compression_ops File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/data/experimental/ops/compression_ops.py", line 16, in from tensorflow.python.data.util import structure File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/data/util/structure.py", line 22, in from tensorflow.python.data.util import nest File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/data/util/nest.py", line 34, in from tensorflow.python.framework import sparse_tensor as _sparse_tensor File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/framework/sparse_tensor.py", line 24, in from tensorflow.python.framework import constant_op File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/framework/constant_op.py", line 25, in from tensorflow.python.eager import execute File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/eager/execute.py", line 21, in from tensorflow.python.framework import dtypes File "/Users/thomasmann/miniconda3/lib/python3.10/site-packages/tensorflow/python/framework/dtypes.py", line 34, in _np_bfloat16 = _pywrap_bfloat16.TF_bfloat16_type() TypeError: Unable to convert function return value to a Python type! The signature was () -> handle
Posted Last updated
.
Post not yet marked as solved
0 Replies
100 Views
Greetings! I have a MacBook Pro (2018) running macOS Monterey and was wondering if it could be repurposed for machine learning work. I have a Razer Core X, which would enable me to use AMD Radeon 6900 XT as a eGPU supported configuration. Before doing any shopping, my question is whether the usage of TensorFlow is feasible with this setup. I am aware of tensorflow-metal, but if I understand correctly, only natively supported Mac GPUs can be used with it (not eGPUs)? PlaidML is also an option, but it still not clear which external GPUs are supported. Any guidance on this topic will be appreciated.
Posted
by soogui.
Last updated
.
Post not yet marked as solved
15 Replies
10k Views
Hi all, I'm using my new M1 Pro with the latest Mac OS 12.1 and I'm experiencing issues with installing tensorflow. I've created an environment and have it activated. I tried conda install -c apple tensorflow-deps but returned with Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. PackagesNotFoundError: The following packages are not available from current channels: tensorflow-deps Current channels: https://conda.anaconda.org/apple/osx-64 https://conda.anaconda.org/apple/noarch https://repo.anaconda.com/pkgs/main/osx-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/osx-64 https://repo.anaconda.com/pkgs/r/noarch To search for alternate channels that may provide the conda package you're looking for, navigate to https://anaconda.org and use the search bar at the top of the page. Note: you may need to restart the kernel to use updated packages. Did anyone have the same issue and any advice to address this? Thanks, Andrew
Posted
by Andrew14.
Last updated
.
Post not yet marked as solved
2 Replies
177 Views
I'm trying to run the example Cats and Dogs from keras, but when I try to run this: data_augmentation = keras.Sequential( [ layers.RandomFlip("horizontal"), layers.RandomRotation(0.1), ] ) I get this error: --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[5], line 3 1 data_augmentation = keras.Sequential( 2 [ ----> 3 layers.RandomFlip("horizontal"), 4 layers.RandomRotation(0.1), 5 ] 6 ) AttributeError: module 'tensorflow.python.keras.layers' has no attribute 'RandomFlip' Any ideas to solve this? Thanks in advance for your answer.
Posted
by bactrion.
Last updated
.
Post marked as solved
21 Replies
7.5k Views
It doesn't matter if I install miniforge or mamba, directly or through brew, when I try to fit the sample model from https://developer.apple.com/metal/tensorflow-plugin/, even with a simple sequential model, I always get this error. Is there any workaround on this? I'll appreciate any help, thanks! 2022-12-10 11:18:19.941623: W tensorflow/tsl/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz 2022-12-10 11:18:20.427283: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled. 2022-12-10 11:18:21.222950: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x28edf1f90 2022-12-10 11:18:21.223003: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x28edf1f90 2022-12-10 11:18:21.363366: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x28edf1f90 2022-12-10 11:18:21.364757: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x28edf1f90 2022-12-10 11:18:21.388739: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x28edf1f90 2022-12-10 11:18:21.388757: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x28edf1f90 NotFoundError Traceback (most recent call last) Cell In[25], line 2 1 model = create_model() ----> 2 history = model.fit(Xf_train, yf_train, epochs=3, batch_size=64); File /opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/utils/traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs) 67 filtered_tb = _process_traceback_frames(e.traceback) 68 # To get the full stack trace, call: 69 # tf.debugging.disable_traceback_filtering() ---> 70 raise e.with_traceback(filtered_tb) from None 71 finally: 72 del filtered_tb File /opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/tensorflow/python/eager/execute.py:52, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name) 50 try: 51 ctx.ensure_initialized() ---> 52 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name, 53 inputs, attrs, num_outputs) 54 except core._NotOkStatusException as e: 55 if name is not None: NotFoundError: Graph execution error: Detected at node 'StatefulPartitionedCall_4' defined at (most recent call last): File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/ipykernel_launcher.py", line 17, in app.launch_new_instance() File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/traitlets/config/application.py", line 992, in launch_instance app.start() File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 711, in start self.io_loop.start() File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/tornado/platform/asyncio.py", line 215, in start self.asyncio_loop.run_forever() File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/asyncio/base_events.py", line 603, in run_forever self._run_once() File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/asyncio/base_events.py", line 1899, in _run_once handle._run() ... File "/var/folders/f9/bp40pn0d401d974fy48dxm8h0000gn/T/ipykernel_63636/3393788193.py", line 2, in <module> history = model.fit(Xf_train, yf_train, epochs=3, batch_size=64); File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/utils/traceback_utils.py", line 65, in error_handler return fn(*args, **kwargs) File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/engine/training.py", line 1650, in fit tmp_logs = self.train_function(iterator) File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/engine/training.py", line 1249, in train_function return step_function(self, iterator) ...... File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/engine/training.py", line 1222, in run_step outputs = model.train_step(data) File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/engine/training.py", line 1027, in train_step self.optimizer.minimize(loss, self.trainable_variables, tape=tape) File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/optimizers/optimizer_experimental/optimizer.py", line 527, in minimize self.apply_gradients(grads_and_vars) File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/optimizers/optimizer_experimental/optimizer.py", line 1140, in apply_gradients return super().apply_gradients(grads_and_vars, name=name) File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/optimizers/optimizer_experimental/optimizer.py", line 634, in apply_gradients iteration = self._internal_apply_gradients(grads_and_vars) File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/optimizers/optimizer_experimental/optimizer.py", line 1166, in _internal_apply_gradients return tf.__internal__.distribute.interim.maybe_merge_call( File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/optimizers/optimizer_experimental/optimizer.py", line 1216, in _distributed_apply_gradients_fn distribution.extended.update( File "/opt/homebrew/Caskroom/miniforge/base/envs/tf/lib/python3.10/site-packages/keras/optimizers/optimizer_experimental/optimizer.py", line 1211, in apply_grad_to_update_var return self._update_step_xla(grad, var, id(self._var_key(var))) Node: 'StatefulPartitionedCall_4' could not find registered platform with id: 0x28edf1f90 [[{{node StatefulPartitionedCall_4}}]] [Op:__inference_train_function_1241]
Posted
by ppobar.
Last updated
.
Post not yet marked as solved
3 Replies
1.1k Views
Hi,I cannot predict with my model on Apple M1pro. I get a error: Traceback (most recent call last):   File "transformer_pe.py", line 605, in     bgru_main()   File "transformer_pe.py", line 400, in bgru_main     main(traindataSetPath, weightPath, batchSize, maxLen, vectorDim, layers, dropout)   File "transformer_pe.py", line 358, in main     model.fit(x_train, y_train, batch_size=batchSize, epochs=10)   File "/Users/icey/miniforge3/envs/py38/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 1183, in fit     tmp_logs = self.train_function(iterator)   File "/Users/icey/miniforge3/envs/py38/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 889, in call     result = self._call(*args, **kwds)   File "/Users/icey/miniforge3/envs/py38/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 950, in _call     return self._stateless_fn(*args, **kwds)   File "/Users/icey/miniforge3/envs/py38/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 3023, in call     return graph_function._call_flat(   File "/Users/icey/miniforge3/envs/py38/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 1960, in _call_flat     return self._build_call_outputs(self._inference_function.call(   File "/Users/icey/miniforge3/envs/py38/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 591, in call     outputs = execute.execute(   File "/Users/icey/miniforge3/envs/py38/lib/python3.8/site-packages/tensorflow/python/eager/execute.py", line 59, in quick_execute     tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name, tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation model/bert_block/encoder_0/multiheadattention/query/einsum/Einsum/ReadVariableOp: Could not satisfy explicit device specification '' because the node {{colocation_node model/bert_block/encoder_0/multiheadattention/query/einsum/Einsum/ReadVariableOp}} 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_=[] ResourceApplyAdaMax: CPU  ReadVariableOp: GPU CPU  _Arg: GPU CPU  Colocation members, user-requested devices, and framework assigned devices, if any:   model_bert_block_encoder_0_multiheadattention_query_einsum_einsum_readvariableop_resource (_Arg)  framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0   adamax_adamax_update_2_resourceapplyadamax_m (_Arg)  framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0   adamax_adamax_update_2_resourceapplyadamax_v (_Arg)  framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0   model/bert_block/encoder_0/multiheadattention/query/einsum/Einsum/ReadVariableOp (ReadVariableOp)    Adamax/Adamax/update_2/ResourceApplyAdaMax (ResourceApplyAdaMax) /job:localhost/replica:0/task:0/device:GPU:0 [[{{node model/bert_block/encoder_0/multiheadattention/query/einsum/Einsum/ReadVariableOp}}]] [Op:__inference_train_function_3353] (py38) icey@IceydeMacBook-Pro 20220204code % python hello.py          Metal device set to: Apple M1 Pro systemMemory: 32.00 GB maxCacheSize: 10.67 GB
Posted
by icey34.
Last updated
.
Post not yet marked as solved
0 Replies
101 Views
I found out that tf.einsum is extremely slow when running on Apple Silicone. And it's due to tf.einsum being placed on CPU instead of GPU. This causes very low GPU utilization and slowness of the operation itself. I tried forcing it on GPU, but does not work. It can be reproduced with following code that logs device placement for tf.einsum. import tensorflow as tf # https://www.tensorflow.org/guide/gpu#logging_device_placement tf.debugging.set_log_device_placement(True) print(tf.__version__) print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU'))) B=1000 S=200 N=16 K=64 a = tf.random.uniform(shape=[B,N,S,K], minval=0.0, maxval=100.0, dtype=float) b = tf.random.uniform(shape=[B,N,S,K], minval=0.0, maxval=100.0, dtype=float) tf.einsum('BNSK,BNTK->BNTS', a,b) # Notice in the output Einsum is placed on CPU. Output: Executing op Einsum in device /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119144: I tensorflow/core/common_runtime/placer.cc:114] inputs_0: (_Arg): /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119182: I tensorflow/core/common_runtime/placer.cc:114] inputs_1: (_Arg): /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119191: I tensorflow/core/common_runtime/placer.cc:114] Einsum: (Einsum): /job:localhost/replica:0/task:0/device:CPU:0 2023-03-08 16:44:01.119197: I tensorflow/core/common_runtime/placer.cc:114] output_RetVal: (_Retval): /job:localhost/replica:0/task:0/device:CPU:0 If I use tf.matmul, then everything happen on GPU which is what I want. With this limitation I basically have to convert all the code that uses tf.einsum to using tf.matmul and is very inconvenient. Has anyone noticed the same problem? What's your solution?
Posted
by TimDeng.
Last updated
.
Post not yet marked as solved
3 Replies
1.1k Views
I'm trying to use tensorflow, but I can't import it. I followed the steps on the Apple website to download and install Tensorflow, and everything appears to be ok, but when I try to import tensorflow, I get some errors. What should I do? Errors: TypeError: Unable to convert function return value to a Python type! The signature was () -> handle RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf ImportError: numpy.core._multiarray_umath failed to import ImportError: numpy.core.umath failed to import what I did: conda create --name myenv python conda activate myenv conda install -c apple tensorflow-deps python -m pip install tensorflow-macos python -m pip install tensorflow-metal conda list: Thanks, Ed
Posted
by Eddluiz.
Last updated
.
Post not yet marked as solved
0 Replies
140 Views
In https://github.com/tensorflow/tensorflow/commit/84f40925e929d05e72ab9234e53c729224e3af38 (about to be released as tf 2.12) they removed the protobuf dependency cap. This now allows using tf (2.12), protobuf (>4.2) and grpc libraries (>1.51.3) which now all have native wheels for M1/M2. This makes it much easier to install tensorflow on new M1/M2 computers and use it alongside gRPC-based serving frameworks. I would thus really hope to have a tensorflow-macos 2.12 version to be released in a timely manner once tf 2.12 is out.
Posted
by Zahlii.
Last updated
.
Post not yet marked as solved
9 Replies
5.9k Views
I installed TensorFlow according to this link: https://developer.apple.com/metal/tensorflow-plugin/ Mac M1 Pro macOS Monterey 12.3 When I try to import tensorflow: import tensorflow I get the following error: RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd ImportError: numpy.core._multiarray_umath failed to import ImportError: numpy.core.umath failed to import Traceback (most recent call last):   File "<stdin>", line 1, in <module>   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/__init__.py", line 37, in <module>     from tensorflow.python.tools import module_util as _module_util   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/__init__.py", line 42, in <module>     from tensorflow.python import data   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/data/__init__.py", line 21, in <module>     from tensorflow.python.data import experimental   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/data/experimental/__init__.py", line 95, in <module>     from tensorflow.python.data.experimental import service   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/data/experimental/service/__init__.py", line 387, in <module>     from tensorflow.python.data.experimental.ops.data_service_ops import distribute   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py", line 23, in <module>     from tensorflow.python.data.experimental.ops import compression_ops   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/data/experimental/ops/compression_ops.py", line 16, in <module>     from tensorflow.python.data.util import structure   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/data/util/structure.py", line 22, in <module>     from tensorflow.python.data.util import nest   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/data/util/nest.py", line 36, in <module>     from tensorflow.python.framework import sparse_tensor as _sparse_tensor   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/framework/sparse_tensor.py", line 24, in <module>     from tensorflow.python.framework import constant_op   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/framework/constant_op.py", line 25, in <module>     from tensorflow.python.eager import execute   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/eager/execute.py", line 23, in <module>     from tensorflow.python.framework import dtypes   File "/Users/fryderykkogl/miniforge3/lib/python3.9/site-packages/tensorflow/python/framework/dtypes.py", line 29, in <module>     _np_bfloat16 = _pywrap_bfloat16.TF_bfloat16_type() TypeError: Unable to convert function return value to a Python type! The signature was () -> handle Any ideas on what I can do? I couldn't find this error anywhere
Posted Last updated
.
Post not yet marked as solved
2 Replies
505 Views
Summary: I have noticed low test accuracy during and after training Tensorflow LSTM models on M1-based Macs with tensorflow-metal/GPU. While I have observed this over more than one model, I chose to use a standard Github repo to reproduce the problem, utilizing a community and educational example based on the Sequential Models Course, Deep Learning Specialization (Andrew Ng). Steps to Reproduce: git clone https://github.com/omerbsezer/LSTM_RNN_Tutorials_with_Demo.git cd LSTM_RNN_Tutorials_with_Demo/SentimentAnalysisProject python main.py Results Test accuracy (CPU only, without tensorflow-metal): ~83% Test accuracy (GPU using tensorflow-metal): ~37% A similar pattern can be observed in epoch steps for accuracy, loss etc. System Details Model: Macbook Pro (16-inch, 2021) Chip: Apple M1 Max Memory: 64GB OS: MacOS 12.0.1 Key Libraries: tensforflow-metal (0.2), tensorflow-macos (2.6.0), python (3.9.7)
Posted
by radagast.
Last updated
.
Post not yet marked as solved
6 Replies
724 Views
Following the TensorFlow-Metal installation instructions, I get the following error when running the test script: 2023-01-19 19:09:54.661559: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x7f7fff9c4750 My system: Mac mini (2018) MacOS Monterey Version 12.6.2 Memory: 32GB Graphics: (eGPU) AMD Radeon RX Vega 64 8GB
Posted
by jnevin.
Last updated
.
Post not yet marked as solved
1 Replies
230 Views
Hi, I have installed tensorflow-macos on an apple-silicon machine, but I am unable to correctly install tensorflow-datasets. Here what I am doing: conda create -n myenv python=3.10 -c conda-forge conda activate myenv conda install -c apple tensorflow-deps python -m pip install tensorflow-macos python -m pip install tensorflow-metal python -m pip install tensorflow-datasets Here I run into an error: ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. tensorflow-macos 2.11.0 requires protobuf<3.20,>=3.9.2, but you have protobuf 3.20.3 which is incompatible. Successfully installed click-8.1.3 dm-tree-0.1.8 etils-1.0.0 googleapis-common-protos-1.58.0 importlib_resources-5.12.0 promise-2.3 protobuf-3.20.3 psutil-5.9.4 tensorflow-datasets-4.8.3 tensorflow-metadata-1.12.0 toml-0.10.2 tqdm-4.64.1 zipp-3.15.0 I am also trying to install KerasCV with Custom Ops from source and I run into the same dependency error on protobuf. It seems that one of the dependencies of tensorflow-datasets and KerasCV requires protobuf 3.20, which in turn is not compatible with my version of tensorflow-macos. If I try to downgrade protobuf to version 3.19.4 I get: ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. googleapis-common-protos 1.58.0 requires protobuf!=3.20.0,!=3.20.1,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5, but you have protobuf 3.19.4 which is incompatible. Here some information about the package versions: tensorflow-datasets    4.8.3          pypi_0  pypi tensorflow-deps      2.10.0            0  apple tensorflow-estimator   2.11.0          pypi_0  pypi tensorflow-macos     2.11.0          pypi_0  pypi tensorflow-metadata    1.12.0          pypi_0  pypi tensorflow-metal     0.7.1          pypi_0  pypi Has anyone been able to create an environment with the correct dependencies?
Posted
by martina_p.
Last updated
.
Post not yet marked as solved
0 Replies
136 Views
env: python 3.10 macos 13.2.1 arch: m2 tensorflow-macos 2.11 tensorflow-metal 0.7.1 When I run model.fit from Keras, I occasionally get the following errors: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled. /AppleInternal/Library/BuildRoots/9e200cfa-7d96-11ed-886f-a23c4f261b56/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShadersGraph/mpsgraph/MetalPerformanceShadersGraph/Core/Files/MPSGraphExecutable.mm:626: failed assertion `Error: Input feed tensor not found in placeholders, tensor corresponds to operation: mps_placeholder'
Posted
by boluoyu.
Last updated
.
Post not yet marked as solved
1 Replies
362 Views
I am getting error after running following code : model.fit(x_train, y_train, epochs=10) After running above code I am getting following error: Epoch 1/10 NotFoundError Traceback (most recent call last) Cell In[11], line 1 ----> 1 model.fit(x_train, y_train, epochs=10) ... ... ... ... ... Node: 'StatefulPartitionedCall_2' could not find registered platform with id: 0x112e240d0 [[{{node StatefulPartitionedCall_2}}]] [Op:__inference_train_function_763]
Posted
by kush0123.
Last updated
.
Post not yet marked as solved
37 Replies
20k Views
Device: MacBook Pro 16 M1 Max, 64GB running MacOS 12.0.1. I tried setting up GPU Accelerated TensorFlow on my Mac using the following steps: Setup: XCode CLI / Homebrew/ Miniforge Conda Env: Python 3.9.5 conda install -c apple tensorflow-deps python -m pip install tensorflow-macos python -m pip install tensorflow-metal brew install libjpeg conda install -y matplotlib jupyterlab In Jupyter Lab, I try to execute this code: from tensorflow.keras import layers from tensorflow.keras import models model = models.Sequential() model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1))) 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, activation='softmax')) model.summary() The code executes, but I get this warning, indicating no GPU Acceleration can be used as it defaults to a 0MB GPU. Error: Metal device set to: Apple M1 Max 2021-10-27 08:23:32.872480: 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-10-27 08:23:32.872707: 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>) Anyone has any idea how to fix this? I came across a bunch of posts around here related to the same issue but with no solid fix. I created a new question as I found the other questions less descriptive of the issue, and wanted to comprehensively depict it. Any fix would be of much help.
Posted Last updated
.
Post not yet marked as solved
0 Replies
215 Views
I have some script which crashes on Apple M1 hardware with tensorflow-macos 2.11.0. It should not crash. It does not crash on other hardware. I think the code should work. It does work fine on other hardware. But even if there is sth wrong with the code, it still should not crash, but throw some exception instead. I also reported this here: https://github.com/tensorflow/tensorflow/issues/59780 On Apple M1 hardware: Checkout https://github.com/rwth-i6/returnn. (Maybe commit 3a67da87c2fd8783c5c2469d72cf1319b5b45837 to be sure.) Run: python3 tests/test_TFUtil.py test_get_variable_grad_from_update_ops The relevant code: https://github.com/rwth-i6/returnn/blob/3a67da87c2fd8783c5c2469d72cf1319b5b45837/tests/test_TFUtil.py#L3507 https://github.com/rwth-i6/returnn/blob/3a67da87c2fd8783c5c2469d72cf1319b5b45837/returnn/tf/util/basic.py#L6649 Relevant log output ... grad: Tensor("test_get_variable_grad_from_update_ops/gradients_2/test_get_variable_grad_from_update_ops/sub_grad/tuple/control_dependency:0", shape=(), dtype=float32) Fatal Python error: Segmentation fault Thread 0x0000000103500580 (most recent call first): File "/Users/az/.local/lib/python3.9/site-packages/tensorflow/python/client/session.py", line 1454 in _call_tf_sessionrun File "/Users/az/.local/lib/python3.9/site-packages/tensorflow/python/client/session.py", line 1361 in _run_fn File "/Users/az/.local/lib/python3.9/site-packages/tensorflow/python/client/session.py", line 1378 in _do_call File "/Users/az/.local/lib/python3.9/site-packages/tensorflow/python/client/session.py", line 1371 in _do_run File "/Users/az/.local/lib/python3.9/site-packages/tensorflow/python/client/session.py", line 1191 in _run File "/Users/az/.local/lib/python3.9/site-packages/tensorflow/python/client/session.py", line 968 in run File "/Users/az/Programmierung/crnn/tests/test_TFUtil.py", line 3529 in test_get_variable_grad_from_update_ops File "/Users/az/Programmierung/crnn/tests/test_TFUtil.py", line 4559 in <module> fish: Job 1, 'python3 tests/test_TFUtil.py te…' terminated by signal SIGSEGV (Address boundary error) Stack trace in LLDB in the crashing thread: * thread #28, queue = 'metal gpu stream', stop reason = EXC_BAD_ACCESS (code=1, address=0xbeaddc3f8010) * frame #0: 0x00000001836ea5a0 libobjc.A.dylib`objc_msgSend + 32 frame #1: 0x000000018df96d38 MPSNDArray`___lldb_unnamed_symbol1550 + 2292 frame #2: 0x000000018df98bbc MPSNDArray`___lldb_unnamed_symbol1567 + 300 frame #3: 0x000000018df991e8 MPSNDArray`___lldb_unnamed_symbol1569 + 176 frame #4: 0x0000000159a7d2b8 libmetal_plugin.dylib`invocation function for block in double dispatchOneKernel<MPSNDArrayIdentity>(MetalStream*, MPSNDArrayIdentity*, NSArray*, MPSNDArray*, char const*, MPSKernelDAGObject*) + 120 frame #5: 0x00000001836a01b4 libdispatch.dylib`_dispatch_client_callout + 20 frame #6: 0x00000001836af414 libdispatch.dylib`_dispatch_lane_barrier_sync_invoke_and_complete + 56 frame #7: 0x0000000159a7d140 libmetal_plugin.dylib`double dispatchOneKernel<MPSNDArrayIdentity>(MetalStream*, MPSNDArrayIdentity*, NSArray*, MPSNDArray*, char const*, MPSKernelDAGObject*) + 120 frame #8: 0x0000000159a7fffc libmetal_plugin.dylib`metal_plugin::MPSApplyMomentumOp<float>::Compute(metal_plugin::OpKernelContext*) + 2768 frame #9: 0x0000000159a7f2fc libmetal_plugin.dylib`void metal_plugin::ComputeOpKernel<metal_plugin::MPSApplyMomentumOp<float> >(void*, TF_OpKernelContext*) + 44 frame #10: 0x000000014cd00028 libtensorflow_framework.2.dylib`tensorflow::PluggableDevice::Compute(tensorflow::OpKernel*, tensorflow::OpKernelContext*) + 148 frame #11: 0x000000014cc847f0 libtensorflow_framework.2.dylib`tensorflow::(anonymous namespace)::ExecutorState<tensorflow::SimplePropagatorState>::Process(tensorflow::SimplePropagatorState::TaggedNode, long long) + 3764 frame #12: 0x000000028a47eb6c _pywrap_tensorflow_internal.so`Eigen::ThreadPoolTempl<tsl::thread::EigenEnvironment>::WorkerLoop(int) + 1496 frame #13: 0x000000028a47e468 _pywrap_tensorflow_internal.so`tsl::thread::EigenEnvironment::CreateThread(std::__1::function<void ()>)::'lambda'()::operator()() const + 80 frame #14: 0x000000014cb9e878 libtensorflow_framework.2.dylib`tsl::(anonymous namespace)::PThread::ThreadFn(void*) + 120 frame #15: 0x000000018386426c libsystem_pthread.dylib`_pthread_start + 148 As you see from the output, the crash happens in the last session.run([minimize_op, grad]).
Posted Last updated
.
Post not yet marked as solved
1 Replies
281 Views
python Python 3.10.9 (main, Jan 11 2023, 09:18:18) [Clang 14.0.6 ] on darwin Type "help", "copyright", "credits" or "license" for more information. import tensorflow RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf ImportError: numpy.core._multiarray_umath failed to import ImportError: numpy.core.umath failed to import Traceback (most recent call last): File "", line 1, in File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/init.py", line 37, in from tensorflow.python.tools import module_util as _module_util File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/init.py", line 42, in from tensorflow.python import data File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/data/init.py", line 21, in from tensorflow.python.data import experimental File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/data/experimental/init.py", line 96, in from tensorflow.python.data.experimental import service File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/data/experimental/service/init.py", line 419, in from tensorflow.python.data.experimental.ops.data_service_ops import distribute File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py", line 22, in from tensorflow.python.data.experimental.ops import compression_ops File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/data/experimental/ops/compression_ops.py", line 16, in from tensorflow.python.data.util import structure File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/data/util/structure.py", line 22, in from tensorflow.python.data.util import nest File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/data/util/nest.py", line 34, in from tensorflow.python.framework import sparse_tensor as _sparse_tensor File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/framework/sparse_tensor.py", line 24, in from tensorflow.python.framework import constant_op File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/framework/constant_op.py", line 25, in from tensorflow.python.eager import execute File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/eager/execute.py", line 21, in from tensorflow.python.framework import dtypes File "/Users/$USER/miniconda/lib/python3.10/site-packages/tensorflow/python/framework/dtypes.py", line 34, in _np_bfloat16 = _pywrap_bfloat16.TF_bfloat16_type() TypeError: Unable to convert function return value to a Python type! The signature was () -> handle
Posted Last updated
.