Windows上的TensorFlow C ++:Executor无法创建内核

时间:2018-02-23 12:04:51

标签: c++ tensorflow

我使用CMake为Windows构建了TensorFlow C ++,我可以运行一些示例。但是,当我尝试在我自己的模型上执行预测时,我收到以下错误消息:

  

执行者无法创建内核。参数无效:NodeDef提及   attr'dilations'不在Op

  

检查GraphDef解释二进制文件是否与生成GraphDef的二进制文件保持同步。

我使用Keras和tf 1.5训练了我的模型。该模型使用adam作为优化器,是一个简单的基于ResNet50的模型。我使用this脚本将Keras模型转换为TensorFlow,它在TensorFlow for Python上运行正常。

有什么想法吗?

这是完整的日志:

2018-02-23 08:32:39.588610: E C:\Visual Studio 2015\Projects\tensorflow\tensorflow\core\common_runtime\executor.cc:643] 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]; 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: conv1/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="VALID", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](zeropadding2d_1/Pad, conv1/kernel). (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
         [[Node: conv1/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="VALID", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](zeropadding2d_1/Pad, conv1/kernel)]]
2018-02-23 08:32:39.637876: E matmul.cpp:357] Running model failed: 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]; 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: conv1/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="VALID", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](zeropadding2d_1/Pad, conv1/kernel). (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
         [[Node: conv1/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="VALID", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](zeropadding2d_1/Pad, conv1/kernel)]]

我正在使用Windows 10 x64与TensorFlow一起使用CMake和Visual Studio 2015构建。

谢谢!

2 个答案:

答案 0 :(得分:0)

解决方案是将TensorFlow更新为更新版本。我使用的版本不支持在Keras中实现的某些操作。

答案 1 :(得分:0)

我也有同样的问题。这是由于培训和目标系统中的Tensorflow版本不同。

首先,我认为这可能是由于培训平台和目标平台操作系统的差异而发生的。因为我在Mac OSX上训练了模型,但是在Linux上使用了模型。但是后来发现它是由于Tensorflow版本差异而发生的。我在Tensorflow 1.6.0中训练了模型,但是在我的Linux服务器上,Tensorflow版本1.4.0可用。我在Mac上将tensorflow降级到1.4.0,重新训练了模型,在Linux上运行良好。

相关问题