When running with Bazel, where should I save .pb graphs for Tensorflow? - tensorflow

Directory structure:
~/tensorflow/tensorflow/cc/dnnops/
├── BUILD
├── graph.pb
└── main.cc
The failing code line from main.cc: status = ReadBinaryProto(tf::Env::Default(), "graph.pb", &graph_def);. Full code can be found here.
Bazel output:
WARNING: /home//.cache/bazel/_bazel_rd1/4ab077b6e1a2076b6ea9f23b417088a6/external/protobuf_archive/WORKSPACE:1: Workspace name in /home//.cache/bazel/bazel/4ab077b6e1a2076b6ea9f23b417088a6/external/protobuf_archive/WORKSPACE (#com_google_protobuf) does not match the name given in the repository's definition (#protobuf_archive); this will cause a build error in future versions
INFO: Analysed target //tensorflow/cc/dnnops:dnnops (0 packages loaded).
INFO: Found 1 target...
Target //tensorflow/cc/dnnops:dnnops up-to-date:
bazel-bin/tensorflow/cc/dnnops/dnnops
INFO: Elapsed time: 5.378s, Critical Path: 5.04s
INFO: 2 processes, local.
INFO: Build completed successfully, 3 total actions
INFO: Running command line: bazel-bin/tensorflow/cc/dnnops/dnnops
Not found: graph.pb; No such file or directory
ERROR: Non-zero return code '1' from command: Process exited with status 1
What I tried
Copy the same graph file inside bazel-bin/tensorflow/cc/dnnops. Still fails with same output from Bazel.
Question
How should I expose the graph file location to Tensorflow/Bazel?

Silly oversight... I entered the full path. From this:
status = ReadBinaryProto(tf::Env::Default(), "graph.pb", &graph_def);
To this:
status = ReadBinaryProto(tf::Env::Default(), "/home/<user>/path/to/graph.pb", &graph_def);

Related

how can i solve FreeRTOS error on atmega128?

------ Build started: Project: freertos, Configuration: Debug AVR ------
Build started.
Project "freertos.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "D:\AVR\freertos\freertos\freertos.cproj" (target "Build" depends on it):
Task "RunCompilerTask"
Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils
C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe all --jobs 4 --output-sync
Building target: freertos.elf
Invoking: AVR/GNU Linker : 5.4.0
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -o freertos.elf heap_1.o list.o main.o port.o queue.o tasks.o -Wl,-Map="freertos.map" -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mrelax -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.3.300\gcc\dev\atmega128"
D:\AVR\freertos\freertos\Debug\Makefile(166,1): error: recipe for target 'freertos.elf' failed
tasks.o: In function `prvIdleTask':
D:\AVR\freertos\freertos\Debug\tasks.c(1,1): error: undefined reference to `vApplicationIdleHook'
collect2.exe(0,0): error: ld returned 1 exit status
make: *** [freertos.elf] Error 1
The command exited with code 2.
Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "freertos.cproj" -- FAILED.
Done building project "freertos.cproj" -- FAILED.
Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
You have to options to solve this error:
1- set configUSE_IDLE_HOOK to 0 in FreeRTOSConfig.h.
2- Define a function that has the following name and prototype:
void vApplicationIdleHook( void );
Anything that starts 'Application' is expected to be provided by the application writer, rather than be part of the kernel - and in all cases the features are options - so as per the above you can either provide the hook function or tern the feature off.

Problems with absl dependencies in TensorFlow print_selective_registration_header building

I'm trying to build //tensorflow/python/tools:print_selective_registration_header and get following output:
$ bazel build --copt="-DUSE_GEMM_FOR_CONV" tensorflow/python/tools:print_selective_registration_header
...
INFO: Analyzed target //tensorflow/python/tools:print_selective_registration_header (377 packages loaded, 24256 targets configured).
INFO: Found 1 target...
INFO: Deleting stale sandbox base /private/var/tmp/_bazel_glebdavydov/01d4cf1f69cd2606674d307a7a455e95/sandbox
ERROR: /Users/glebdavydov/Downloads/tensorflow-master/tensorflow/c/BUILD:372:1: undeclared inclusion(s) in rule '//tensorflow/c:ops':
this rule is missing dependency declarations for the following files included by 'tensorflow/c/ops.cc':
'tensorflow/contrib/makefile/downloads/absl/absl/strings/string_view.h'
'tensorflow/contrib/makefile/downloads/absl/absl/types/optional.h'
Target //tensorflow/python/tools:print_selective_registration_header failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 54.737s, Critical Path: 13.10s
INFO: 4 processes: 4 local.
FAILED: Build did NOT complete successfully
How can I fix this?
I fixed that issue by installing version of bazel corresponding to this build configurations.

Tensorflow bazel quantization build error

I am trying to build tensorflow tools package with bazel 0.18.0
following steps are ok
git clone https://github.com/tensorflow/tensoflow
bazel build --config=cuda //tensorflow/tools/pip_package:build_pip_package
bazel build --config=cuda //tensorflow/examples/label_image:label_image
until trying to run this command line
bazel build --config=cuda //tensorflow/contrib/quantization:quantize_graph
it show error, so should i give something else then quantize_graph? and what i can use or find?
root#24663fb1018d:/srv/wu/tensorflow-src/tensorflow# bazel build --config=cuda //tensorflow/contrib/quantization:quantize_graph
WARNING: Duplicate rc file: /srv/wu/tensorflow-src/tensorflow/tools/bazel.rc is read multiple times, most recently imported from /srv/wu/tensorflow-src/tensorflow/.bazelrc
WARNING: Processed legacy workspace file /srv/wu/tensorflow-src/tensorflow/tools/bazel.rc. This file will not be processedin the next release of Bazel. Please read https://github.com/bazelbuild/bazel/issues/6319 for further information, including how to upgrade.
Starting local Bazel server and connecting to it...
WARNING: The following configs were expanded more than once: [cuda]. For repeatable flags, repeats are counted twice and may lead to unexpected behavior.
ERROR: Skipping '//tensorflow/contrib/quantization:quantize_graph': no such target '//tensorflow/contrib/quantization:quantize_graph': target 'quantize_graph' not declared in package 'tensorflow/contrib/quantization' defined by /srv/wu/tensorflow-src/tensorflow/tensorflow/contrib/quantization/BUILD
WARNING: Target pattern parsing failed.
ERROR: no such target '//tensorflow/contrib/quantization:quantize_graph': target 'quantize_graph' not declared in package 'tensorflow/contrib/quantization' defined by /srv/wu/tensorflow-src/tensorflow/tensorflow/contrib/quantization/BUILD
INFO: Elapsed time: 1.195s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded)
and then i tried with tools path, no luck
bazel build --config=cuda //tensorflow/tools/quantization:quantize_graph
WARNING: Duplicate rc file: /srv/wu/tensorflow-src/tensorflow/tools/bazel.rc is read multiple times, most recently imported from /srv/wu/tensorflow-src/tensorflow/.bazelrcWARNING: Processed legacy workspace file /srv/wu/tensorflow-src/tensorflow/tools/bazel.rc. This file will not be processed in the next release of Bazel. Please read https://github.com/bazelbuild/bazel/issues/6319 for further information, including how to upgrade.WARNING: The following configs were expanded more than once: [cuda]. For repeatable flags, repeats are counted twice and may lead to unexpected behavior.ERROR: Skipping '//tensorflow/tools/quantization:quantize_graph': no such package'tensorflow/tools/quantization': BUILD file not found on package pathWARNING: Target pattern parsing failed.
ERROR: no such package 'tensorflow/tools/quantization': BUILD file not found on package path
INFO: Elapsed time: 0.506s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
also the toco is not working
bazel build --config=cuda tensorflow/contrib/lite/toco:toco
WARNING: Duplicate rc file: /srv/wu/tensorflow-src/tensorflow/tools/bazel.rc is read multiple times, most recently imported from /srv/wu/tensorflow-src/tensorflow/.bazelrc
WARNING: Processed legacy workspace file /srv/wu/tensorflow-src/tensorflow/tools/bazel.rc. This file will not be processed in the next release of Bazel. Please read https://github.com/bazelbuild/bazel/issues/6319 for further information, including how to upgrade.WARNING: The following configs were expanded more than once: [cuda]. For repeatable flags, repeats are counted twice and may lead to unexpected behavior.ERROR: Skipping 'tensorflow/contrib/lite/toco:toco': no such package 'tensorflow/contrib/lite/toco': BUILD file not found on package path
WARNING: Target pattern parsing failed.ERROR: no such package 'tensorflow/contrib/lite/toco': BUILD file not found on package pathINFO: Elapsed time: 0.500s
INFO: 0 processes.FAILED: Build did NOT complete successfully (0 packages loaded)
To verify where targets are, look into the BUILD file in the package directory.
The quantize_graph target has been moved to the //tensorflow/contrib/quantize package. This should work:
$ bazel build --config=cuda //tensorflow/contrib/quantize:quantize_graph
The toco target has been moved from //tensorflow/contrib/lite/toco to //tensorflow/lite/toco. Like quantize_graph, this should work:
$ bazel build --config=cuda //tensorflow/lite/toco:toco

Inspecting Tensorflow graph

I was testing the command to inspect a custom built tensorflow graph.
The command I used is the one found in Here
bazel build tensorflow/tools/graph_transforms:summarize_graph bazel-bin/tensorflow/tools/graph_transforms/summarize_graph --in_graph=/home/WarMachineRox/test_frozen_graph.pb
But it returns an error saying:
ERROR: Unrecognized option: --in_graph=/home/WarMachineRox/test_frozen_graph.pb
If I use in_graph option without '--', it returns:
ERROR: no such package 'tensorflow/tools/graph_transforms/tensorflow/tools/graph_transforms': BUILD file not found on package path
Is there anyway to inspect tensorflow graph input node without using this?
Thanks,
bazel build tensorflow/tools/graph_transforms:summarize_graph bazel-bin/tensorflow/tools/graph_transforms/summarize_graph --in_graph=/home/WarMachineRox/test_frozen_graph.pb
should be two separate commands:
$ bazel build tensorflow/tools/graph_transforms:summarize_graph
INFO: Analysed target //tensorflow/tools/graph_transforms:summarize_graph (0 packages loaded).
INFO: Found 1 target...
Target //tensorflow/tools/graph_transforms:summarize_graph up-to-date:
bazel-bin/tensorflow/tools/graph_transforms/summarize_graph
INFO: Elapsed time: 0.372s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
$ bazel-bin/tensorflow/tools/graph_transforms/summarize_graph
2018-05-29 12:37:51.343760: E tensorflow/tools/graph_transforms/summarize_graph_main.cc:313] in_graph graph can't be empty.
usage: bazel-bin/tensorflow/tools/graph_transforms/summarize_graph
Flags:
--in_graph="" string input graph file name
--print_structure=false bool whether to print the network connections of the graph

bazel - Error building TensorFlow with local LLVM repository

Essentially, I want to run TensorFlow with a custom LLVM repository and not the llvm-mirror that bazel pulls from.
I made the following changes:
Changed the temp_workaround_http_archive rule in //tensorflow/workspace.bzl to:
native.local_repository (
name = "llvm",
path = "/git/llvm/",
)
In /git/llvm I added the file WORKSPACE containing:
workspace( name = "llvm" )
However, I know that an llvm.build file is required, but since I am new to bazel, I am not sure where it should be located.
I am getting the following error log:
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
ERROR: /git/tensorflow/tensorflow/tools/pip_package/BUILD:81:1: no such package '#llvm//': BUILD file not found on package path and referenced by '//tensorflow/tools/pip_package:licenses'.
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted.
INFO: Elapsed time: 0.219s
I installed TensorFlow from source. Here is the version info:
$ git rev-parse HEAD
4c3bb1aeb7bb46bea35036433742a720f39ce348
$ bazel version
Build label: 0.4.5
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Mar 16 12:19:38 2017 (1489666778)
Build timestamp: 1489666778
Build timestamp as int: 1489666778
Thanks in advance for the help!
Found the fix. Quite simple actually.
The local_repository rule in bazel is for external bazel repositories only. To use a non-bazel external repository, we need to use new_local_repository which takes build_file as an argument.
You can use the http server function of python to build a local file server, like:
python3 -m http.server
Then edit the file "tensorflow/workspace.bzl"
tf_http_archive(
name = "llvm",
urls = [
"https://mirror.bazel.build/**/195a164675af86f390f9816e53291013d1b551d7.tar.gz",
"http://localhost:8000/195a164675af86f390f9816e53291013d1b551d7.tar.gz",
"https://github.com/**/195a164675af86f390f9816e53291013d1b551d7.tar.gz",
],
sha256 = "57a8333f8e6095d49f1e597ca18e591aba8a89d417f4b58bceffc5fe1ffcc02b",
strip_prefix = "llvm-195a164675af86f390f9816e53291013d1b551d7",
build_file = str(Label("//third_party/llvm:llvm.BUILD")),
)
Add one local file path in the middle line of urls, and then rebuild it again.