Posts

Post not yet marked as solved
1 Replies
587 Views
I have done a fresh installation without forcing any package version, so what I got were the default ones. I installed miniconda3 first. This is the tensorflow suite that I got: tensorflow-deps      2.9.0             tensorflow-estimator   2.11.0        tensorflow-macos     2.11.0        tensorflow-metal     0.7.1       python version 3.10 When I import tensorflow I get this runtime error about a wrong version of Numpy.: --------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf --------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf --------------------------------------------------------------------------- ImportError Traceback (most recent call last) ImportError: numpy.core._multiarray_umath failed to import --------------------------------------------------------------------------- ImportError Traceback (most recent call last) ImportError: numpy.core.umath failed to import --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[1], line 1 ----> 1 import tensorflow File ~/miniconda3/envs/tensorm1/lib/python3.10/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 ~/miniconda3/envs/tensorm1/lib/python3.10/site-packages/tensorflow/python/__init__.py:42 37 from tensorflow.python.eager import context 39 # pylint: enable=wildcard-import 40 41 # Bring in subpackages. ---> 42 from tensorflow.python import data 43 from tensorflow.python import distribute 44 # from tensorflow.python import keras File ~/miniconda3/envs/tensorm1/lib/python3.10/site-packages/tensorflow/python/data/__init__.py:21 15 """`tf.data.Dataset` API for input pipelines. 16 17 See [Importing Data](https://tensorflow.org/guide/data) for an overview. 18 """ 20 # pylint: disable=unused-import ---> 21 from tensorflow.python.data import experimental 22 from tensorflow.python.data.ops.dataset_ops import AUTOTUNE 23 from tensorflow.python.data.ops.dataset_ops import Dataset File ~/miniconda3/envs/tensorm1/lib/python3.10/site-packages/tensorflow/python/data/experimental/__init__.py:96 15 """Experimental API for building input pipelines. 16 17 This module contains experimental `Dataset` sources and transformations that can (...) 92 @@UNKNOWN_CARDINALITY 93 """ 95 # pylint: disable=unused-import ---> 96 from tensorflow.python.data.experimental import service 97 from tensorflow.python.data.experimental.ops.batching import dense_to_ragged_batch 98 from tensorflow.python.data.experimental.ops.batching import dense_to_sparse_batch File ~/miniconda3/envs/tensorm1/lib/python3.10/site-packages/tensorflow/python/data/experimental/service/__init__.py:419 1 # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); (...) 13 # limitations under the License. 14 # ============================================================================== 15 """API for using the tf.data service. 16 17 This module contains: (...) 416 job of ParameterServerStrategy). 417 """ --> 419 from tensorflow.python.data.experimental.ops.data_service_ops import distribute 420 from tensorflow.python.data.experimental.ops.data_service_ops import from_dataset_id 421 from tensorflow.python.data.experimental.ops.data_service_ops import register_dataset File ~/miniconda3/envs/tensorm1/lib/python3.10/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py:22 20 from tensorflow.core.protobuf import data_service_pb2 21 from tensorflow.python import tf2 ---> 22 from tensorflow.python.data.experimental.ops import compression_ops 23 from tensorflow.python.data.experimental.service import _pywrap_server_lib 24 from tensorflow.python.data.experimental.service import _pywrap_utils File ~/miniconda3/envs/tensorm1/lib/python3.10/site-packages/tensorflow/python/data/experimental/ops/compression_ops.py:16 1 # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); (...) 13 # limitations under the License. 14 # ============================================================================== 15 """Ops for compressing and uncompressing dataset elements.""" ---> 16 from tensorflow.python.data.util import structure 17 from tensorflow.python.ops import gen_experimental_dataset_ops as ged_ops 20 def compress(element): File ~/miniconda3/envs/tensorm1/lib/python3.10/site-packages/tensorflow/python/data/util/structure.py:22 18 import itertools 20 import wrapt ---> 22 from tensorflow.python.data.util import nest 23 from tensorflow.python.framework import composite_tensor 24 from tensorflow.python.framework import ops File ~/miniconda3/envs/tensorm1/lib/python3.10/site-packages/tensorflow/python/data/util/nest.py:34 1 # Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); (...) 13 # limitations under the License. 14 # ============================================================================== 16 """## Functions for working with arbitrarily nested sequences of elements. 17 18 NOTE(mrry): This fork of the `tensorflow.python.util.nest` module (...) 31 arrays. 32 """ ---> 34 from tensorflow.python.framework import sparse_tensor as _sparse_tensor 35 from tensorflow.python.util import _pywrap_utils 36 from tensorflow.python.util import nest .................. TypeError: Unable to convert function return value to a Python type! The signature was () -> handle code-block I have tried to upgrade and downgrade numpy. I also tried different combinations of version of tensorflow-deps, -macos and -metal. All of that failed. The initial installation is the default one though, so it should work...... Any suggestions?
Posted
by gppower.
Last updated
.
Post not yet marked as solved
4 Replies
1.3k 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
.