tensorflow-metal

RSS for tag

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

tensorflow-metal Documentation

Posts under tensorflow-metal tag

215 Posts
Sort by:
Post not yet marked as solved
10 Replies
6.5k 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
5 Replies
753 Views
I am trying to run the notebook https://www.tensorflow.org/text/tutorials/text_classification_rnn from the TensorFlow website. The code has LSTM and Bidirectional layers When the GPU is enabled the time is 56 minutes/epoch. When I am only using the CPU is 264 seconds/epoch. I am using MacBook Pro 14 (10 CPU cores, 16 GPU cores) and TensorFlow-macos 2.8 with TensorFlow-metal 0.5.0.  I face the same problem for TensorFlow-macos 2.9 too. My environment has: tensorflow-macos          2.8.0   tensorflow-metal          0.5.0  tensorflow-text           2.8.1   tensorflow-datasets       4.6.0                    tensorflow-deps           2.8.0                          tensorflow-hub            0.12.0                       tensorflow-metadata       1.8.0                                         When I am using CNNs the GPU is fully enabled and 3-4 times faster than when only using the CPU.  Any idea where is the problem when using LSTMs and Bidirectional?
Posted Last updated
.
Post not yet marked as solved
1 Replies
360 Views
I was following the text classification tutorial below, and using tensorflow-macos 2.9.0. on Macbook M1. https://www.tensorflow.org/text/tutorials/text_classification_rnn. However, it ran into three issues, If GPU was enabled, the model fit was extremely slow, while disabling GPU would make the model fit faster. Error when fitting the model with GPU enabled. The model still kept running after showing the following messages, but very very slow. W tensorflow/core/common_runtime/forward_type_inference.cc:332] Type inference failed. This indicates an invalid graph that escaped type checking. Error message: INVALID_ARGUMENT: expected compatible input types, but input 1: type_id: TFT_OPTIONAL args { type_id: TFT_PRODUCT args { type_id: TFT_TENSOR args { type_id: TFT_INT32 } } } is neither a subtype nor a supertype of the combined inputs preceding it: type_id: TFT_OPTIONAL args { type_id: TFT_PRODUCT args { type_id: TFT_TENSOR args { type_id: TFT_FLOAT } } } Two results were supposed to be identical, but they were identical when GPU was disabled. When GPU is enabled, they were not. When GPU is enabled To confirm that this works as expected, evaluate a sentence twice. First, alone so there's no padding to mask: 1/1 [==============================] - 1s 1s/step [0.00808082] Now, evaluate it again in a batch with a longer sentence. The result should be identical: 1/1 [==============================] - 16s 16s/step [-0.01561341] When GPU is disabled (First run as above) 1/1 [==============================] - 1s 1s/step [-0.0032991] (second run) 1/1 [==============================] - 0s 71ms/step [-0.0032991]
Posted
by windlove.
Last updated
.
Post not yet marked as solved
10 Replies
4.1k Views
I m using macbook air 13" and pursuing Artificial Intelligence course I m facing huge problem with Jupyter notebook post installing tensorflow as the kernel keeps dying and I have literally tried solution in every article/resource on Google Nothing seems to be fixing the issue. It began only when I started to run code for Convolutional Neural Network Please help me fix this issue and understand why its not getting fixed At the moment, I can only think of trading Macbook for Windows Laptop but It will be very hard as I have not had hands-on Windows laptop Hope to hear back soon Thanks Keshav Lal Seth
Posted Last updated
.
Post not yet marked as solved
0 Replies
90 Views
I prepared a python3.9 environment with tensorflow-macos( 2.9.0 , 2.9.1), tensorflow-metal( 0.4.0, 0.5.1) to enable m1 core acceleration. The program architecture is a tf.keras model training on a Celery(5.2.7) worker which is created by gevent(21.8.0 ). After training, the model is converted to coreml model(coremltools 6.0 ) and tflite model. Based on experiments, there are some kinds of memory leak on two different M1 Macs. 1.     Memory grew smoothly from 7GB to 80GB within a 300-epoch training. 2.     Memory grew slowly from 7GB to 11GB within a 100-epoch training process, then grow to 13GB after model conversion. We added tf.keras.clear_session() that expect the memory to be collected after celery worker task finished. But memory still remained when the next task published to the worker. I saw some post about memory leak on M1 core. Is there any suggestion to memory leak? I know a work around may be to create celery work by prefork method and set memory growth limit. But my code cannot transfer directly because some GPU resource context issue. Is it easy to create tf.keras training in threads on the M1?
Posted
by wangfmn.
Last updated
.
Post not yet marked as solved
1 Replies
103 Views
system info: macOS 13.0 14 inch M1 Pro (2021 generation) I tried to import TensorFlow as our official guide instructs: https://developer.apple.com/metal/tensorflow-plugin/ but something happens, I cannot import TensorFlow after trying to upgrade numpy or TensorFlow-macos or something else, like our forum discusses. I will be appraised if anyone could help me with that, please let me know numpy                     1.21.5           py39h42add53_3    defaults numpy-base                1.21.5           py39hadd41eb_3    defaults tensorflow-estimator      2.9.0                    pypi_0    pypi tensorflow-macos          2.9.2                    pypi_0    pypi tensorflow-metal          0.5.1                    pypi_0    pypi (tf) gary@192 ~ % python Python 3.9.15 (main, Nov  4 2022, 11:12:28)  [Clang 12.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe 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/gary/Documents/anaconda3/envs/tf/lib/python3.9/site-packages/tensorflow/__init__.py", line 37, in <module>     from tensorflow.python.tools import module_util as _module_util   File "/Users/gary/Documents/anaconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/__init__.py", line 42, in <module>     from tensorflow.python import data   File "/Users/gary/Documents/anaconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/data/__init__.py", line 21, in <module>     from tensorflow.python.data import experimental   File "/Users/gary/Documents/anaconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/data/experimental/__init__.py", line 95, in <module>     from tensorflow.python.data.experimental import service   File "/Users/gary/Documents/anaconda3/envs/tf/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/gary/Documents/anaconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py", line 22, in <module>     from tensorflow.python.data.experimental.ops import compression_ops   File "/Users/gary/Documents/anaconda3/envs/tf/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/gary/Documents/anaconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/data/util/structure.py", line 22, in <module>     from tensorflow.python.data.util import nest   File "/Users/gary/Documents/anaconda3/envs/tf/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/gary/Documents/anaconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/framework/sparse_tensor.py", line 24, in <module>     from tensorflow.python.framework import constant_op   File "/Users/gary/Documents/anaconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/framework/constant_op.py", line 25, in <module>     from tensorflow.python.eager import execute   File "/Users/gary/Documents/anaconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/eager/execute.py", line 23, in <module>     from tensorflow.python.framework import dtypes   File "/Users/gary/Documents/anaconda3/envs/tf/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 >>>
Posted Last updated
.
Post not yet marked as solved
2 Replies
227 Views
I'm trying to use tensorflow per this tutorial for arm64 Apple Silicon: https://developer.apple.com/metal/tensorflow-plugin/ However, when I attempt to import tensorflow, I get this error: RuntimeError Traceback (most recent call last) RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf Output exceeds the size limit. Open the full output data in a text editor ImportError Traceback (most recent call last) ImportError: numpy.core.multiarray failed to import The above exception was the direct cause of the following exception: SystemError Traceback (most recent call last) SystemError: <built-in method contains of dict object at 0x107c68040> returned a result with an error set The above exception was the direct cause of the following exception: ImportError Traceback (most recent call last) Cell In [2], line 1 ----> 1 import tensorflow as tf File ~/opt/miniconda3/envs/speaker_recognition/lib/python3.8/site-packages/tensorflow/init.py:37 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 ~/opt/miniconda3/envs/speaker_recognition/lib/python3.8/site-packages/tensorflow/python/init.py:37 29 # We aim to keep this file minimal and ideally remove completely. 30 # If you are adding a new file with @tf_export decorators, ... ---> 19 from tensorflow.python.client._pywrap_tf_session import * 20 from tensorflow.python.client._pywrap_tf_session import _TF_SetTarget 21 from tensorflow.python.client._pywrap_tf_session import _TF_SetConfig ImportError: initialization failed What else can I try to get tensorflow operational and using my M1's GPU?
Posted
by tambo.
Last updated
.
Post not yet marked as solved
2 Replies
157 Views
First off, I'm mainly a wet-lab biologist, and Python is not my strong suit, so sorry if I seem a little clueless here. Anyways, I am having trouble converting a pretrained keras model (.h5 format) with coremltools. My code to try and convert the model: DL_model = (path to .h5 file) model_converted = ct.convert(DL_model, source = "tensorflow") and it throws an error: ValueError: Unknown metric function: binary_recall. Please ensure this object is passed to the custom_objects argument. See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details. I assume I need to pass some sort of custom_objects = {"custom_obj": custom_obj} argument in ct.convert, but I don't know how. I tried: custom_objects = {"binary_recall": binary_recall}) but that caused NameError: name 'binary_recall' is not defined Can anyone give me some help here? It would be nice to speed up this model by converting it to Apple's format; I work with huge files and cutting down data processing time is important for me. Thanks!! Noah
Posted
by nlittman1.
Last updated
.
Post not yet marked as solved
0 Replies
155 Views
I just install the latest version of TensorFlow and TensorFlow-metal on my Mac (M1 Max macOS 12.5) and try to run the demo code of "Customizing A TensorFlow Operation". But it reports the error like this: $ python tiny_nerf_hash.py Checking whether it needs to recompile... Loading the .so binary... Traceback (most recent call last): File "/Users/-/Downloads/CustomizingATensorFlowOperation/tiny_nerf_hash.py", line 22, in <module> from hash_encoder import HashEncoder File "/Users/-/Downloads/CustomizingATensorFlowOperation/./hash_encoder/hash_encoder.py", line 37, in <module> _backend = tf.load_op_library(os.path.join(pathlib.Path( File "/Users/-/miniforge3/envs/instsha/lib/python3.9/site-packages/tensorflow/python/framework/load_library.py", line 54, in load_op_library lib_handle = py_tf.TF_LoadLibrary(library_filename) tensorflow.python.framework.errors_impl.NotFoundError: dlopen(/Users/-/Downloads/CustomizingATensorFlowOperation/hash_encoder/hash_encoder_kernel.so, 0x0006): symbol not found in flat namespace (__ZN10tensorflow14kernel_factory17OpKernelRegistrar12InitInternalEPKNS_9KernelDefEN4absl12lts_2022062311string_viewENSt3__110unique_ptrINS0_15OpKernelFactoryENS8_14default_deleteISA_EEEE)
Posted Last updated
.
Post not yet marked as solved
9 Replies
19k Views
I just got my new MacBook Pro with M1 Max chip and am setting up Python. I've tried several combinational settings to test speed - now I'm quite confused. First put my questions here: Why python run natively on M1 Max is greatly (~100%) slower than on my old MacBook Pro 2016 with Intel i5? On M1 Max, why there isn't significant speed difference between native run (by miniforge) and run via Rosetta (by anaconda) - which is supposed to be slower ~20%? On M1 Max and native run, why there isn't significant speed difference between conda installed Numpy and TensorFlow installed Numpy - which is supposed to be faster? On M1 Max, why run in PyCharm IDE is constantly slower ~20% than run from terminal, which doesn't happen on my old Intel Mac. Evidence supporting my questions is as follows: Here are the settings I've tried: 1. Python installed by Miniforge-arm64, so that python is natively run on M1 Max Chip. (Check from Activity Monitor, Kind of python process is Apple). Anaconda.: Then python is run via Rosseta. (Check from Activity Monitor, Kind of python process is Intel). 2. Numpy installed by conda install numpy: numpy from original conda-forge channel, or pre-installed with anaconda. Apple-TensorFlow: with python installed by miniforge, I directly install tensorflow, and numpy will also be installed. It's said that, numpy installed in this way is optimized for Apple M1 and will be faster. Here is the installation commands: conda install -c apple tensorflow-deps python -m pip install tensorflow-macos python -m pip install tensorflow-metal 3. Run from Terminal. PyCharm (Apple Silicon version). Here is the test code: import time import numpy as np np.random.seed(42) a = np.random.uniform(size=(300, 300)) runtimes = 10 timecosts = [] for _ in range(runtimes): s_time = time.time() for i in range(100): a += 1 np.linalg.svd(a) timecosts.append(time.time() - s_time) print(f'mean of {runtimes} runs: {np.mean(timecosts):.5f}s') and here are the results: +-----------------------------------+-----------------------+--------------------+ | Python installed by (run on)→ | Miniforge (native M1) | Anaconda (Rosseta) | +----------------------+------------+------------+----------+----------+---------+ | Numpy installed by ↓ | Run from → | Terminal | PyCharm | Terminal | PyCharm | +----------------------+------------+------------+----------+----------+---------+ | Apple Tensorflow | 4.19151 | 4.86248 | / | / | +-----------------------------------+------------+----------+----------+---------+ | conda install numpy | 4.29386 | 4.98370 | 4.10029 | 4.99271 | +-----------------------------------+------------+----------+----------+---------+ This is quite slow. For comparison, run the same code on my old MacBook Pro 2016 with i5 chip - it costs 2.39917s. another post reports that run with M1 chip (not Pro or Max), miniforge+conda_installed_numpy is 2.53214s, and miniforge+apple_tensorflow_numpy is 1.00613s. you may also try on it your own. Here is the CPU information details: My old i5: $ sysctl -a | grep -e brand_string -e cpu.core_count machdep.cpu.brand_string: Intel(R) Core(TM) i5-6360U CPU @ 2.00GHz machdep.cpu.core_count: 2 My new M1 Max: % sysctl -a | grep -e brand_string -e cpu.core_count machdep.cpu.brand_string: Apple M1 Max machdep.cpu.core_count: 10 I follow instructions strictly from tutorials - but why would all these happen? Is it because of my installation flaws, or because of M1 Max chip? Since my work relies heavily on local runs, local speed is very important to me. Any suggestions to possible solution, or any data points on your own device would be greatly appreciated :)
Posted Last updated
.
Post not yet marked as solved
0 Replies
216 Views
Hi, the headline says it basically. I installed tensorflow-metal via https://developer.apple.com/metal/tensorflow-plugin/ in a new python arm64 environment and it works fine on the mac silicon but the "old" / previously existing Intel based environments crash when Tensorflow is imported (from their intel based environment). The same error occurs when I try to import Tensorflow in python in a new created environment. The error (in illegal hardware instruction error in python & below as snipped from the Full Error Report) should indicate that I try to import tensorflow with arm64 dependencies in the x86 python environment (?) Is there a central dependency that all environments use (e.g., to xcode tools)? If so how can I "break" the dependency? Or what else is the problem? Cheers for any advice, Ralf Translated Report (Full Report Below) Process: python3.9 [4506] Path: /Users/USER/*/python3.9 Identifier: python3.9 Version: ??? Code Type: X86-64 (Translated) Parent Process: zsh [4489] Responsible: Terminal [2340] User ID: 501 Date/Time: 2022-11-11 22:35:30.8426 +0100 OS Version: macOS 13.0.1 (22A400) Report Version: 12 Anonymous UUID: 80661AD4-199E-2752-9885-3E0092AFA20B Time Awake Since Boot: 3800 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 4 Illegal instruction: 4 Terminating Process: exc handler [4506] Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libtensorflow_framework.2.dylib 0x16820f064 tensorflow::monitoring::MetricDef<(tensorflow::monitoring::MetricKind)1, long long, 2>::MetricDef<char [11], char [7]>(absl::lts_20210324::string_view, absl::lts_20210324::string_view, char const (&) [11], char const (&) [7]) + 68 1 libtensorflow_framework.2.dylib 0x16820747b tensorflow::monitoring::Counter<2>* tensorflow::monitoring::Counter<2>::New<char const (&) [46], char const (&) [58], char const (&) [11], char const (&) [7]>(char const (&) [46], char const (&) [58], char const (&) [11], char const (&) [7]) + 91 2 libtensorflow_framework.2.dylib 0x168213661 _GLOBAL__sub_I_loader.cc + 49 3 dyld 0x204947618 invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 172 4 dyld 0x204986c4d invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 132 5 dyld 0x20497aef7 invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 557 6 dyld 0x20492d0b7 dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 245 7 dyld 0x20497a0a7 dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 175 8 dyld 0x20497c7ea dyld3::MachOFile::forEachInitializerPointerSection(Diagnostics&, void (unsigned int, unsigned int, bool&) block_pointer) const + 116 9 dyld 0x204986882 dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 390
Posted Last updated
.
Post not yet marked as solved
4 Replies
567 Views
I am training a model using tensorflow-metal 0.5.1. and at one point the training hangs and I have to stop the kernel. It is quite a long training. It starts fine with all 10 available cores running using the GPU as shown by Activity Monitor. After about 20 hours into the training, in one of the core processes the %GPU drops to zero while still showing some CPU activity. In succession after some hours, the same thing happens to another 4 core processes, nevertheless the training continues as it outputs some progress. When the remaining core processes that still use the GPU terminate, the progression output stops. The core processes with no GPU activity still run but they do nothing and the training hangs forever. The only thing left is stopping the kernel from jupyter notebook. Here is the code to reproduce the problem: # imports import pandas as pd import matplotlib import matplotlib.pyplot as plt import tensorflow from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Flatten from tensorflow.keras.layers import Conv2D, MaxPooling2D from tensorflow.keras.layers import BatchNormalization, Dropout from sklearn.model_selection import GridSearchCV from scikeras.wrappers import KerasClassifier from tensorflow.keras.optimizers import SGD import numpy # pip install extra-keras-datasets first from extra_keras_datasets import kmnist # Model configuration no_classes = 10 validation_split = 0.2 # Load KMNIST dataset (input_train, target_train), (input_test, target_test) = kmnist.load_data(type='kmnist') # Shape of the input sets input_train_shape = input_train.shape input_test_shape = input_test.shape # Keras layer input shape. input_shape = (input_train_shape[1], input_train_shape[2], 1) # Reshape the training data to include channels input_train = input_train.reshape(input_train_shape[0], input_train_shape[1], input_train_shape[2], 1) input_test = input_test.reshape(input_test_shape[0], input_test_shape[1], input_test_shape[2], 1) # Parse numbers as floats input_train = input_train.astype('float32') input_test = input_test.astype('float32') # Normalize input data input_train = input_train / 255 input_test = input_test / 255 # Function to create model def create_model_SGD(neurons): model = Sequential() model.add(Conv2D(32, kernel_size = (3, 3), activation = 'relu', input_shape = input_shape, padding = 'same')) model.add(BatchNormalization()) model.add(MaxPooling2D(pool_size = (2, 2))) model.add(BatchNormalization()) model.add(Conv2D(64, kernel_size = (3, 3), activation = 'relu', padding = 'same')) model.add(BatchNormalization()) model.add(MaxPooling2D(pool_size = (2, 2))) model.add(BatchNormalization()) model.add(Conv2D(128, kernel_size = (3, 3), activation = 'relu', padding = 'same')) model.add(Conv2D(128, kernel_size = (3, 3), activation = 'relu', padding = 'same')) model.add(BatchNormalization()) model.add(MaxPooling2D(pool_size = (2, 2))) model.add(BatchNormalization()) model.add(Flatten()) model.add(Dense(neurons, activation = 'relu')) model.add(Dropout(rate = 0.2)) model.add(BatchNormalization()) model.add(Dense(neurons, activation = 'relu')) model.add(Dropout(rate = 0.2)) model.add(BatchNormalization()) model.add(Dense(no_classes, activation = 'softmax')) # compilation of the model model.compile(loss=tensorflow.keras.losses.sparse_categorical_crossentropy, optimizer='SGD', metrics=['accuracy']) return model # fix random seed for reproducibility seed = 7 tensorflow.random.set_seed(seed) # create model model = KerasClassifier(model=create_model_SGD, verbose=0) # define the grid search parameters learn_rate = [0.001, 0.01, 0.1] momentum = [0.0, 0.5, 0.9] neurons = [256, 512, 1024] batch_size = [100, 250, 350] epochs = [10, 25, 50] param_grid = dict(model__neurons=neurons, optimizer__learning_rate=learn_rate, optimizer__momentum=momentum, batch_size=batch_size, epochs=epochs) grid = GridSearchCV(estimator=model, param_grid=param_grid, n_jobs=-1, cv=3, verbose=3) grid_result = grid.fit(input_train, target_train) Test configurations are: MacBook Pro M1 Max macOS 12.5.1 tensorflow-deps 2.9 tensorflow-macos 2.9.2 tensorflow-metal 0.5.1
Posted
by gppower.
Last updated
.
Post not yet marked as solved
0 Replies
149 Views
When using custom functions under the @tf.function handle, the output of tf.random will be fixed at each call. This behavior will occur after the first call to a method that is wrapped under @tf.function and will persist until the kernel is restarted.
Posted
by atr17001.
Last updated
.
Post not yet marked as solved
1 Replies
213 Views
I'm getting below error in almost every way i'm trying to install tensorflow in mac Air M2. ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.   tensorflow-macos from https://files.pythonhosted.org/packages/30/6b/0ceaa806258dd33b15a160b79eeedb37ff8cb24269b308773afb81d11517/tensorflow_macos-2.10.0-cp39-cp39-macosx_12_0_arm64.whl#sha256=f2ec603c5496c25fb1bcda8eb4166423bf023bfb7ae6cbdec0be8796ca67e866:     Expected sha256 f2ec603c5496c25fb1bcda8eb4166423bf023bfb7ae6cbdec0be8796ca67e866        Got    f8cbfc1ecbf07b17f8d8fb152cf3a214b5591581fa07b07decb02b11c2822ad7 please help me.
Posted Last updated
.
Post not yet marked as solved
6 Replies
3.4k 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
341 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
16 Replies
1.3k Views
Comparison between MAC Studio M1 Ultra (20c, 64c, 128GB RAM) vs 2017 Intel i5 MBP (16GB RAM) for the subject matter i.e. memory leakage while using tf.keras.models.predict() for saved model on both machines: MBP-2017: First prediction takes around 10MB and subsequent calls ~0-1MB MACSTUDIO-2022: First prediction takes around 150MB and subsequent calls ~70-80MB. After say 10000 such calls o predict(), while my MBP memory usage stays under 10GB, MACSTUDIO climbs to ~80GB (and counting up for higher number of calls). Even using keras.backend.clear_session() after each call on MACSTUDIO did not help. Can anyone having insight on TensorFlow-metal and/or MAC M1 machines help? Thanks, Bapi
Posted
by karbapi.
Last updated
.
Post not yet marked as solved
0 Replies
339 Views
Tensorflow metal not working on M1 Macbook Air(8GB RAM). #test.py import tensorflow as tf cifar = tf.keras.datasets.cifar100 (x_train, y_train), (x_test, y_test) = cifar.load_data() model = tf.keras.applications.ResNet50( include_top=True, weights=None, input_shape=(32, 32, 3), classes=100,) loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) model.compile(optimizer="adam", loss=loss_fn, metrics=["accuracy"]) model.fit(x_train, y_train, epochs=5, batch_size=64) Here's the error log:- > python test.py Metal device set to: Apple M1 systemMemory: 8.00 GB maxCacheSize: 2.67 GB 2022-10-28 23:09:44.144540: 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-10-28 23:09:44.144913: 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>) [1] 89863 bus error python test.py Another test on a custom code raises this error:- 1 leaked semaphore objects to clean up at shutdown
Posted
by udayjain.
Last updated
.
Post not yet marked as solved
0 Replies
250 Views
I tried training my model on my M1 Pro using Tensorflow's mixed-precision, hoping it will boost the performance, but I got an error: .../mpsgraph/MetalPerformanceShadersGraph/Core/Files/MPSGraphUtilities.mm:289:0: error: 'mps.select' op failed to verify that all of {true_value, false_value, result} have same element type .../mpsgraph/MetalPerformanceShadersGraph/Core/Files/MPSGraphUtilities.mm:289:0: note: see current operation: %5 = "mps.select"(%4, %3, %2) : (tensor<1xi1>, tensor<1xf16>, tensor<1xf32>) -> tensor<1xf16>
Posted Last updated
.
Post not yet marked as solved
2 Replies
224 Views
Hi, I use the ResNet50 example code, with below extra code to enable float16, but the performance drops much, is it expected? from tensorflow.keras import mixed_precision mixed_precision.set_global_policy('mixed_float16')
Posted
by juliussf.
Last updated
.