Is this the correct guide for tensorflow text summarization? - tensorflow

Reading the tensorflow text summarization model it states "The results described below are based on model trained on multi-gpu and multi-machine settings. It has been simplified to run on only one machine for open source purpose."
Further in the guide this command is invoked :
bazel build -c opt --config=cuda textsum/...
Does this command not relate to cuda/gpu? Why is this command truncated?

This is a bazel command: --config=cuda means "use the CUDA build configuration (and generate GPU-compatible code)", and textsum/... means "all targets under the directory textsum" (i.e. the command isn't truncated and you should type the literal ... when entering the command).

Related

error bazel build in tensorflow

At first, I would like to use bazel to help me run tensorflow with SSE and avx so I tried this within work space:
bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=cuda -k //tensorflow/tools/pip_package:build_pip_package
but it gives me a new error like following, I wonder what is wrong and what should I do? Thanks for help.
WARNING: Config values are not defined in any .rc file: cuda
ERROR: Skipping '//tensorflow/tools/pip_package:build_pip_package': no such package 'tensorflow/tools/pip_package': BUILD file not found on package path
WARNING: Target pattern parsing failed.
INFO: Analysed 0 targets (2 packages loaded).
INFO: Found 0 targets...
ERROR: command succeeded, but there were errors parsing the target pattern
INFO: Elapsed time: 2.727s, Critical Path: 0.02s
FAILED: Build did NOT complete successfully
You probably have an outdated bazel. I am not sure but you can try to use --config=opt instead of -c opt for initial versions.
You have to run ./configure. That will create a .bazelrc and .tf_configure.bazel file in your Tensorflow workspace.
The --config=cuda Bazel flag refers to entries in those two files (they are both text files). The entries typically look like this: build:cuda --some_bazel_flag.
It was answered here

What's the difference between -c opt and --config=opt when building TensorFlow from source?

When building TensorFlow from source, we're asked to set --config=opt (which by default will enable the gcc flag -march=native) but across the web I see a lot of people using -c opt instead, but according to Bazel's documentation -c is actually shorthand for --compilation_mode and not --config!
Confusingly, --compilation_mode also takes 'opt' as a value, but I assume that's just coincidental? Could someone clarify the difference between -c opt and --config=opt when executing bazel build during TensorFlow compilation?
The -c opt flag is for telling Bazel to build with optimization settings enabled and no debug information. Like you mentioned --compilation_mode opt. This is related to the flags used to compile any code.
The --config=opt is telling Bazel, to look in the .bazelrc file during compilation and read any settings that match the opt configuration. After you run your configure script with tensorflow, you should have a .bazelrc file sitting in the root of your workspace which defines settings for multiple configurations. For the opt configuration, it adds the extra -march-native for compilation.
So it is a bit coincidental that they are named the same way. But --config is a flexible tool to choose Bazel settings from a .bazelrc file. -c is really just for building code with optimizations.
--config set a configuration that expands in a set of flag defined in a .rc file. E.g. if the rc file contains build:opt -c opt, setting --config opt on the command line will expand to -c opt. The tensorflow rc file set -c opt but does not defined any opt configuration. So setting --config opt will do nothing.
ADDENDUM: ./configure of TensorFlow add some C++ options on the .bazelrc on the opt configuration (so it will expand into those C++ options).

Compiling Tensorflow with Bazel

I tried compiling tensorflow 1.3 from the HEAD of the master branch using the following line of shell command after running ./configure
sudo bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.1 --copt=-msse4.2 --config=cuda -k --verbose_failures //tensorflow/tools/pip_package:build_pip_package
I get the following error in the end.
At global scope:cc1plus: warning: unrecognized command line option '-Wno-self-assign'
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 3834.785s, Critical Path: 196.95s FAILED: Build did NOT complete successfully
These were the warnings it gave initially.
WARNING: /home/pranav/tensorflow_install/tensorflow/tensorflow/core/BUILD:1634:1: in includes attribute of cc_library rule //tensorflow/core:framework_headers_lib: '../../external/nsync/public' resolves to 'external/nsync/public' not below the relative path of its package 'tensorflow/core'. This will be an error in the future. Since this rule was created by the macro 'cc_header_only_library', the error might have been caused by the macro implementation in /home/pranav/tensorflow_install/tensorflow/tensorflow/tensorflow.bzl:911:30
WARNING: /home/pranav/tensorflow_install/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. Switch to SavedModel immediately.
WARNING: /home/pranav/tensorflow_install/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switch to SavedModel immediately.
INFO: Analysed target //tensorflow/tools/pip_package:build_pip_package (208 packages loaded).
Then loads of INFO. I'm not sure if it is of any help.
Bazel Version:
Build label: 0.5.4
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Aug 25 10:00:00 2017 (1503655200)
Build timestamp: 1503655200
Build timestamp as int: 1503655200
I read in some answer to run the following code,
$ bazel query --output=build 'somepath("//tensorflow/core:version_info_gen", "//tensorflow/tools/git:gen/spec.json")'
And it gave me this.maybe this will be of help.
# /home/pranav/tensorflow_install/tensorflow/tensorflow/core/BUILD:1546:1
genrule(
name = "version_info_gen",
generator_name = "version_info_gen",
generator_function = "tf_version_info_genrule",
generator_location = "tensorflow/core/BUILD:1546",
srcs = ["//tensorflow/tools/git:gen/spec.json", "//tensorflow/tools/git:gen/head", "//tensorflow/tools/git:gen/branch_ref"],
tools = ["//tensorflow/tools/git:gen_git_source.py"],
outs = ["//tensorflow/core:util/version_info.cc"],
cmd = "$(location //tensorflow/tools/git:gen_git_source.py) --generate $(SRCS) \"$#\"",
local = True,
)
Also, "the bazel command i wrote" > log.txt doesn't fill the text file with the terminal outputs.
If you guys want more information to help me. Suggest me a way to copy the terminal output to a text file so that i can upload it on github and give you the link.
I also used --explain to write all explanations to a file . I can upload that also if you want.
I also tried --local_resources 2048,.5,1.0 to reduce my memory allocation in case of memory issues. Still doesn't work.
Thanks a lot in advance.

Not able to resolve the warnings being given by tensorflow

Whenever I run any script using Tensor Flow, I get the following warnings:
The TensorFlow library wasn't compiled to use SSE instructions, but
these are available on your machine and could speed up CPU
computations
I tried to follow the method posted on this stack overflow post and entered the following command on the command line:
bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=cuda -k //tensorflow/tools/pip_package:build_pip_package
However I get the following error
The 'build' command is only supported from within a workspace.
How do I solve this error and then make the tensor flow compile using SSE instructions
The Installing Tensorflow from Sources page explains the procedure pretty well, make sure you have all the requirements met before running the build step.
If you wish to automate the ./configure (tensorflow-cpu) step you can run the following command from TF's root directory:
# CPU default configuration
tensorflow/tools/ci_build/builds/configured CPU
and then run the build command with native optimization:
# build with native optimization
bazel build -c opt --copt=-march=native tensorflow/tools/pip_package:build_pip_package

Running seq2seq model error

I am trying to run the code in this tutorial.
When I try to run this command:
sudo bazel run -c opt tensorflow/models/rnn/translate/translate.py -- -- data_dir ../data/translate/
I get the following error:
...................
ERROR: Cannot run target //tensorflow/models/rnn/translate:translate.py: Not executable.
INFO: Elapsed time: 1.537s
ERROR: Build failed. Not running target.
Any ideas how to resolve?
It seems there are a lot of mistakes in the Tensorflow tutorial..
I was able to run it by removing the .py, and adding an extra -- before the options like:
bazel run -c opt tensorflow/models/rnn/translate/translate -- --data_dir /home/minsoo/tensorflowrnn/data
the directory part should be changed according to your system.
I ran it by going to the directory and running:
python translate.py