hub icon indicating copy to clipboard operation
hub copied to clipboard

USE large 5 doesn't work with TF2.1

Open rmanak opened this issue 6 years ago • 2 comments

I am getting this error message:

InternalError: 2 root error(s) found.
  (0) Internal:  Blas GEMM launch failed : a.shape=(17, 320), b.shape=(320, 512), m=17, n=512, k=320
	 [[{{node sequential/keras_layer/StatefulPartitionedCall/StatefulPartitionedCall/StatefulPartitionedCall/EncoderTransformer/Transformer/PrepareForTransformer/dense/MatMul}}]]
	 [[sequential/keras_layer/StatefulPartitionedCall/StatefulPartitionedCall/StatefulPartitionedCall/EncoderTransformer/Transformer/layer_prepostprocess/layer_norm/add_1/_250]]
  (1) Internal:  Blas GEMM launch failed : a.shape=(17, 320), b.shape=(320, 512), m=17, n=512, k=320
	 [[{{node sequential/keras_layer/StatefulPartitionedCall/StatefulPartitionedCall/StatefulPartitionedCall/EncoderTransformer/Transformer/PrepareForTransformer/dense/MatMul}}]]
0 successful operations.
0 derived errors ignored. [Op:__inference_distributed_function_124929]

Function call stack:
distributed_function -> distributed_function

When trying to train USE 5 on GPU, here is the minimal code:

import tensorflow as tf
import tensorflow_hub as hub

# MODEL = "https://tfhub.dev/google/universal-sentence-encoder/4"
MODEL = "https://tfhub.dev/google/universal-sentence-encoder-large/5"
DIM = 512
IS_TRAINABLE = False #Works if False

train_data = ["Hello world", "I'll fix it", "Function instantiation has undefined input shape"]
train_labels = [0, 0, 1]

hub_layer = hub.KerasLayer(MODEL, output_shape=[DIM], input_shape=[], trainable=IS_TRAINABLE, dtype=tf.string)

model = tf.keras.Sequential()
model.add(hub_layer)
model.add(tf.keras.layers.Dense(1))

model.compile(optimizer="adam", loss="binary_crossentropy")
model.fit(train_data, train_labels)

I can already confirm that GPU is not running out of memory, the model only takes up 1.5GB/16GB

Any help would be appreciated? I've found similar issues, but solutions such as:

try: 
    tf.config.experimental.set_memory_growth(physical_devices[0], True) 
    assert tf.config.experimental.get_memory_growth(physical_devices[0]) 
except: 
  # Invalid device or cannot modify virtual devices once initialized. 
    pass  

doesn't work

rmanak avatar Jan 22 '20 00:01 rmanak

@rmanak, I have tried reproducing your issue in Google Colab with Runtime as GPU. I didn't get the error specified by you but got the below error:

ValueError: Failed to find data adapter that can handle input: <class 'NoneType'>, <class 'NoneType'>

Please find the Github Gist. Can you please help us reproduce your issue. Thanks!

rmothukuru avatar Jan 22 '20 04:01 rmothukuru

@rmothukuru ops I forgot to add the training data in the .fit method... edited it.

After long investigation of runtimes library versions in colab, I found that the culprit is the version of libcublas10 that by default is installed at 10.2.2.X but needs to be downgraded using:

apt-get remove libcublas10 -y
apt-get update && apt-get install -y --no-install-recommends libcublas10=10.2.1.243-1

fixes the problem, thanks! will close this

rmanak avatar Jan 22 '20 23:01 rmanak