3

私はbazelとtensorflowにまったく慣れていないので、これに対する解決策は経験のある人には明らかかもしれません. tensorflow の bazel ビルドが失敗し、「依存関係がありません」というエラー メッセージが表示されます。関連する一連のビルド コマンドと出力を次に示します。

(tf-gpu)kss@linux-9c32:~/projects> git clone --recurse-submodules https://github.com/tensorflow/tensorflow tensorflow-nogpu
Cloning into 'tensorflow-nogpu'...
remote: Counting objects: 16735, done.
remote: Compressing objects: 100% (152/152), done.
remote: Total 16735 (delta 73), reused 0 (delta 0), pack-reused 16583
Receiving objects: 100% (16735/16735), 25.25 MiB | 911.00 KiB/s, done.
Resolving deltas: 100% (10889/10889), done.
Checking connectivity... done.
Submodule 'google/protobuf' (https://github.com/google/protobuf.git) registered for path 'google/protobuf'
Cloning into 'google/protobuf'...
remote: Counting objects: 30266, done.
remote: Compressing objects: 100% (113/113), done.
remote: Total 30266 (delta 57), reused 0 (delta 0), pack-reused 30151
Receiving objects: 100% (30266/30266), 28.90 MiB | 1.98 MiB/s, done.
Resolving deltas: 100% (20225/20225), done.
Checking connectivity... done.
Submodule path 'google/protobuf': checked out '0906f5d18a2548024b511eadcbb4cfc0ca56cd67'
(tf-gpu)kss@linux-9c32:~/projects> cd tensorflow-nogpu/
(tf-gpu)kss@linux-9c32:~/projects/tensorflow-nogpu> ./configure 
Please specify the location of python. [Default is /home/kss/.venv/tf-gpu/bin/python]: 
Do you wish to build TensorFlow with GPU support? [y/N] 
No GPU support will be enabled for TensorFlow
Configuration finished
(tf-gpu)kss@linux-9c32:~/projects/tensorflow-nogpu> bazel build -c opt //tensorflow/tools/pip_package:build_pip_package                                                        
Sending SIGTERM to previous Bazel server (pid=8491)... done.
....
INFO: Found 1 target...
ERROR: /home/kss/.cache/bazel/_bazel_kss/b97e0e942a10977a6b42467ea6712cbf/external/re2/BUILD:9:1: undeclared inclusion(s) in rule '@re2//:re2':
this rule is missing dependency declarations for the following files included by 'external/re2/re2/perl_groups.cc':
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/stddef.h'
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/stdarg.h'
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/stdint.h'
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/x86intrin.h'
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/ia32intrin.h'
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/mmintrin.h'
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/xmmintrin.h'
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/mm_malloc.h'
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/emmintrin.h'
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/immintrin.h'
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/fxsrintrin.h'
  '/usr/lib64/gcc/x86_64-suse-linux/4.8/include/adxintrin.h'.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 144.661s, Critical Path: 1.18s
(tf-gpu)kss@linux-9c32:~/projects/tensorflow-nogpu> 

使用している bazel のバージョンは です。openSUSE release 0.1.413.2 で実行しています。おそらく予想されるヘッダーファイルが存在することを確認しました:

(tf-gpu)kss@linux-9c32:~/projects/tensorflow-nogpu> ll /usr/lib64/gcc/x86_64-suse-linux/4.8/include/stddef.h
-rw-r--r-- 1 root root 13619 Oct  6  2014 /usr/lib64/gcc/x86_64-suse-linux/4.8/include/stddef.h

この質問を見つけた人への注意

--crosstool_topではなく使用する必要があることを除いて、以下のダミアンの回答を使用してください--crosstool。また、GPU アクセラレーション用にビルドしている場合はCROSSTOOL、tensorflow リポジトリのファイルを次のように変更する必要もあります。

(tf-gpu)kss@linux-9c32:~/projects/tensorflow-gpu> git diff third_party/gpus/crosstool/CROSSTOOL | cat
diff --git a/third_party/gpus/crosstool/CROSSTOOL b/third_party/gpus/crosstool/CROSSTOOL
index dfde7cd..b63f950 100644
--- a/third_party/gpus/crosstool/CROSSTOOL
+++ b/third_party/gpus/crosstool/CROSSTOOL
@@ -56,6 +56,7 @@ toolchain {
   cxx_builtin_include_directory: "/usr/lib/gcc/"
   cxx_builtin_include_directory: "/usr/local/include"
   cxx_builtin_include_directory: "/usr/include"
+  cxx_builtin_include_directory: "/usr/lib64/gcc"
   tool_path { name: "gcov" path: "/usr/bin/gcov" }

   # C(++) compiles invoke the compiler (as that is the one knowing where
4

2 に答える 2

4

C++ コンパイラを微調整する必要があります。

そのための最善の方法は次のとおりです。パッケージ パス ディレクトリからファイルtools/cpp/CROSSTOOL( https://github.com/bazelbuild/bazel/blob/master/tools/cpp/CROSSTOOL~/.bazel/base_workspace ) を編集します ( にある必要があります。 ) を使用して、 100 行目の周りに行bazel info package_pathを追加します ( https://github.com/bazelbuild/bazel/blob/master/tools/cpp/CROSSTOOL#L101を参照)。cxx_builtin_include_directory: /usr/lib64/gcc

その後echo "build --crosstool=//tools/cpp:toolchain" >>~/.bazelrc、ビルドを再試行します。

ごちゃごちゃして申し訳ありませんが、C++ ツールチェーンがすぐに使えるように取り組んでいます。

于 2016-02-08T16:42:00.600 に答える
0

コンパイラが依存関係を生成するときに (-MMD ではなく) -MD フラグを使用するため、システム ヘッダー ファイルの Bazel の苦情。-MD の使用は、頻繁に変更される環境では合理的ですが、システム ヘッダー ファイルへの依存関係をリストすると、「依存関係宣言がありません」というエラーが発生します。

私を助けたのは、「subprocess.call([CPU_COMPILER]...)」の直前のコンパイララッパーファイル third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc.tpl で「-MD」フラグを「-MMD」フラグに変換することでした。 :

cpu_compiler_flags = ['-MMD' if flag == '-MD' else flag for flag in cpu_compiler_flags]

および third_party/sycl/crosstool/computecpp.tpl の同様の場所:

computecpp_device_compiler_flags = ['-MMD' if flag == '-MD' else flag for flag in computecpp_device_compiler_flags]
于 2017-03-10T08:13:30.373 に答える