首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >tensorflow UnknownError:图形执行错误: JIT编译失败。[Op:__inference_restored_function_body_9127]

tensorflow UnknownError:图形执行错误: JIT编译失败。[Op:__inference_restored_function_body_9127]
EN

Stack Overflow用户
提问于 2022-11-25 01:13:14
回答 1查看 41关注 0票数 0

我试着使用来自tensorflow中心的通用语句编码器。从集线器下载并提取通用句子编码器,当我试图预测一种感觉时,它显示出一个错误:

UnknownError:图形执行错误:

JIT编译失败。

代码语言:javascript
运行
复制
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)

得到了错误

代码语言:javascript
运行
复制
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]

我该怎么修呢?我只想让它起作用。

EN

Stack Overflow用户

发布于 2022-11-25 04:43:32

首先,在CPU后置、tf.estimators()和TensorFlow集线器需要专用硬件的情况下,使用GPU是一个错误。嵌入-4

示例:尝试将CUDA路径添加到操作系统的局部变量中,存在错误,请按照说明进行操作。显示未完成安装或安装的错误。

代码语言:javascript
运行
复制
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)

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

代码语言:javascript
运行
复制
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)
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74567500

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档