Making tensorflow size smaller using selective registration for MacOs #53202
Labels
stat:awaiting tensorflower
Status - Awaiting response from tensorflower
subtype:macOS
macOS Build/Installation issues
TF 2.7
Issues related to TF 2.7.0
type:build/install
Build and install issues
type:feature
Feature requests
Please make sure that this is a build/installation issue. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template
System information
Describe the problem
I am trying to make TF size smaller on MacOs the size is 950mb but after using the below optional flags the size is reduced to 839mb:
--config=nogcp --config=nonccl --config=noaws --config=nohdfs --define=with_xla_support=false --define=with_ignite_support=false --define=with_kafka_support=false
Is there any more flags that can be used to reduce the size of TF?
Since it is still big 839mb I would like to use the selective registration method to get only the operations I use in my model as described in:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/print_selective_registration_header.py
I followed the steps mentioned in this link but I am not finding equivalent command for MacOs for the following step:
bazel build -c opt --copt="-DSELECTIVE_REGISTRATION" --copt="-DSUPPORT_SELECTIVE_REGISTRATION" //tensorflow/tools/android/inference_interface:libtensorflow_inference.so
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain
--crosstool_top=//external:android/crosstool --cpu=armeabi-v7a
My questions:
Is the selective registration supported for android only? I didn't find a directory named MacOs in //tensorflow/tools/?
I need to support both cpu intel and arm so what I should type in --cpu?
I tried --cpu=x86_64 and --cpu=arm64 got:
ERROR: /private/var/tmp/_bazel_integrator/0a793f72f57e57f678a00d6fdcdcda5e/external/local_config_cc/BUILD:41:19: in cc_toolchain_suite rule @local_config_cc//:toolchain: cc_toolchain_suite '@local_config_cc//:toolchain' does not contain a toolchain for cpu 'x86_64'
What is the equivalent command for MacOs for --crosstool_top=//external:android/crosstool ?
I tried --crosstool_top=//external:macos/crosstool but got error:
no such target '//external:macos/crosstool': target 'macos/crosstool' not declared in package 'external' defined by /Users/integrator/tensorflow/WORKSPACE
Provide the exact sequence of commands / steps that you executed before running into the problem
I used an official trained model from here: http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz
I got runtime warning for this step:
INFO:tensorflow:Loading proto file /Users/integrator/Downloads/vgg_16.ckpt
I1125 15:27:19.769747 8639198720 selective_registration_header_lib.py:84] Loading proto file /Users/integrator/Downloads/vgg_16.ckpt
/Users/integrator/tensorflow/bazel-bin/tensorflow/python/tools/print_selective_registration_header.runfiles/org_tensorflow/tensorflow/python/tools/selective_registration_header_lib.py:93: RuntimeWarning: Unexpected end-group tag: Not all data was converted
graph_def = graph_pb2.GraphDef.FromString(file_data)
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain
--crosstool_top=//external:android/crosstool --cpu=armeabi-v7a
Got different errors when running the last step three times in sequence:
ERROR: /private/var/tmp/_bazel_integrator/0a793f72f57e57f678a00d6fdcdcda5e/external/highwayhash/BUILD.bazel:8:11: undeclared inclusion(s) in rule '@highwayhash//:sip_hash':
this rule is missing dependency declarations for the following files included by 'highwayhash/highwayhash/sip_hash.cc':
ERROR: /Users/integrator/tensorflow/tensorflow/core/lib/jpeg/BUILD:47:11: undeclared inclusion(s) in rule '//tensorflow/core/lib/jpeg:portable_jpeg_internal':
this rule is missing dependency declarations for the following files included by 'tensorflow/core/lib/jpeg/jpeg_handle.cc':
ERROR:/private/var/tmp/_bazel_integrator/0a793f72f57e57f678a00d6fdcdcda5e/external/com_google_absl/absl/hash/BUILD.bazel:29:11: undeclared inclusion(s) in rule '@com_google_absl//absl/hash:hash':
this rule is missing dependency declarations for the following files included by 'com_google_absl/absl/hash/internal/hash.cc':
Any other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.
The text was updated successfully, but these errors were encountered: