简体   繁体   English

在 Linux 上运行 Tensorflow 代码时出错

[英]Error running Tensorflow code on Linux

I ran my code on a Windows system and it worked fine.我在 Windows 系统上运行我的代码,它运行良好。 I am now trying to run it on an Ubuntu machine and I get the following error:我现在试图在 Ubuntu 机器上运行它,但出现以下错误:

W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
E tensorflow/core/common_runtime/executor.cc:594] Executor failed to create kernel. Invalid argument: NodeDef mentions attr 'dilations' not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_HALF, DT_FLOAT, DT_DOUBLE]; attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true; attr=padding:string,allowed=["SAME", "VALID"]; attr=data_format:string,default="NHWC",allowed=["NHWC", "NCHW"]>; NodeDef: import/MobilenetV1/MobilenetV1/Conv2d_0/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_import/input_0, import/MobilenetV1/Conv2d_0/weights)
     [[Node: import/MobilenetV1/MobilenetV1/Conv2d_0/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_import/input_0, import/MobilenetV1/Conv2d_0/weights)]]
Traceback (most recent call last):
  File "/user/HS127/sc00858/Documents/tensorflow-for-poets-2/scripts/test.py", line 118, in <module>
    {input_operation.outputs[0]: t})
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 767, in run
    run_metadata_ptr)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 965, in _run
    feed_dict_string, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1015, in _do_run
    target_list, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1035, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: NodeDef mentions attr 'dilations' not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_HALF, DT_FLOAT, DT_DOUBLE]; attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true; attr=padding:string,allowed=["SAME", "VALID"]; attr=data_format:string,default="NHWC",allowed=["NHWC", "NCHW"]>; NodeDef: import/MobilenetV1/MobilenetV1/Conv2d_0/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_import/input_0, import/MobilenetV1/Conv2d_0/weights)
     [[Node: import/MobilenetV1/MobilenetV1/Conv2d_0/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_import/input_0, import/MobilenetV1/Conv2d_0/weights)]]

Caused by op u'import/MobilenetV1/MobilenetV1/Conv2d_0/convolution', defined at:
  File "/user/HS127/sc00858/Documents/tensorflow-for-poets-2/scripts/test.py", line 85, in <module>
    graph = load_graph(model_file)
  File "/user/HS127/sc00858/Documents/tensorflow-for-poets-2/scripts/test.py", line 38, in load_graph
    tf.import_graph_def(graph_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/importer.py", line 288, in import_graph_def
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2327, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1226, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): NodeDef mentions attr 'dilations' not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_HALF, DT_FLOAT, DT_DOUBLE]; attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true; attr=padding:string,allowed=["SAME", "VALID"]; attr=data_format:string,default="NHWC",allowed=["NHWC", "NCHW"]>; NodeDef: import/MobilenetV1/MobilenetV1/Conv2d_0/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_import/input_0, import/MobilenetV1/Conv2d_0/weights)
     [[Node: import/MobilenetV1/MobilenetV1/Conv2d_0/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_import/input_0, import/MobilenetV1/Conv2d_0/weights)]]

I don't understand why this error is occurring and any help in debugging would be appreciated.我不明白为什么会发生这个错误,任何调试帮助将不胜感激。 My code is trying to run inference on a pre-trained mobilenet graph.我的代码试图在预先训练的 mobilenet 图上运行推理。

EDIT编辑

Minimum of TF 1.5 is needed to infer from Mobilenet从 Mobilenet 推断至少需要 TF 1.5

I'm going to put my money on a Tensorflow version mismatch.我要把钱花在 Tensorflow 版本不匹配上。 Based on the following error text:基于以下错误文本:

NodeDef mentions attr 'dilations' not in Op

Dilated convolutions are a rather newish concept, and likely to be changing from minor version to minor version, and it sounds like your code is utilizing it in a function, perhaps in the layers api.扩张卷积是一个相当新的概念,可能会从次要版本更改为次要版本,听起来您的代码正在一个函数中使用它,也许在层 api 中。 Check that you're running the same tensorflow version on both systems.检查您是否在两个系统上运行相同的 tensorflow 版本。 If they're not the same version, look for the term dilations in your code as the likely culprit of change.如果它们的版本不同,请在代码中查找术语dilations作为更改的可能罪魁祸首。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM