Windows平台上的TensorFlow C++:执行程序无法创建内核

xdnvmnnf  于 2022-11-25  发布在  Windows
关注(0)|答案(2)|浏览(152)

我已经使用CMake构建了TensorFlow C++ for Windows,并且可以运行一些示例。但是,当我尝试对模型执行预测时,我收到以下错误消息:
执行程序无法创建内核。参数无效:NodeDef提到不在Op中的属性

检查GraphDef-interpreting二进制文件是否与GraphDef-generating二进制文件同步更新。
我已经使用Keras和tf 1.5训练了我的模型。该模型使用adam作为优化器,是一个基于ResNet 50的简单模型。我使用this脚本将Keras模型转换为TensorFlow,它在Python的TensorFlow上运行正常。
有什么想法吗?
以下是完整日志:

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操作系统,并使用CMake和Visual Studio 2015构建了TensorFlow。
谢谢你!

cunj1qz1

cunj1qz11#

解决方案正在将TensorFlow更新到较新的版本。我使用的版本不支持Keras中实现的一些操作。

o7jaxewo

o7jaxewo2#

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

相关问题