【问题标题】:tensorflow UnknownError: Graph execution error: JIT compilation failed. [Op:__inference_restored_function_body_9127]tensorflow UnknownError:图形执行错误:JIT 编译失败。 [操作:__inference_restored_function_body_9127]
【发布时间】:2023-01-24 05:41:52
【问题描述】:

我试图使用来自 tensorflow hub 的 UNIVERSAL SENTENCE ENCODER。 从集线器下载并提取通用句子编码器 当我试图预测一个衰老时,它显示了一个错误说

UnknownError:图形执行错误:

JIT 编译失败。

import tensorflow_hub as hub

#loading downloaded and untarred universal sentence encoder
embed = hub.load("./universal-sentence-encoder_4/")
  
# passed as an array in embed()
Sentences = [
    "How old are you"
]
embeddings = embed(Sentences)
  
print(embeddings)
  

并得到错误

2022-11-25 06:29:46.006767: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 2630 MB memory:  -> device: 0, name: NVIDIA GeForce GTX 1650, pci bus id: 0000:01:00.0, compute capability: 7.5
error: Can't find libdevice directory ${CUDA_DIR}/nvvm/libdevice
2022-11-25 06:29:50.652156: W tensorflow/core/framework/op_kernel.cc:1768] UNKNOWN: JIT compilation failed.
---------------------------------------------------------------------------
UnknownError                              Traceback (most recent call last)
Input In [1], in <cell line: 25>()
     17 # Load pre-trained universal sentence encoder model
     18 # embed = hub.load("https://tfhub.dev/google/universal-sentence-encoder/4")
     19   
     20 # Sentences for which you want to create embeddings,
     21 # passed as an array in embed()
     22 Sentences = [
     23     "How old are you"
     24 ]
---> 25 embeddings = embed(Sentences)
     27 # Printing embeddings of each sentence
     28 print(embeddings)

File ~/miniconda3/envs/tf/lib/python3.10/site-packages/tensorflow/python/saved_model/load.py:704, in _call_attribute(instance, *args, **kwargs)
    703 def _call_attribute(instance, *args, **kwargs):
--> 704   return instance.__call__(*args, **kwargs)

File ~/miniconda3/envs/tf/lib/python3.10/site-packages/tensorflow/python/util/traceback_utils.py:153, in filter_traceback.<locals>.error_handler(*args, **kwargs)
    151 except Exception as e:
    152   filtered_tb = _process_traceback_frames(e.__traceback__)
--> 153   raise e.with_traceback(filtered_tb) from None
    154 finally:
    155   del filtered_tb

File ~/miniconda3/envs/tf/lib/python3.10/site-packages/tensorflow/python/eager/execute.py:54, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
     52 try:
     53   ctx.ensure_initialized()
---> 54   tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
     55                                       inputs, attrs, num_outputs)
     56 except core._NotOkStatusException as e:
     57   if name is not None:

UnknownError: Graph execution error:

JIT compilation failed.
     [[{{node EncoderDNN/EmbeddingLookup/EmbeddingLookupUnique/embedding_lookup/mod}}]] [Op:__inference_restored_function_body_4561]

我该如何解决? 我只是想让它工作。

【问题讨论】:

    标签: tensorflow deep-learning word-embedding


    【解决方案1】:

    首先,使用 GPU 而不是 CPU 回退存在一个错误,tf.estimators() 和 TensorFlow-hub 需要专用硬件。 embedding-4

    示例:尝试将 CUDA 路径添加到您操作系统的局部变量,您遇到了错误,请按照说明进行操作。错误指示未完成的安装或设置。

    import tensorflow as tf
    import tensorflow_hub as hub
    
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""
    [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
    None
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""
    physical_devices = tf.config.experimental.list_physical_devices('GPU')
    assert len(physical_devices) > 0, "Not enough GPU hardware devices available"
    config = tf.config.experimental.set_memory_growth(physical_devices[0], True)
    print(physical_devices)
    print(config)
    
    embed = hub.load("https://tfhub.dev/google/universal-sentence-encoder/4")
    
    
    embeddings = embed([
        "The quick brown fox jumps over the lazy dog.",
        "I am a sentence for which I would like to get its embedding"])
      
    print(embeddings)
    

    输出:简单的嵌入层,单词到序列的工作原理。

    tf.Tensor(
    [[-0.03133015 -0.06338634 -0.01607501 ... -0.03242781 -0.0457574
       0.05370456]
     [ 0.05080863 -0.01652433  0.0157378  ...  0.00976659  0.03170122
       0.01788119]], shape=(2, 512), dtype=float32)
    

    【讨论】:

      【解决方案2】:

      面临类似的问题。我有张量流 2.10.1。通过降级到 2.8.0 修复

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-10-17
        • 2021-05-25
        • 1970-01-01
        • 2021-04-08
        • 1970-01-01
        • 1970-01-01
        • 2022-11-15
        相关资源
        最近更新 更多