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
2 Replies
1.4k Views
Tensorflow-macos v2.5 does run on my M1 MacBook Pro by downloading the Apple tensorflow deps and conda env. However, when I download the PyQt5 package, the ERROR: PyQt5 has a pyproject.toml file that does not comply with PEP 518: 'build-system.requires' contains an invalid requirement: 'sip >=5.0.1 <6' apears while I can install qt5 directly without the tensorflow deps. Error also comes out when I re-installing numpy whose version is specifically asked by tensorflow-macos (why re-install: opencv automatically unistall the tensorflow's numpy and installs another which tensorflow-macos cannot use), showing Could not build wheels for numpy which use PEP 517 and cannot be installed directly. What should I do? The only way I can fix the problem by myself is to clear the conda env and install deps, tensorflow, metal pkg etc. once again and avoid the using of qt5 and deleting of original numpy. What a bad experience.
Posted
by
Post not yet marked as solved
2 Replies
382 Views
Thanks very much for tensorflow-metal. Is there a timeline for when it will support multiple GPUs? Alternately, is there a way to start two instances and force each to different GPUs? Then two sessions could be run in parallel. Thanks!
Posted
by
Post not yet marked as solved
4 Replies
1k Views
When I fit the data, the loss didn't decrease. Using the same codes on windows PC, I can get right results . And other codes including fit() also can't work and faced the same error. The errors shows the followings : 2021-07-29 16:55:02.257192: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:176] None of the MLIR Optimization Passes are enabled (registered 2) 2021-07-29 16:55:02.258033: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz 2021-07-29 16:55:02.339241: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:112] Plugin optimizer for device_type GPU is enabled. And the codes are : import tensorflow as tf import numpy as np from tensorflow import keras from matplotlib import pyplot as plt model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])]) model.compile(optimizer='sgd', loss='mean_squared_error') xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float) ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float) model.fit(xs, ys, epochs=500)
Posted
by
Post not yet marked as solved
5 Replies
2.1k Views
System information Script can be found below MacBook Pro M1 (Mac OS Big Sir (11.5.1)) TensorFlow installed from (source) TensorFlow version (2.5 version) with Metal Support Python version: 3.9 GPU model and memory: MacBook Pro M1 and 16 GB Steps needed for installing Tensorflow with metal support. https://developer.apple.com/metal/tensorflow-plugin/ I am trying to train a model on Macbook Pro M1, but the performance is so bad and the train doesn't work properly. It takes a ridiculously long time just for a single epoch. Code needed for reproducing this behavior. import tensorflow as tf from tensorflow.keras.datasets import imdb from tensorflow.keras.layers import Embedding, Dense, LSTM from tensorflow.keras.losses import BinaryCrossentropy from tensorflow.keras.models import Sequential from tensorflow.keras.optimizers import Adam from tensorflow.keras.preprocessing.sequence import pad_sequences # Model configuration additional_metrics = ['accuracy'] batch_size = 128 embedding_output_dims = 15 loss_function = BinaryCrossentropy() max_sequence_length = 300 num_distinct_words = 5000 number_of_epochs = 5 optimizer = Adam() validation_split = 0.20 verbosity_mode = 1 # Disable eager execution tf.compat.v1.disable_eager_execution() # Load dataset (x_train, y_train), (x_test, y_test) = imdb.load_data(num_words=num_distinct_words) print(x_train.shape) print(x_test.shape) # Pad all sequences padded_inputs = pad_sequences(x_train, maxlen=max_sequence_length, value = 0.0) # 0.0 because it corresponds with <PAD> padded_inputs_test = pad_sequences(x_test, maxlen=max_sequence_length, value = 0.0) # 0.0 because it corresponds with <PAD> # Define the Keras model model = Sequential() model.add(Embedding(num_distinct_words, embedding_output_dims, input_length=max_sequence_length)) model.add(LSTM(10)) model.add(Dense(1, activation='sigmoid')) # Compile the model model.compile(optimizer=optimizer, loss=loss_function, metrics=additional_metrics) # Give a summary model.summary() # Train the model history = model.fit(padded_inputs, y_train, batch_size=batch_size, epochs=number_of_epochs, verbose=verbosity_mode, validation_split=validation_split) # Test the model after training test_results = model.evaluate(padded_inputs_test, y_test, verbose=False) print(f'Test results - Loss: {test_results[0]} - Accuracy: {100*test_results[1]}%') I have noticed this same problem with LSTM layers Also, this issue is been reported in Keras and they can't debug. Keras issue https://github.com/keras-team/keras/issues/15003
Posted
by
Post not yet marked as solved
5 Replies
1.4k Views
I try to install and fix the tensorflow on my new Mac m1 following a lot the instuctions in the internet but it's not work. The kernel will died when try to import tensorflow. `(tensorflow-metal) ampnapat@Amps-MacBook-Pro ~ % python -m pip install tensorflow-macos ERROR: Could not find a version that satisfies the requirement tensorflow-macos (from versions: none) ERROR: No matching distribution found for tensorflow-macos (tensorflow-metal) ampnapat@Amps-MacBook-Pro ~ % python -m pip install tensorflow-metal ERROR: Could not find a version that satisfies the requirement tensorflow-metal (from versions: none) ERROR: No matching distribution found for tensorflow-metal`
Posted
by
Post not yet marked as solved
1 Replies
326 Views
Details here: https://stackoverflow.com/questions/68551935/why-does-my-tensorflow-model-stop-training I can run the VariationalDeepSemantic Hashing model in an Anaconda python 3.85 virtual environment with tensorflow 2.5 on CPUs. If I run the same code in the tensorflow-metal virtual environment with python 3.82, accessing my AMD Radeon Pro 5700 XT GPU, the process stops training at epoch 5 on the 5200 batch.
Posted
by
Post not yet marked as solved
2 Replies
1.2k Views
Dear Developers, I am a newbie on the TensorFlow business. I have however managed to install TensorFlow (macOS and metal) on M1 MacBook Air as detailed in this website (https://developer.apple.com/metal/tensorflow-plugin/) However, when I try to run an example code (https://github.com/keras-team/keras-io/blob/master/examples/vision/mnist_convnet.py), I got issues that I cannot understand `2021-08-01 00:28:43.807922: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:176] None of the MLIR Optimization Passes are enabled (registered 2) 2021-08-01 00:28:43.808097: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz Epoch 1/15 2021-08-01 00:28:43.911127: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:112] Plugin optimizer for device_type GPU is enabled. 2021-08-01 00:28:43.984 python[20105:3940931] -[MPSNDArrayIdentity encodeToCommandEncoder:commandBuffer:sourceArrays:resultState:destinationArray:kernelDAGObject:]: unrecognized selector sent to instance 0x1682e8560 2021-08-01 00:28:43.987 python[20105:3940931] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MPSNDArrayIdentity encodeToCommandEncoder:commandBuffer:sourceArrays:resultState:destinationArray:kernelDAGObject:]: unrecognized selector sent to instance 0x1682e8560' *** First throw call stack: ( 0   CoreFoundation                      0x0000000180de2320 __exceptionPreprocess + 240 1   libobjc.A.dylib                     0x0000000180b10c04 objc_exception_throw + 60 2   CoreFoundation                      0x0000000180e71020 -[NSObject(NSObject) __retain_OA] + 0 3   CoreFoundation                      0x0000000180d44184 ___forwarding___ + 1444 4   CoreFoundation                      0x0000000180d43b30 _CF_forwarding_prep_0 + 96 5   libmetal_plugin.dylib               0x0000000150a55db4 ___ZN12metal_plugin14MPSApplyAdamOpIfE7ComputeEPNS_15OpKernelContextE_block_invoke.115 + 92 6   libdispatch.dylib                   0x0000000180abd420 _dispatch_client_callout + 20 7   libdispatch.dylib                   0x0000000180acba98 _dispatch_lane_barrier_sync_invoke_and_complete + 60 8   libmetal_plugin.dylib               0x0000000150a533c0 _ZN12metal_plugin14MPSApplyAdamOpIfE7ComputeEPNS_15OpKernelContextE + 4884 9   libmetal_plugin.dylib               0x0000000150a51e78 _ZN12metal_pluginL15ComputeOpKernelINS_14MPSApplyAdamOpIfEEEEvPvP18TF_OpKernelContext + 44 10  _pywrap_tensorflow_internal.so      0x0000000130076460 _ZN10tensorflow15PluggableDevice7ComputeEPNS_8OpKernelEPNS_15OpKernelContextE + 148 11  libtensorflow_framework.2.dylib     0x0000000123a78664 _ZN10tensorflow12_GLOBAL__N_113ExecutorStateINS_15PropagatorStateEE7ProcessENS2_10TaggedNodeEx + 3080 12  libtensorflow_framework.2.dylib     0x0000000123a79dbc _ZNSt3__110__function6__funcIZN10tensorflow12_GLOBAL__N_113ExecutorStateINS2_15PropagatorStateEE7RunTaskIZNS6_13ScheduleReadyEPN4absl14lts_2020_09_2313InlinedVectorINS5_10TaggedNodeELm8ENS_9allocatorISB_EEEEPNS5_20TaggedNodeReadyQueueEEUlvE0_EEvOT_EUlvE_NSC_ISL_EEFvvEEclEv + 56 13  _pywrap_tensorflow_internal.so      0x00000001307aa230 _ZN5Eigen15ThreadPoolTemplIN10tensorflow6thread16EigenEnvironmentEE10WorkerLoopEi + 1508 14  _pywrap_tensorflow_internal.so      0x00000001307a9b28 _ZZN10tensorflow6thread16EigenEnvironment12CreateThreadENSt3__18functionIFvvEEEENKUlvE_clEv + 80 15  libtensorflow_framework.2.dylib     0x0000000124014b08 _ZN10tensorflow12_GLOBAL__N_17PThread8ThreadFnEPv + 120 16  libsystem_pthread.dylib             0x0000000180c6a06c _pthread_start + 320 17  libsystem_pthread.dylib             0x0000000180c64da0 thread_start + 8 ) libc++abi.dylib: terminating with uncaught exception of type NSException` Do you have an idea what could be the reason? I would like also to benefit from GPU acceleration. I am running on macOS Big Sur 11.2.3. Many thanks, All the best
Posted
by
Post not yet marked as solved
2 Replies
2.0k Views
I am trying to profile a tensorflow 2.5 model with tensorflow-macos and tensorflow-metal. I am getting this error: AttributeError: module 'tensorflow.compat.v1.profiler' has no attribute 'experimental' Here's a code snippet: import tensorflow as tf import numpy as np from utils import * tf.compat.v1.enable_v2_behavior() from tensorflow.python.framework.ops import disable_eager_execution disable_eager_execution() options = tf.profiler.experimental.ProfilerOptions(host_tracer_level = 3,                                                    python_tracer_level = 1,                                                    device_tracer_level = 1) tf.profiler.experimental.start('~/logdir', options=options) ... tf.profiler.experimental.stop() % pip list Package                    Version -------------------------- ------------------- absl-py                    0.12.0 anyio                      3.2.1 appnope                    0.1.2 argon2-cffi                20.1.0 astunparse                 1.6.3 async-generator            1.10 attrs                      21.2.0 Babel                      2.9.1 backcall                   0.2.0 bleach                     3.3.1 cachetools                 4.2.2 certifi                    2021.5.30 cffi                       1.14.6 charset-normalizer         2.0.1 cloudpickle                1.6.0 cycler                     0.10.0 Cython                     0.29.24 debugpy                    1.3.0 decorator                  5.0.9 defusedxml                 0.7.1 dill                       0.3.4 dm-tree                    0.1.6 dotmap                     1.3.23 entrypoints                0.3 flatbuffers                1.12 future                     0.18.2 gast                       0.4.0 gensim                     4.0.1 google-auth                1.32.1 google-auth-oauthlib       0.4.4 google-pasta               0.2.0 googleapis-common-protos   1.53.0 grpcio                     1.34.1 gviz-api                   1.9.0 gym                        0.18.3 h5py                       3.1.0 idna                       3.2 importlib-resources        5.2.0 ipykernel                  6.0.1 ipython                    7.25.0 ipython-genutils           0.2.0 ipywidgets                 7.6.3 jedi                       0.18.0 Jinja2                     3.0.1 json5                      0.9.6 jsonschema                 3.2.0 jupyter-client             6.1.12 jupyter-core               4.7.1 jupyter-server             1.9.0 jupyterlab                 3.0.16 jupyterlab-pygments        0.1.2 jupyterlab-server          2.6.1 jupyterlab-widgets         1.0.0 keras-nightly              2.5.0.dev2021032900 Keras-Preprocessing        1.1.2 kiwisolver                 1.3.1 Markdown                   3.3.4 MarkupSafe                 2.0.1 matplotlib                 3.4.2 matplotlib-inline          0.1.2 memory-profiler            0.58.0 mistune                    0.8.4 nbclassic                  0.3.1 nbclient                   0.5.3 nbconvert                  6.1.0 nbformat                   5.1.3 nest-asyncio               1.5.1 notebook                   6.4.0 numpy                      1.19.5 oauthlib                   3.1.1 opt-einsum                 3.3.0 packaging                  21.0 pandas                     1.3.0 pandocfilters              1.4.3 parso                      0.8.2 pexpect                    4.8.0 pickleshare                0.7.5 Pillow                     8.2.0 pip                        21.2.1 prometheus-client          0.11.0 promise                    2.3 prompt-toolkit             3.0.19 protobuf                   3.17.3 psutil                     5.8.0 ptyprocess                 0.7.0 pyasn1                     0.4.8 pyasn1-modules             0.2.8 pybind11                   2.6.2 pycparser                  2.20 pyglet                     1.5.15 Pygments                   2.9.0 pyparsing                  2.4.7 pyrsistent                 0.18.0 python-dateutil            2.8.2 pytz                       2021.1 pyzmq                      22.1.0 requests                   2.26.0 requests-oauthlib          1.3.0 requests-unixsocket        0.2.0 rsa                        4.7.2 scipy                      1.7.0 Send2Trash                 1.7.1 setuptools                 41.2.0 six                        1.15.0 smart-open                 5.1.0 sniffio                    1.2.0 tensorboard                2.5.0 tensorboard-data-server    0.6.1 tensorboard-plugin-profile 2.4.0 tensorboard-plugin-wit     1.8.0 tensorflow-datasets        4.3.0 tensorflow-estimator       2.5.0 tensorflow-hub             0.12.0 tensorflow-macos           2.5.0 tensorflow-metadata        1.1.0 tensorflow-metal           0.1.1 tensorflow-probability     0.13.0 termcolor                  1.1.0 terminado                  0.10.1 testpath                   0.5.0 tornado                    6.1 tqdm                       4.61.2 traitlets                  5.0.5 typing-extensions          3.7.4.3 urllib3                    1.26.6 wcwidth                    0.2.5 webencodings               0.5.1 websocket-client           1.1.0 Werkzeug                   2.0.1 wheel                      0.36.2 widgetsnbextension         3.5.1 wrapt                      1.12.1 zipp                       3.5.0
Posted
by
Post marked as solved
2 Replies
337 Views
Hi I'd just like to confirm that there is no OpKernel 'AssignVariableOp' for DTYPE=dt_COMPLEX 64 in the tensorflow-metal plugin. This is the error I'm getting: And this is some example code that will generate this error: I've tried a few different ways of getting a Variable of complex64 type on the GPU but none seem to work. If support is not included in the plugin, will it be added in the future? I'm not familiar enough with C++ to write my own. Thanks Edit: I'm on an M1 MacBook Air with 16GB of RAM
Posted
by
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
by
Post not yet marked as solved
8 Replies
2.1k Views
Hello, I cannot predict with my model on Apple M1. I get a error: Traceback (most recent call last):   File "/Users/martin/Documents/Projects/rl-toolkit/rl_toolkit/__main__.py", line 154, in <module>     agent.run()   File "/Users/martin/Documents/Projects/rl-toolkit/rl_toolkit/training.py", line 213, in run     losses = self._train(sample)   File "/Users/martin/miniforge3/lib/python3.9/site-packages/tensorflow/python/eager/def_function.py", line 889, in __call__     result = self._call(*args, **kwds)   File "/Users/martin/miniforge3/lib/python3.9/site-packages/tensorflow/python/eager/def_function.py", line 950, in _call     return self._stateless_fn(*args, **kwds)   File "/Users/martin/miniforge3/lib/python3.9/site-packages/tensorflow/python/eager/function.py", line 3023, in __call__     return graph_function._call_flat(   File "/Users/martin/miniforge3/lib/python3.9/site-packages/tensorflow/python/eager/function.py", line 1960, in _call_flat     return self._build_call_outputs(self._inference_function.call(   File "/Users/martin/miniforge3/lib/python3.9/site-packages/tensorflow/python/eager/function.py", line 591, in call     outputs = execute.execute(   File "/Users/martin/miniforge3/lib/python3.9/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 ReadVariableOp: Could not satisfy explicit device specification '' because the node {{colocation_node 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_=[] ResourceApplyAdamWithAmsgrad: CPU  ReadVariableOp: GPU CPU  _Arg: GPU CPU  Colocation members, user-requested devices, and framework assigned devices, if any:   readvariableop_resource (_Arg)  framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0   adam_2_adam_update_6_resourceapplyadamwithamsgrad_m (_Arg)  framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0   adam_2_adam_update_6_resourceapplyadamwithamsgrad_v (_Arg)  framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0   adam_2_adam_update_6_resourceapplyadamwithamsgrad_vhat (_Arg)  framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0   ReadVariableOp (ReadVariableOp)    Exp/ReadVariableOp (ReadVariableOp)    ReadVariableOp_1 (ReadVariableOp)    actor/ReadVariableOp (ReadVariableOp)    actor/Exp/ReadVariableOp (ReadVariableOp)    actor/ReadVariableOp_1 (ReadVariableOp)    actor_critic/actor/ReadVariableOp (ReadVariableOp)    actor_critic/actor/Exp/ReadVariableOp (ReadVariableOp)    actor_critic/actor/ReadVariableOp_1 (ReadVariableOp)    Adam_2/Adam/update_6/ResourceApplyAdamWithAmsgrad (ResourceApplyAdamWithAmsgrad) /job:localhost/replica:0/task:0/device:GPU:0 [[{{node ReadVariableOp}}]] [Op:__inference__train_4206]
Posted
by
Post not yet marked as solved
3 Replies
1.4k Views
after running conda install -c apple tensorflow-deps, I am about to install basic tensorflow-macos, but I got these errors: error: Command "/Users/ktietz/Code/oss/ci_pkgs/python-split_1627475317671/_build_env/bin/llvm-ar rcs build/temp.macosx-11.1-arm64-3.9/libnpymath.a build/temp.macosx-11.1-arm64-3.9/numpy/core/src/npymath/npy_math.o build/temp.macosx-11.1-arm64-3.9/build/src.macosx-11.1-arm64-3.9/numpy/core/src/npymath/ieee754.o build/temp.macosx-11.1-arm64-3.9/build/src.macosx-11.1-arm64-3.9/numpy/core/src/npymath/npy_math_complex.o build/temp.macosx-11.1-arm64-3.9/numpy/core/src/npymath/halffloat.o" failed with exit status 127   ----------------------------------------   ERROR: Failed building wheel for numpy Failed to build numpy ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly my python is ver. 3.9.6
Posted
by
Post not yet marked as solved
2 Replies
3.3k Views
When following the instructions on installing TensorFlow on an M1 mac from Apples instructions I get the following error: NotImplementedError: Cannot convert a symbolic Tensor (sequential/lstm/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported
Posted
by
Post not yet marked as solved
2 Replies
1.9k Views
I have an M1 MacBook Air! I tried installing 'keras' and 'tensorflow' packages in Rstudio. However I got an error. Then, I tried creating a virtual env to work in it and my script did run for a couple of hours but then it's again back to the same error: Error in py_initialize(config$python, config$libpython, config$pythonhome, : /Users/mansichandra/mambaforge/envs/walnut/lib/libpython3.8.dylib - dlopen(/Users/mansichandra/mambaforge/envs/walnut/lib/libpython3.8.dylib, 10): no suitable image found. Did find: /Users/mansichandra/mambaforge/envs/walnut/lib/libpython3.8.dylib: mach-o, but wrong architecture /Users/mansichandra/mambaforge/envs/walnut/lib/libpython3.8.dylib: mach-o, but wrong architecture How can this be resolved because I'm pretty sure it's an architecture problem!!
Posted
by
Post not yet marked as solved
1 Replies
742 Views
Hello, I am trying to install tensorflow-macos and tensorflow-metal on my 16 inch Macbook Pro 2020 in an Anaconda environment but it does not seem to work. It keeps reporting that there is no matching distribution despite the fact that the environment is using Python 3.8.11. Does Tensorflow Metal only work in Python virtual environments or is there a particular reason why no distribution could be found for the Anaconda environment?
Posted
by
Post not yet marked as solved
2 Replies
534 Views
Is there anyway we can set the number of threads used during coreML inference? My model is relatively small and the overhead of launching new threads is too expensive. When using TensorFlow C API, forcing to single thread results in significant decrease in CPU usage. (So far coreML with multiple threads has 3 times the cpu usage compares to TensorFlow with single thread). Also, wondering if anyone has compared the performance between TensorFlow in C and coreML?
Posted
by
Post not yet marked as solved
6 Replies
2.3k Views
Hello, I noticed a substantial decrease in performance compared to previous releases of tensorflow for M1 Macs. I previously installed the alpha release of tensorflow for M1 from GitHub, found here: https://github.com/apple/tensorflow_macos and was very impressed by the performance. I used the following script to benchmark my M1 Mac and other systems: https://gist.github.com/tampapath/662aca8cd0ef6790ade1bf3c23fe611a#file-fashin_mnist-py Running the alpha release from GitHub, my M1 Mac handsomely outperformed both google colab's random GPU offerings and an RTX 2070 windows computer. Recently, I went back to the GitHub repository, looking for new updates on tensorflow support for the M1 and was redirected here to the tensorflow-metal PluggableDevices installation guide: https://developer.apple.com/metal/tensorflow-plugin/ After installing the conda environment and running the same benchmark script, I realized my M1 systems's was running much slower. Additionally, the following error messages printed to the console while running the benchmark: 2021-08-12 21:48:16.306946: 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-08-12 21:48:16.307209: 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>) 2021-08-12 21:48:16.437942: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:176] None of the MLIR Optimization Passes are enabled (registered 2) 2021-08-12 21:48:16.441196: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz Has anyone else noticed this loss in performance? The results I got are as follow: benchmark script duration tf GitHub alpha 🟢 9.62s new tf-metal 🔴 76.52s google colab 🔴 57.53s RTX 2070 PC 🔴 23.18s both tf GitHub alpha and new tf-metal were ran on the same 13" M1 MacBook Pro. I wrote an installation guide for the GitHub alpha release if anyone wants to compare results, or run a faster version of tensorflow compatible with their M1 Mac: https://github.com/apple/tensorflow_macos/issues/215
Posted
by
Post not yet marked as solved
0 Replies
656 Views
Hello, I made a post earlier comparing the performance between the latest release of tensorflow with apple silicon support: https://developer.apple.com/forums/thread/687654. In my testing the GitHub alpha greatly outperforms the current release. I provided an installation guide for the GitHub alpha in that post. sounddevice: https://pypi.org/project/sounddevice/ My goal is to get the python library sounddevice working in either of the virtual environments created by the two different tensorflow releases for apple silicon. Preferably the GitHub alpha, since its much faster. The two releases being the current release https://developer.apple.com/metal/tensorflow-plugin/ using a conda virtual environment, or the GitHub alpha release which can be setup using the installer script. GitHub alpha venv errors Installation: First I make an environment following the installation guide I provided in my first post (linked above). I activate the virtual environment I install sounddevice using the following command: $ python3 -m pip install sounddevice When I try to import sounddevice I get the following errors: Traceback (most recent call last): File "/Users/sadedwar/code/fun/ga-synth/venv/lib/python3.8/site-packages/sounddevice.py", line 72, in <module> _lib = _ffi.dlopen(_libname) OSError: cannot load library '/usr/local/lib/libportaudio.dylib': dlopen(/usr/local/lib/libportaudio.dylib, 2): no suitable image found. Did find: /usr/local/lib/libportaudio.dylib: mach-o, but wrong architecture /usr/local/Cellar/portaudio/19.7.0/lib/libportaudio.2.dylib: mach-o, but wrong architecture tensorflow-metal PluggableDevice errors Installation: exactly as described in: https://developer.apple.com/metal/tensorflow-plugin/ I install python-sounddevice from: https://anaconda.org/conda-forge/python-sounddevice importing works fine When I try to run the following code: myrecording = sd.rec(int(duration * samplerate), samplerate=samplerate, channels=channels) it yields this error: Traceback (most recent call last): File "/Users/sadedwar/code/fun/ga-synth/makeDatasets.py", line 41, in <module> render_dataset(make_simple_dataset(100)) File "/Users/sadedwar/code/fun/ga-synth/makeDatasets.py", line 37, in render_dataset data, samplerate = audioRecorder.play_and_rec() File "/Users/sadedwar/code/fun/ga-synth/audioRecorder.py", line 29, in play_and_rec recording, samplerate = rec_mono_16bit_8kHz(duration=0.1) File "/Users/sadedwar/code/fun/ga-synth/audioRecorder.py", line 17, in rec_mono_16bit_8kHz myrecording = sd.rec(int(duration * samplerate), samplerate=samplerate, channels=channels) File "/Users/sadedwar/miniforge3/envs/machinelearning/lib/python3.9/site-packages/sounddevice.py", line 274, in rec ctx.start_stream(InputStream, samplerate, ctx.input_channels, File "/Users/sadedwar/miniforge3/envs/machinelearning/lib/python3.9/site-packages/sounddevice.py", line 2573, in start_stream self.stream = StreamClass(samplerate=samplerate, File "/Users/sadedwar/miniforge3/envs/machinelearning/lib/python3.9/site-packages/sounddevice.py", line 1415, in __init__ _StreamBase.__init__(self, kind='input', wrap_callback='array', File "/Users/sadedwar/miniforge3/envs/machinelearning/lib/python3.9/site-packages/sounddevice.py", line 836, in __init__ def callback_ptr(iptr, optr, frames, time, status, _): MemoryError: Cannot allocate write+execute memory for ffi.callback(). You might be running on a system that prevents this. For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks Any help is appreciated, thank you.
Posted
by
Post not yet marked as solved
1 Replies
653 Views
My m1 MBP is not using the full gpu power when running TensorFlow. Its taking about 6 seconds / epoch when for the same task other get 1 second per epoch. when running the training the Mac doesn't get hot and the fans don't rev. Any advice? Thanks, Logan
Posted
by