Skip to content

Fixed issue with Protobufs for TensorFlow 1.4.0 #24

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 50 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,54 @@ example.pn.cc
Finally you could use the funcition in the files to extract your label data.

### FAQ
1. If you still get errors like after finishing the above instruction:
```
Invalid argument: No OpKernel was registered to support Op 'xxx' with these attrs. Registered devices: [CPU], Registered kernels:
<no registered kernels>
```
- Solution: First check if you use the certain ops_to_register.h for the model you choose.
Then check the file "tensorflow/contrib/makefile/tf_op_files.txt" and add the "tensorflow/core/kernels/cwise_op_xxx.cc" into the txt file if it is not in there.

2. Make sure you've added the "-O3 -DANDROID_TYPES=ANDROID_TYPES_FULL -DSELECTIVE_REGISTRATION -DSUPPORT_SELECTIVE_REGISTRATION" when run the "compile_ios_tensorflow_s.sh".

1. If you still get errors like after finishing the above instruction:
```
Invalid argument: No OpKernel was registered to support Op 'xxx' with these attrs. Registered devices: [CPU], Registered kernels:
<no registered kernels>
```
- Solution: First check if you use the certain ops_to_register.h for the model you choose.
Then check the file "tensorflow/contrib/makefile/tf_op_files.txt" and add the "tensorflow/core/kernels/cwise_op_xxx.cc" into the txt file if it is not in there.

3. Invalid argument: No OpKernel was registered to support Op 'Conv2D' with these attrs. Registered devices: [CPU], Registered kernels:
```
[[Node: FeatureExtractor/InceptionV2/InceptionV2/Conv2d_1a_7x7/separable_conv2d = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](FeatureExtractor/InceptionV2/InceptionV2/Conv2d_1a_7x7/separable_conv2d/depthwise, FeatureExtractor/InceptionV2/Conv2d_1a_7x7/pointwise_weights/read)]]
```
- Solution: Because of the special structure of models, they include the GEMM function in the conv layers. However, the default Makefile does not use the GEMM for conv layer, so that you need to munually replace the line in the ops_to_register.h. In your ops_to_register.h replace the line "Conv2DOp<CPUDevice, float>" with "Conv2DUsingGemmOp< float, Im2ColConvFunctor<float, float, float, FastGemmFunctor<float, float, float>>>" and the problem will be solved.
2. Make sure you've added the "-O3 -DANDROID_TYPES=ANDROID_TYPES_FULL -DSELECTIVE_REGISTRATION -DSUPPORT_SELECTIVE_REGISTRATION" when run the "compile_ios_tensorflow_s.sh".


3. Invalid argument: No OpKernel was registered to support Op 'Conv2D' with these attrs. Registered devices: [CPU], Registered kernels:
```
[[Node: FeatureExtractor/InceptionV2/InceptionV2/Conv2d_1a_7x7/separable_conv2d = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](FeatureExtractor/InceptionV2/InceptionV2/Conv2d_1a_7x7/separable_conv2d/depthwise, FeatureExtractor/InceptionV2/Conv2d_1a_7x7/pointwise_weights/read)]]
```
- Solution: Because of the special structure of models, they include the GEMM function in the conv layers. However, the default Makefile does not use the GEMM for conv layer, so that you need to munually replace the line in the ops_to_register.h. In your ops_to_register.h replace the line "Conv2DOp<CPUDevice, float>" with "Conv2DUsingGemmOp< float, Im2ColConvFunctor<float, float, float, FastGemmFunctor<float, float, float>>>" and the problem will be solved.

4. GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
\#error This file was generated by an older version of protoc which is
\#error incompatible with your Protocol Buffer headers. Please
\#error regenerate this file with a newer version of protoc.

- Solution: This means that the version of Protobuf which is being included from the TF_ROOT does not match the version which was used to generate the .cc and .h interface files. The easiest thing to do is just to re-generate them from the original .proto spec file.
Either check the CHANGES.txt file in your TF_ROOT:
```
$ cat $TF_ROOT/tensorflow/contrib/makefile/downloads/protobuf/CHANGES.txt
```
The newest version number of that lib will be at the top.
Or look at the IF statement in the .h file
If it says:
\#if GOOGLE_PROTOBUF_VERSION < 3004000
That means Protobuf 3.4.0

Then get the correct version binary for your system
https://github.com/google/protobuf/releases

The original .proto file is from here:
https://github.com/tensorflow/models/blob/master/research/object_detection/protos/string_int_label_map.proto

Then run something like:
```
$ ./protoc --version
libprotoc 3.4.0 \# correct version
$ ./protoc --cpp_out=./ ./string_int_label_map.proto
```

Then replace the files in the ex_SSD_Mobilenet_TF folder with the newly generated ones:
- string_int_label_map.pb.cc
- string_int_label_map.pb.h

The app should now compile.
Empty file added TF_Graph/.blank
Empty file.
Loading