TensorFlow Tutorial on Sequence-to-Sequence Models: Running translate.py return CRC check failure - tensorflow

I am trying to run tutorial for sequence-to-sequence model, but running the following command
bazel run -c opt <...>/models/rnn/translate/translate.py --data_dir [your_data_directory]
ends with the following error
for line in gz_file:
File "/usr/lib/python2.7/gzip.py", line 462, in readline
c = self.read(readsize)
File "/usr/lib/python2.7/gzip.py", line 268, in read
self._read(readsize)
File "/usr/lib/python2.7/gzip.py", line 315, in _read
self._read_eof()
File "/usr/lib/python2.7/gzip.py", line 354, in _read_eof
hex(self.crc)))
IOError: CRC check failed 0xb94c52ed != 0xc6088f89L
ERROR: Non-zero return code '1' from command: Process exited with status 1.
Did I do something wrong, or is there (another) error in the tutorial?

Try to remove files in dir /tmp:
training-giga-fren.tar
giga-fren.release2.en.gz
giga-fren.release2.fr.gz
And then rerun
bazel run -c opt <...>/models/rnn/translate/translate.py --data_dir [your_data_directory]

Related

Problem with building Chromium for Windows on Mac host

I am trying to cross build chromium on mac host. I have followed the instructions from https://chromium.googlesource.com/chromium/src.git/+/HEAD/docs/win_cross.md and everything seems fine. But when I run autoninja -C out/win chrome I face with the following error. Any help would be appreciated.
ninja: Entering directory `out/win'
[0/1] Regenerating ninja files
ERROR at //build/config/win/visual_studio_version.gni:27:7: Script returned non-zero exit code.
exec_script("../../vs_toolchain.py", [ "get_toolchain_dir" ], "scope")
^----------
Current dir: /chromium/src/out/win/
Command: python3 /chromium/src/build/vs_toolchain.py get_toolchain_dir
Returned 1.
stderr:
Traceback (most recent call last):
File "/chromium/src/build/vs_toolchain.py", line 587, in <module>
sys.exit(main())
File "/chromium/src/build/vs_toolchain.py", line 583, in main
return commands[sys.argv[1]](*sys.argv[2:])
File "/chromium/src/build/vs_toolchain.py", line 561, in GetToolchainDir
win_sdk_dir = SetEnvironmentAndGetSDKDir()
File "/chromium/src/build/vs_toolchain.py", line 554, in SetEnvironmentAndGetSDKDir
return NormalizePath(os.environ['WINDOWSSDKDIR'])
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 679, in __getitem__
raise KeyError(key) from None
KeyError: 'WINDOWSSDKDIR'
See //third_party/angle/gni/angle.gni:35:5: whence it was imported.
import("//build/config/win/visual_studio_version.gni")
^----------------------------------------------------
See //chrome/elevation_service/BUILD.gn:7:1: whence it was imported.
import("//build/toolchain/win/midl.gni")
^--------------------------------------
See //BUILD.gn:660:7: which caused the file to be included.
"//chrome/elevation_service:elevation_service_unittests",
^-------------------------------------------------------
FAILED: build.ninja
../../buildtools/mac/gn --root=../.. -q --ide=vs --regeneration gen .
ninja: error: rebuilding 'build.ninja': subcommand failed

Cannot install petsc4py on Ubuntu 20.04

After successfully installing and testing PETSc I went ahead and tried to install petsc4py with:
$ sudo python3 -m pip install petsc4py
but got loads of errors. Here are the messages:
Collecting petsc4py
Using cached petsc4py-3.16.1.tar.gz (2.3 MB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-yg5szcfl/petsc4py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-yg5szcfl/petsc4py/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info
cwd: /tmp/pip-install-yg5szcfl/petsc4py/
Complete output (54 lines):
running egg_info
creating /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info
writing /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info/dependency_links.txt
writing requirements to /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info/requires.txt
writing top-level names to /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info/top_level.txt
writing manifest file '/tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info/SOURCES.txt'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-yg5szcfl/petsc4py/setup.py", line 289, in <module>
main()
File "/tmp/pip-install-yg5szcfl/petsc4py/setup.py", line 286, in main
run_setup()
File "/tmp/pip-install-yg5szcfl/petsc4py/setup.py", line 135, in run_setup
setup(packages = ['petsc4py',
File "/usr/local/lib/python3.8/dist-packages/setuptools/__init__.py", line 155, in setup
return distutils.core.setup(**attrs)
File "/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/core.py", line 148, in setup
return run_commands(dist)
File "/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
dist.run_commands()
File "/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
self.run_command(cmd)
File "/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/dist.py", line 986, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.8/dist-packages/setuptools/command/egg_info.py", line 298, in run
self.find_sources()
File "/usr/local/lib/python3.8/dist-packages/setuptools/command/egg_info.py", line 305, in find_sources
mm.run()
File "/usr/local/lib/python3.8/dist-packages/setuptools/command/egg_info.py", line 540, in run
self.add_defaults()
File "/usr/local/lib/python3.8/dist-packages/setuptools/command/egg_info.py", line 577, in add_defaults
sdist.add_defaults(self)
File "/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/command/sdist.py", line 226, in add_defaults
self._add_defaults_python()
File "/usr/local/lib/python3.8/dist-packages/setuptools/command/sdist.py", line 111, in _add_defaults_python
build_py = self.get_finalized_command('build_py')
File "/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/cmd.py", line 299, in get_finalized_command
cmd_obj.ensure_finalized()
File "/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "/usr/local/lib/python3.8/dist-packages/setuptools/command/build_py.py", line 29, in finalize_options
orig.build_py.finalize_options(self)
File "/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/command/build_py.py", line 43, in finalize_options
self.set_undefined_options('build',
File "/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/cmd.py", line 287, in set_undefined_options
src_cmd_obj.ensure_finalized()
File "/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "/tmp/pip-install-yg5szcfl/petsc4py/conf/baseconf.py", line 411, in finalize_options
self.petsc_dir = config.get_petsc_dir(self.petsc_dir)
File "/tmp/pip-install-yg5szcfl/petsc4py/conf/baseconf.py", line 349, in get_petsc_dir
petsc_dir = petsc.get_petsc_dir()
AttributeError: module 'petsc' has no attribute 'get_petsc_dir'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
There are so many error messages that I have no idea where from I should start. Any help? The installation should be straightforward, I don't know what's going on. Trying to fix the package (or setup.py thereof) manually is futile. I'm using Python 3.8.10.
Any hints will be much appreciated.
The easiest solution I found to solve this issue in one of my Dockerfile is simply to use apt-get install -y python3-petsc4py-complex.
(If you want/have the petsc real version, use apt-get install -y python3-petsc4py-real instead).
From those who are interested, the same idea can be applied for slepc with apt-get install -y python3-slepc4py-complex.
Feel free to tell me if it works ! If not, I will try on a new Dockerfile to solve this.

CalledProcessError while installing Tensorflow using Bazel

I am trying to install Tensorflow from source using Bazel on Raspberry pi. I am following the official documentation as given here. When I run the ./configure in Tensorflow directory after completing all the steps written for Bazel, I get the following error
/home/cvit/bin/bazel: line 88: /home/cvit/.bazel/bin/bazel-real: cannot execute binary file: Exec format error
/home/cvit/bin/bazel: line 88: /home/cvit/.bazel/bin/bazel-real: Success
Traceback (most recent call last):
File "./configure.py", line 1552, in <module>
main()
File "./configure.py", line 1432, in main
check_bazel_version('0.15.0')
File "./configure.py", line 450, in check_bazel_version
curr_version = run_shell(['bazel', '--batch', '--bazelrc=/dev/null', 'version'])
File "./configure.py", line 141, in run_shell
output = subprocess.check_output(cmd)
File "/usr/lib/python2.7/subprocess.py", line 223, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['bazel', '--batch', '--bazelrc=/dev/null', 'version']' returned non-zero exit status 1
I didn't put the user flag in the bazel installation. So, I think this might be bazelrc error so I tried to set $PATH=$BAZEL/bin but nothing happened.
Please give any suggestion !!
Probably the problem is that the non appropriate version of bazel is installed.
Run bazel version in the tensorflow directory, and see if there is an error.
If there is a problem with bazel version, then check out the .baselversion file, and if it contains a version that isn't installable with apt, then dowload the installer from https://github.com/bazelbuild/bazel/releases then install it, else install with apt.
After that everything should work fine.

TensorFlow freeze_graph cannot find .runfiles

I have built TensorFlow from source using Bazel, however, when I try to run the freeze_graph script, I get the error requesting for the .runfiles
Here is my run command
python /home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph --input_graph=graph.pbtx --input_checkpoint=model.ckpt-0.data-00000-of-00001 --input_binary=false --output_graph=../frozen_graph/frozen_graph.pb --output_node_names=ArgMax
and here is the error it generates:
Traceback (most recent call last):
File "/home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph", line 172, in <module>
Main()
File "/home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph", line 111, in Main
module_space = FindModuleSpace()
File "/home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph", line 86, in FindModuleSpace
raise AssertionError('Cannot find .runfiles directory for %s' % sys.argv[0])
AssertionError: Cannot find .runfiles directory for /home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph
Any idea what I may be doing wrong?
If you used bazel to build freeze_graph, then bazel-bin contains your compiled freeze_graph code. This means you don't need to invoke freeze_graph with python, you can run it like this:
./home/olu/TensorFlow_Source/tensorflow/bazel-bin/tensorflow/python/tools/freeze_graph ...
You can run the python file directory by calling:
python /path/to/freeze_graph.py ...
Hope that helps!
in my case, I got the same error and I needed to build freeze_graph 1st:
bazel build tensorflow/python/tools:freeze_graph
After this you can run it this way:
bazel-bin/tensorflow/python/tools/freeze_graph \
--input_graph=/tmp/inception_v3_inf_graph.pb \
--input_checkpoint=/tmp/checkpoints/inception_v3.ckpt \
--input_binary=true --output_graph=/tmp/frozen_inception_v3.pb \
--output_node_names=InceptionV3/Predictions/Reshape_1
David

Unable to setup WebRTC native android code on ubuntu instance

Followed steps provided in this web page https://webrtc.org/native-code/android/
When I executed command "ninja -C out/Debug AppRTCMobile" I got following response
ninja: Entering directory `out/Debug'
ninja: fatal: chdir to 'out/Debug' - No such file or directory
I got stuck here and need help to continue in executing the next steps to complete the code setup.
Ubuntu version - 16.04.2
I have followed the same procedure once again to setup the code. This time I got a new error
Steps:
-> fetch --nohooks webrtc_android
-> gclient sync
-> gn gen out/Debug --args='target_os="android" target_cpu="arm"'
-> ninja -C out/Debug
ninja: Entering directory `out/Debug'
[1/8508] ACTION
//base:android_runtime_jni_headers__jni_Runtime(//build/toolchain/android:android_clang_arm)
FAILED: gen/android_runtime_jni_headers/base/jni/Runtime_jni.h python
../../base/android/jni_generator/jni_generator.py --depfile
gen/base/android_runtime_jni_headers__jni_Runtime.d --jar_file
../../third_party/android_tools/sdk/platforms/android-26/android.jar
--input_file java/lang/Runtime.class --ptr_type=long --output_dir gen/android_runtime_jni_headers/base/jni --includes
../../../../../../base/android/jni_generator/jni_generator_helper.h
--native_exports_optional
Traceback (most recent call last):
File "../../base/android/jni_generator/jni_generator.py", line 1428,
in
sys.exit(main(sys.argv))
File "../../base/android/jni_generator/jni_generator.py", line 1421,
in main
GenerateJNIHeader(input_file, output_file, options) File "../../base/android/jni_generator/jni_generator.py", line 1326, in
GenerateJNIHeader
jni_from_javap = JNIFromJavaP.CreateFromClass(input_file, options)
File "../../base/android/jni_generator/jni_generator.py", line 662,
in CreateFromClass
stderr=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in
_execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
[3/8508] CC obj/third_party/boringssl/boringssl/v3_ncons.o
ninja: build stopped: subcommand failed.
Someone please help me in resolving this issue.
You have to generate the projects using GN before trying to compile. You have the instructions here:
https://webrtc.org/native-code/android/