Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.13.0 of TensorFlowSharp unable to consume .PB model file (works with updated tensorflow.dll) #444

Open
sdg002 opened this issue Aug 1, 2019 · 6 comments

Comments

@sdg002
Copy link

sdg002 commented Aug 1, 2019

Describe the bug
I have a simple C# console EXE (.NET Framework which uses Version 1.13.0 of TensorFlowSharp . The EXE produces this error when consuming a TF model file produced using Version 1.14.0 of tensorflow-gpu . The EXE worked beautifully few months ago. I upgraded the version of TF and ran into this problem.

TensorFlow.TFException: NodeDef mentions attr 'explicit_paddings' not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_HALF, DT_BFLOAT16, 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"]; attr=dilations:list(int),default=[1, 1, 1, 1]>; NodeDef: {{node conv1/convolution}} = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], explicit_paddings=[], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](conv1_input, conv1/kernel/read). 
(Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
   at TensorFlow.TFStatus.CheckMaybeRaise(TFStatus incomingStatus, Boolean last)
   at TensorFlow.TFGraph.Import(TFBuffer graphDef, TFImportGraphDefOptions options, TFStatus status)
   at TensorFlow.TFGraph.Import(Byte[] buffer, TFImportGraphDefOptions options, TFStatus status)
   at TensorFlow.TFGraph.Import(Byte[] buffer, String prefix, TFStatus status)
   at ConsoleAppTester.Program.TestMnistImagesUsingTrainedModel(String modelfile, String folderWithMNIST) in C:\Users\saurabhd\MyTrials\MachineLearnings-2\MNISTpng\ConsoleAppTester\Program.cs:line 101
   at ConsoleAppTester.Program.Main(String[] args) in C:\Users\saurabhd\MyTrials\MachineLearnings-2\MNISTpng\ConsoleAppTester\Program.cs:line 23

To Reproduce

  • Train MNIST using TF 1.14 (GPU)
  • Export model and weights to .PB
  • Use 1.13 TensorflowSharp to import the graph

Expected behavior
The same TensorFlowSharp code worked with older Tensorflow models.

Desktop (please complete the following information):

  • OS: Windows 10
  • Version: TF 1.14 , TensorFlowSharp 1.13

What solved the problem?
I copied over the latest tensorflow.dll as libtensorflow.dll into the output directory of the C# executable project.
Source URL:
https://www.tensorflow.org/install/lang_c

Thank you for all the efforts. I am happy to provide further Python scripts if you want test cases.

@DavideCatto
Copy link

I had the same problems. I had resolved training the network with the same TF version 1.13.
It's a work around but actually works.

@sdg002
Copy link
Author

sdg002 commented Aug 9, 2019

Hi @DavideCatto ,
Thanks for replying. I tried downgrading to 1.13 but I get this message. By any chance would you know why Python would not allow me to install 1.13?
Thanks,
Saurabh

py -m pip install tensorflow-gpu==1.13
Collecting tensorflow-gpu==1.13
  Could not find a version that satisfies the requirement tensorflow-gpu==1.13 (from versions: 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 2.0.0a0, 2.0.0b0, 2.0.0b1)
No matching distribution found for tensorflow-gpu==1.13

@DavideCatto
Copy link

Hi @DavideCatto ,
Thanks for replying. I tried downgrading to 1.13 but I get this message. By any chance would you know why Python would not allow me to install 1.13?
Thanks,
Saurabh

py -m pip install tensorflow-gpu==1.13
Collecting tensorflow-gpu==1.13
  Could not find a version that satisfies the requirement tensorflow-gpu==1.13 (from versions: 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 2.0.0a0, 2.0.0b0, 2.0.0b1)
No matching distribution found for tensorflow-gpu==1.13

Try tensorflow-gpu==r1.13
Cheers

@sdg002
Copy link
Author

sdg002 commented Aug 11, 2019

Thanks for the hint.

This command worked.

py -m pip install tensorflow-gpu==1.13.1

@geometrikal
Copy link

Instead of recompiling you could update the tensorflow dll. This was the easiest way for me:

  1. Install the SciSharp.TensorFlow.Redist package for the tensorflow version you need.
  2. Copy the tensorflow.dll from there into the root directory of the project and rename to libtensorflow.dll
  3. Add this file to your project in VS and set its build properties to "Content" and "Copy if newer"

@mage-sh
Copy link

mage-sh commented Feb 29, 2020

Instead of recompiling you could update the tensorflow dll. This was the easiest way for me:

  1. Install the SciSharp.TensorFlow.Redist package for the tensorflow version you need.
  2. Copy the tensorflow.dll from there into the root directory of the project and rename to libtensorflow.dll
  3. Add this file to your project in VS and set its build properties to "Content" and "Copy if newer"

can you explain the 2nd and 3rd step please. @geometrikal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants