・2018/08/18
Raspberry Piで TensorFlow Deep Learning Frameworkを自己ビルドする方法
(ラズパイで TensorFlow Deep Learning Frameworkを自己ビルドする方法)
Tags: [Raspberry Pi], [電子工作], [ディープラーニング]
● Raspberry Piで TensorFlowのビルドに挑戦
Raspberry Piで TensorFlowのビルドに挑戦します。
ラズパイ3B+はビルド時に Raspbian OSがリセットして再起動してしまいました。(正常にビルドできない)
※ USB端子に USBカメラと USB切り換え器、+5V端子に冷却ファン(Nidec 0.05A)を接続していたのが原因かもしれないので全部取り外して再確認中。(CPU負荷による電源ふらつきが原因と予想)
ラズパイ3Bは大丈夫です。(多分、、、12時間経過で現在もビルド進行中 [5505/6289]、からのビルド FAILで失敗)
●今回動かした Raspberry Pi Raspbian OSのバージョン
RASPBIAN STRETCH WITH DESKTOP
Version:June 2018
Release date: 2018-06-27
Kernel version: 4.14
pi@raspberrypi:~/pytorch $ uname -a
Linux raspberrypi 4.14.50-v7+ #1122 SMP Tue Jun 19 12:26:26 BST 2018 armv7l GNU/Linux
● Raspberry Piで TensorFlow Deep Learning Frameworkを Gitソースリストからビルドする。
tensorflow/tensorflow
Computation using data flow graphs for scalable machine learning https://tensorflow.org
XLA Accelerated Linear Algebraで速くなる。
# お決まりの sudo apt-get updateで最新状態に更新する
sudo apt-get update
# Bazelビルド時の環境変数をクリアする
export EXTRA_BAZEL_ARGS=
export BAZEL_JAVAC_OPTS=
# TensorFlowのビルドに必要なパッケージをインストールする
#
cd
git clone https://github.com/tensorflow/tensorflow --depth 1 --recurse-submodules
# ディレクトリを移動する
cd tensorflow
# TensorFlowをビルドする時の環境変数を設定します
# Python3用にビルドする
# Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3
export PYTHON_BIN_PATH=/usr/bin/python3
# jemallocだけ 1(YES)
# Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]: Y
export TF_NEED_JEMALLOC=1
# Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: N
export TF_NEED_GCP=0
# Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: N
export TF_NEED_HDFS=0
# Do you wish to build TensorFlow with Amazon AWS Platform support? [Y/n]: N
export TF_NEED_AWS=0
# Do you wish to build TensorFlow with Apache Kafka Platform support? [Y/n]: N
export TF_NEED_KAFKA=0
# Do you wish to build TensorFlow with XLA JIT support? [y/N]: N
export TF_ENABLE_XLA=0
# Do you wish to build TensorFlow with GDR support? [y/N]: N
export TF_NEED_GDR=0
# Do you wish to build TensorFlow with VERBS support? [y/N]: N
export TF_NEED_VERBS=0
# Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: N
export TF_NEED_OPENCL_SYCL=0
export TF_NEED_OPENCL=0
# Do you wish to build TensorFlow with CUDA support? [y/N]: N
export TF_NEED_CUDA=0
# Do you wish to download a fresh release of clang? (Experimental) [y/N]: N
export TF_DOWNLOAD_CLANG=0
# Do you wish to build TensorFlow with MPI support? [y/N]: N
export TF_NEED_MPI=0
# Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:
export CC_OPT_FLAGS="-march=native"
# Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: N
export TF_SET_ANDROID_WORKSPACE=0
# configureする
./configure
「Please input the desired Python library path to use.」でリターンキーを押す。
2018/09/01追記、下記でリターンキーを押す。(Nと同じ扱い)
Do you wish to build TensorFlow with nGraph support? [y/N]:
No nGraph support will be enabled for TensorFlow.
pi@raspberrypi:~/tensorflow $ ./configure
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.16.1- (@non-git) installed.
Found possible Python library paths:
/usr/lib/python3/dist-packages
/usr/local/lib/python3.5/dist-packages
Please input the desired Python library path to use. Default is [/usr/lib/python3/dist-packages]
Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See tools/bazel.rc for more details.
--config=mkl # Build with MKL support.
--config=monolithic # Config for mostly static monolithic build.
Configuration finished
# TensorFlowをビルドする(timeコマンドでビルドの処理時間を計測する)
# --jobs 2で 2コアビルド
# --jobs 2で 2コアビルドでも SWAPが発生しまくりで超低速になりました
time \
bazel build \
--jobs 1 \
--local_resources 1024,1.0,1.0 \
--verbose_failures \
-c opt \
--copt="-march=armv7-a" \
--copt="-mfpu=neon-vfpv4" \
--copt="-mfloat-abi=hard" \
--copt="-funsafe-math-optimizations" \
--copt="-ftree-vectorize" \
--copt="-fomit-frame-pointer" \
--cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" \
tensorflow/tools/pip_package:build_pip_package
● --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
gcc 5.1以降の場合に必要。(gcc 5.1も含む)
ABIの動作を昔の仕様と同じにするオプション。
Runtime Library (libstdc++) ABI
A Dual ABI is provided by the library. A new ABI is enabled by default. The old ABI is still supported and can be used by defining the macro _GLIBCXX_USE_CXX11_ABI to 0 before including any C++ standard library headers.
ABI(Application Binary Interface)
COW = Copy On Write
SSO = Small-String Optimization
https://github.com/tensorflow/tensorflow/issues/6473
Errors_impl - NotFoundError - stringpiece #6473
https://github.com/tensorflow/tensorflow/pull/6997/files
Add note to new op and source build doc (#6473) #6997
https://github.com/MircoT/tensorflow/blob/master/tensorflow/docs_src/extend/adding_an_op.md
Adding a New Op
Note on gcc version 5: gcc5 uses the new C++ ABI. The binary pip packages available on the TensorFlow website are built with gcc4 that uses the older ABI. If you compile your op library with gcc5, add -D_GLIBCXX_USE_CXX11_ABI=0 to the command line to make the library compatible with the older abi. Furthermore if you are using TensorFlow package created from source remember to add -cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" as bazel command to compile the Python package.
https://github.com/MircoT/tensorflow/blob/master/tensorflow/docs_src/install/install_sources.md
Installing TensorFlow from Sources
NOTE on gcc version 5: the binary pip packages available on the TensorFlow website are built with gcc4 that uses the older ABI. To make the library compatible with the older abi you have to add -cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
● GCCの 4.8化は不要
TensorFlowをソースコードからコンパイルする手順に書いて有るが、実際には不要。
sudo apt-get install gcc-4.8 g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 100
● TensorFlowのビルドでエラー
TensorFlowのビルドでエラー no such package '@png_archive//'
解決方法不明、もう一度 bazel buildで TensorFlowのビルド操作を行なうと継続してビルドできた。
WARNING: /home/pi/tensorflow/tensorflow/core/BUILD:2548:1: in includes attribute of cc_library rule //tensorflow/core:framework_headers_lib: '../../external/com_google_absl' resolves to 'external/com_google_absl' 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/pi/tensorflow/tensorflow/tensorflow.bzl:1373:20
ERROR: /home/pi/tensorflow/tensorflow/tools/pip_package/BUILD:131:1: no such package '@png_archive//': Traceback (most recent call last):
File "/home/pi/tensorflow/third_party/repo.bzl", line 106
_apply_patch(ctx, ctx.attr.patch_file)
File "/home/pi/tensorflow/third_party/repo.bzl", line 73, in _apply_patch
_execute_and_check_ret_code(ctx, cmd)
File "/home/pi/tensorflow/third_party/repo.bzl", line 52, in _execute_and_check_ret_code
fail("Non-zero return code({1}) when ...))
Non-zero return code(256) when executing 'patch -p1 -d /home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/external/png_archive -i /home/pi/tensorflow/third_party/png_fix_rpi.patch':
Stdout:
Stderr: Timed out and referenced by '//tensorflow/tools/pip_package:licenses'
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: no such package '@png_archive//': Traceback (most recent call last):
File "/home/pi/tensorflow/third_party/repo.bzl", line 106
_apply_patch(ctx, ctx.attr.patch_file)
File "/home/pi/tensorflow/third_party/repo.bzl", line 73, in _apply_patch
_execute_and_check_ret_code(ctx, cmd)
File "/home/pi/tensorflow/third_party/repo.bzl", line 52, in _execute_and_check_ret_code
fail("Non-zero return code({1}) when ...))
Non-zero return code(256) when executing 'patch -p1 -d /home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/external/png_archive -i /home/pi/tensorflow/third_party/png_fix_rpi.patch':
Stdout:
Stderr: Timed out
INFO: Elapsed time: 178.823s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (171 packages loaded)
real 3m4.702s
user 0m0.107s
sys 0m0.074s
pi@raspberrypi:~/tensorflow $ time bazel build --jobs 2 --local_resources 1024,1.0,1.0 --verbose_failures -c opt --copt="-march=armv7-a" --copt="-mfpu=neon-vfpv4" --copt="-mfloat-abi=hard" --copt="-funsafe-math-optimizations" --copt="-ftree-vectorize" --copt="-fomit-frame-pointer" --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" tensorflow/tools/pip_package:build_pip_package
...
...
INFO: From Compiling tensorflow/python/pywrap_tensorflow_internal.cc [for host]:
bazel-out/host/bin/tensorflow/python/pywrap_tensorflow_internal.cc: In function 'PyObject* TF_GetColocationGroups(GItem)':
bazel-out/host/bin/tensorflow/python/pywrap_tensorflow_internal.cc:4654:9: warning: unused variable 'i' [-Wunused-variable]
int i = 0;
^
bazel-out/host/bin/tensorflow/python/pywrap_tensorflow_internal.cc: In function 'PyObject* _wrap_PyRecordReader_New(PyObject*, PyObject*)':
bazel-out/host/bin/tensorflow/python/pywrap_tensorflow_internal.cc:7424:138: warning: 'arg2' may be used uninitialized in this function [-Wmaybe-uninitialized]
result = (tensorflow::io::PyRecordReader *)tensorflow::io::PyRecordReader::New((string const &)*arg1,arg2,(string const &)*arg3,arg4);
^
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-self-assign'
Slow read: a 58725824-byte read from /home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/_pywrap_tensorflow_internal.so took 10015ms.
ERROR: /home/pi/tensorflow/tensorflow/BUILD:576:1: Executing genrule //tensorflow:tensorflow_python_api_gen failed (Exit 1): bash failed: error executing command
(cd /home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow && \
exec env - \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games \
/bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/tensorflow/create_tensorflow.python_api --root_init_template=tensorflow/api_template.__init__.py --apidir=bazel-out/host/genfiles/tensorflow --apiname=tensorflow --apiversion=1 --package=tensorflow.python --output_package=tensorflow bazel-out/host/genfiles/tensorflow/__init__.py bazel-out/host/genfiles/tensorflow/app/__init__.py bazel-out/host/genfiles/tensorflow/bitwise/__init__.py bazel-out/host/genfiles/tensorflow/compat/__init__.py bazel-out/host/genfiles/tensorflow/data/__init__.py bazel-out/host/genfiles/tensorflow/debugging/__init__.py bazel-out/host/genfiles/tensorflow/distributions/__init__.py bazel-out/host/genfiles/tensorflow/dtypes/__init__.py bazel-out/host/genfiles/tensorflow/errors/__init__.py bazel-out/host/genfiles/tensorflow/feature_column/__init__.py bazel-out/host/genfiles/tensorflow/gfile/__init__.py bazel-out/host/genfiles/tensorflow/graph_util/__init__.py bazel-out/host/genfiles/tensorflow/image/__init__.py bazel-out/host/genfiles/tensorflow/io/__init__.py bazel-out/host/genfiles/tensorflow/initializers/__init__.py bazel-out/host/genfiles/tensorflow/keras/__init__.py bazel-out/host/genfiles/tensorflow/keras/activations/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/densenet/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/inception_resnet_v2/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/inception_v3/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/mobilenet/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/nasnet/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/resnet50/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/vgg16/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/vgg19/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/xception/__init__.py bazel-out/host/genfiles/tensorflow/keras/backend/__init__.py bazel-out/host/genfiles/tensorflow/keras/callbacks/__init__.py bazel-out/host/genfiles/tensorflow/keras/constraints/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/boston_housing/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/cifar10/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/cifar100/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/fashion_mnist/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/imdb/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/mnist/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/reuters/__init__.py bazel-out/host/genfiles/tensorflow/keras/estimator/__init__.py bazel-out/host/genfiles/tensorflow/keras/initializers/__init__.py bazel-out/host/genfiles/tensorflow/keras/layers/__init__.py bazel-out/host/genfiles/tensorflow/keras/losses/__init__.py bazel-out/host/genfiles/tensorflow/keras/metrics/__init__.py bazel-out/host/genfiles/tensorflow/keras/models/__init__.py bazel-out/host/genfiles/tensorflow/keras/optimizers/__init__.py bazel-out/host/genfiles/tensorflow/keras/preprocessing/__init__.py bazel-out/host/genfiles/tensorflow/keras/preprocessing/image/__init__.py bazel-out/host/genfiles/tensorflow/keras/preprocessing/sequence/__init__.py bazel-out/host/genfiles/tensorflow/keras/preprocessing/text/__init__.py bazel-out/host/genfiles/tensorflow/keras/regularizers/__init__.py bazel-out/host/genfiles/tensorflow/keras/utils/__init__.py bazel-out/host/genfiles/tensorflow/keras/wrappers/__init__.py bazel-out/host/genfiles/tensorflow/keras/wrappers/scikit_learn/__init__.py bazel-out/host/genfiles/tensorflow/layers/__init__.py bazel-out/host/genfiles/tensorflow/linalg/__init__.py bazel-out/host/genfiles/tensorflow/logging/__init__.py bazel-out/host/genfiles/tensorflow/losses/__init__.py bazel-out/host/genfiles/tensorflow/manip/__init__.py bazel-out/host/genfiles/tensorflow/math/__init__.py bazel-out/host/genfiles/tensorflow/metrics/__init__.py bazel-out/host/genfiles/tensorflow/nn/__init__.py bazel-out/host/genfiles/tensorflow/nn/rnn_cell/__init__.py bazel-out/host/genfiles/tensorflow/profiler/__init__.py bazel-out/host/genfiles/tensorflow/python_io/__init__.py bazel-out/host/genfiles/tensorflow/quantization/__init__.py bazel-out/host/genfiles/tensorflow/resource_loader/__init__.py bazel-out/host/genfiles/tensorflow/strings/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/builder/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/constants/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/loader/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/main_op/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/signature_constants/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/signature_def_utils/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/tag_constants/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/utils/__init__.py bazel-out/host/genfiles/tensorflow/sets/__init__.py bazel-out/host/genfiles/tensorflow/sparse/__init__.py bazel-out/host/genfiles/tensorflow/spectral/__init__.py bazel-out/host/genfiles/tensorflow/summary/__init__.py bazel-out/host/genfiles/tensorflow/sysconfig/__init__.py bazel-out/host/genfiles/tensorflow/test/__init__.py bazel-out/host/genfiles/tensorflow/train/__init__.py bazel-out/host/genfiles/tensorflow/train/queue_runner/__init__.py bazel-out/host/genfiles/tensorflow/user_ops/__init__.py')
Traceback (most recent call last):
File "/home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _ZN10tensorflow9ConcatCPUINS_8bfloat16EEEvPNS_10DeviceBaseERKSt6vectorISt10unique_ptrINS_6TTypesIT_Li2EiE11ConstMatrixESt14default_deleteIS9_EESaISC_EEPNS8_6MatrixE
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/tools/api/generator/create_python_api.py", line 27, in <module>
from tensorflow.python.tools.api.generator import doc_srcs
File "/home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/pi/.cache/bazel/_bazel_pi/c9b23b7b8edb3dba430c02139630698d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _ZN10tensorflow9ConcatCPUINS_8bfloat16EEEvPNS_10DeviceBaseERKSt6vectorISt10unique_ptrINS_6TTypesIT_Li2EiE11ConstMatrixESt14default_deleteIS9_EESaISC_EEPNS8_6MatrixE
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 50393.244s, Critical Path: 4604.43s
INFO: 5625 processes: 5625 local.
FAILED: Build did NOT complete successfully
real 839m59.543s
user 0m13.563s
sys 0m10.932s
解決方法不明
tensorflowのソースディレクトリで import tensorflowすると怒られる。
pi@raspberrypi:~/tensorflow $ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170124] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "/home/pi/tensorflow/tensorflow/python/platform/self_check.py", line 25, in <module>
from tensorflow.python.platform import build_info
ImportError: cannot import name 'build_info'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/tensorflow/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/pi/tensorflow/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/pi/tensorflow/tensorflow/python/pywrap_tensorflow.py", line 25, in <module>
from tensorflow.python.platform import self_check
File "/home/pi/tensorflow/tensorflow/python/platform/self_check.py", line 27, in <module>
raise ImportError("Could not import tensorflow. Do not import tensorflow "
ImportError: Could not import tensorflow. Do not import tensorflow from its source directory; change directory to outside the TensorFlow source tree, and relaunch your Python interpreter from there.
>>> quit()
pi@raspberrypi:~/tensorflow $ cd
pi@raspberrypi:~ $ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170124] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> print (tensorflow.__version__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute '__version__'
>>> print (tensorflow)
<module 'tensorflow' (namespace)>
>>> quit()
bazel build時に no such package '@swig//'
ERROR: /home/pi/tensorflow/tensorflow/python/BUILD:3735:1: every rule of type _py_wrap_cc implicitly depends upon the target '@swig//:swig', but this target could not be found because of: no such package '@swig//': java.io.IOException: Downloaded file at /home/pi/.cache/bazel/_bazel_pi/cache/repos/v1/content_addressable/sha256/58a475dbbd4a4d7075e5fe86d4e54c9edde39847cdb96a3053d87cb64a23a453/file has SHA-256 of e2e47954cc9d014e5ddb9f8f63f45d62909e5c5469f11a15dcc2f597be835697, does not match expected SHA-256 (58a475dbbd4a4d7075e5fe86d4e54c9edde39847cdb96a3053d87cb64a23a453)
sudo apt-get -y install swig
bazel build時に no such package '@astor_archive//'
ERROR: /home/pi/tensorflow/tensorflow/contrib/autograph/pyct/BUILD:19:1: no such package '@astor_archive//': java.io.IOException: Downloaded file at /home/pi/.cache/bazel/_bazel_pi/cache/repos/v1/content_addressable/sha256/ff6d2e2962d834acb125cc4dcc80c54a8c17c253f4cc9d9c43b5102a560bb75d/file has SHA-256 of e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855, does not match expected SHA-256 (ff6d2e2962d834acb125cc4dcc80c54a8c17c253f4cc9d9c43b5102a560bb75d)
解決方法不明
sudo apt-get -y install python3-pip python3-numpy python3-dev
sudo apt-get -y install python3-wheel
sudo apt-get -y install libtool autoconf automake
# Setting up libtool (2.4.6-2) ...
# Setting up autoconf (2.69-10) ...
# Setting up automake (1:1.15-6) ...
sudo apt-get -y install swig
# Setting up swig (3.0.10-1.1) ...
# TensorFlowのコンフィグ
# ./configure
# TensorFlowをビルドする(timeコマンドでビルドの処理時間を計測する)
# --jobs 3で 3コアビルドだと SWAPが発生しまくりで超低速になりました
time \
bazel build \
--jobs 3 \
--local_resources 1024,2.0,1.0 \
--verbose_failures \
-c opt \
--copt="-march=armv7-a" \
--copt="-mfpu=neon-vfpv4" \
--copt="-mfloat-abi=hard" \
--copt="-funsafe-math-optimizations" \
--copt="-ftree-vectorize" \
--copt="-fomit-frame-pointer" \
--cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" \
tensorflow/tools/pip_package:build_pip_package
# ビルド時の指定はラズパイの場合は下記がオススメ
--jobs 2 \
--local_resources 1024,1.0,1.0 \
# --jobs 2で 2コアビルドでも SWAPが発生しまくりで超低速になりました
下記のビルドの所でスタック、実質的に停止状態となった。
# [3,512 / 6,350] 2 actions running
# Compiling tensorflow/core/kernels/svd_op_complex64.cc; 54325s local
# Compiling tensorflow/core/kernels/svd_op_complex128.cc; 53098s local
Tags: [Raspberry Pi], [電子工作], [ディープラーニング]
●関連するコンテンツ(この記事を読んだ人は、次の記事も読んでいます)
NVIDIA Jetson Nano 開発者キットを買ってみた。メモリ容量 4GB LPDDR4 RAM
Jetson Nanoで TensorFlow PyTorch Caffe/Caffe2 Keras MXNet等を GPUパワーで超高速で動かす!
Raspberry Piでメモリを馬鹿食いするアプリ用に不要なサービスを停止してフリーメモリを増やす方法
ラズパイでメモリを沢山使用するビルドやアプリ用に不要なサービス等を停止して使えるメインメモリを増やす
【成功版】最新版の Darknetに digitalbrain79版の Darknet with NNPACKの NNPACK処理を適用する
ラズパイで NNPACK対応の最新版の Darknetを動かして超高速で物体検出や DeepDreamの悪夢を見る
【成功版】Raspberry Piで NNPACK対応版の Darknet Neural Network Frameworkをビルドする方法
ラズパイに Darknet NNPACK darknet-nnpackをソースからビルドして物体検出を行なう方法
【成功版】Raspberry Piで Darknet Neural Network Frameworkをビルドする方法
ラズパイに Darknet Neural Network Frameworkを入れて物体検出や悪夢のグロ画像を生成する
【成功版】Raspberry Piに TensorFlow Deep Learning Frameworkをインストールする方法
ラズパイに TensorFlow Deep Learning Frameworkを入れて Google DeepDreamで悪夢を見る方法
Raspberry Piで Caffe Deep Learning Frameworkで物体認識を行なってみるテスト
ラズパイで Caffe Deep Learning Frameworkを動かして物体認識を行なってみる
【ビルド版】Raspberry Piで DeepDreamを動かしてキモイ絵をモリモリ量産 Caffe Deep Learning Framework
ラズパイで Caffe Deep Learning Frameworkをビルドして Deep Dreamを動かしてキモイ絵を生成する
【インストール版】Raspberry Piで DeepDreamを動かしてキモイ絵をモリモリ量産 Caffe Deep Learning
ラズパイで Caffe Deep Learning Frameworkをインストールして Deep Dreamを動かしてキモイ絵を生成する
Raspberry Piで Caffe2 Deep Learning Frameworkをソースコードからビルドする方法
ラズパイで Caffe 2 Deep Learning Frameworkをソースコードから自己ビルドする方法
Orange Pi PC 2の 64bitのチカラで DeepDreamしてキモイ絵を高速でモリモリ量産してみるテスト
OrangePi PC2に Caffe Deep Learning Frameworkをビルドして Deep Dreamを動かしてキモイ絵を生成する
Raspberry Piに Jupyter Notebookをインストールして拡張子 ipynb形式の IPythonを動かす
ラズパイに IPython Notebookをインストールして Google DeepDream dream.ipynbを動かす
Raspberry Piで Deep Learningフレームワーク Chainerをインストールしてみる
ラズパイに Deep Learningのフレームワーク Chainerを入れてみた
Raspberry Piで DeepBeliefSDKをビルドして画像認識フレームワークを動かす方法
ラズパイに DeepBeliefSDKを入れて画像の物体認識を行なう
Raspberry Piで Microsoftの ELLをビルドする方法
ラズパイで Microsoftの ELL Embedded Learning Libraryをビルドしてみるテスト、ビルドするだけ
Raspberry Piで MXNet port of SSD Single Shot MultiBoxを動かして画像の物体検出をする方法
ラズパイで MXNet port of SSD Single Shot MultiBox Object Detectorで物体検出を行なってみる
Raspberry Piで Apache MXNet Incubatingをビルドする方法
ラズパイで Apache MXNet Incubatingをビルドしてみるテスト、ビルドするだけ
Raspberry Piで OpenCVの Haar Cascade Object Detectionでリアルタイムにカメラ映像の顔検出を行なってみる
ラズパイで OpenCVの Haar Cascade Object Detection Face & Eyeでリアルタイムでカメラ映像の顔検出をする方法
Raspberry Piで NNPACKをビルドする方法
ラズパイで NNPACKをビルドしてみるテスト、ビルドするだけ
Raspberry Pi 3の Linuxコンソール上で使用する各種コマンドまとめ
ラズパイの Raspbian OSのコマンドラインで使用する便利コマンド、負荷試験や CPUシリアル番号の確認方法等も
[HOME]
|
[BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c)
2018 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator
http://www.neko.ne.jp/~freewing/raspberry_pi/raspberry_pi_build_tensorflow_deep_learning_framework/