Problems with building Tensorflow with SYCL

Hello!

I have been trying to build Tensorflow with SYCL support. I followed this guide.

I used ComputeCPP v1.14.0 for Ubuntu 16.04. Everything else was done in the same way as in the guide.

The compilation first goes OK, and then at some point I am getting an error like this one:

/home/b2/tensorflow/tensorflow/core/BUILD:2388:1: C++ compilation of rule ‘//tensorflow/core:framework_internal_impl’ failed (Exit 1): gcc failed: error executing command
(cd /home/b2/.cache/bazel/bazel_b2/1290b07231ac2b86225e2ae44227d4a6/execroot/org_tensorflow &&
exec env -
PATH=/home/b2/.pyenv/plugins/pyenv-virtualenv/shims:/home/b2/.pyenv/shims:/home/b2/.pyenv/bin:/home/b2/.local/bin:/home/b2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin/x86_64:/home/b2/RCP-master/Output/bin:/home/b2/Android/Sdk/platform-tools:/opt/flutter/bin
PWD=/proc/self/cwd
/usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 ‘-D_FORTIFY_SOURCE=1’ -DNDEBUG -ffunction-sections -fdata-sections ‘-std=c++0x’ -MD -MF bazel-out/host/bin/tensorflow/core/objs/framework_internal_impl/bfloat16.pic.d '-frandom-seed=bazel-out/host/bin/tensorflow/core/objs/framework_internal_impl/bfloat16.pic.o’ -fPIC -D__CLANG_SUPPORT_DYN_ANNOTATION -DEIGEN_MPL2_ONLY ‘-DEIGEN_MAX_ALIGN_BYTES=64’ -DTENSORFLOW_USE_JEMALLOC -DTENSORFLOW_USE_ABSL -DTF_USE_SNAPPY -iquote . -iquote bazel-out/host/genfiles -iquote bazel-out/host/bin -iquote external/com_google_absl -iquote bazel-out/host/genfiles/external/com_google_absl -iquote bazel-out/host/bin/external/com_google_absl -iquote external/bazel_tools -iquote bazel-out/host/genfiles/external/bazel_tools -iquote bazel-out/host/bin/external/bazel_tools -iquote external/nsync -iquote bazel-out/host/genfiles/external/nsync -iquote bazel-out/host/bin/external/nsync -iquote external/jemalloc -iquote bazel-out/host/genfiles/external/jemalloc -iquote bazel-out/host/bin/external/jemalloc -iquote external/eigen_archive -iquote bazel-out/host/genfiles/external/eigen_archive -iquote bazel-out/host/bin/external/eigen_archive -iquote external/local_config_sycl -iquote bazel-out/host/genfiles/external/local_config_sycl -iquote bazel-out/host/bin/external/local_config_sycl -iquote external/opencl_headers -iquote bazel-out/host/genfiles/external/opencl_headers -iquote bazel-out/host/bin/external/opencl_headers -iquote external/gif_archive -iquote bazel-out/host/genfiles/external/gif_archive -iquote bazel-out/host/bin/external/gif_archive -iquote external/jpeg -iquote bazel-out/host/genfiles/external/jpeg -iquote bazel-out/host/bin/external/jpeg -iquote external/protobuf_archive -iquote bazel-out/host/genfiles/external/protobuf_archive -iquote bazel-out/host/bin/external/protobuf_archive -iquote external/com_googlesource_code_re2 -iquote bazel-out/host/genfiles/external/com_googlesource_code_re2 -iquote bazel-out/host/bin/external/com_googlesource_code_re2 -iquote external/farmhash_archive -iquote bazel-out/host/genfiles/external/farmhash_archive -iquote bazel-out/host/bin/external/farmhash_archive -iquote external/fft2d -iquote bazel-out/host/genfiles/external/fft2d -iquote bazel-out/host/bin/external/fft2d -iquote external/highwayhash -iquote bazel-out/host/genfiles/external/highwayhash -iquote bazel-out/host/bin/external/highwayhash -iquote external/png_archive -iquote bazel-out/host/genfiles/external/png_archive -iquote bazel-out/host/bin/external/png_archive -iquote external/zlib_archive -iquote bazel-out/host/genfiles/external/zlib_archive -iquote bazel-out/host/bin/external/zlib_archive -Ibazel-out/host/bin/external/opencl_headers/virtual_includes/OpenCL-Headers -isystem external/nsync/public -isystem bazel-out/host/genfiles/external/nsync/public -isystem bazel-out/host/bin/external/nsync/public -isystem external/jemalloc/include -isystem bazel-out/host/genfiles/external/jemalloc/include -isystem bazel-out/host/bin/external/jemalloc/include -isystem external/eigen_archive -isystem bazel-out/host/genfiles/external/eigen_archive -isystem bazel-out/host/bin/external/eigen_archive -isystem external/local_config_sycl/sycl -isystem bazel-out/host/genfiles/external/local_config_sycl/sycl -isystem bazel-out/host/bin/external/local_config_sycl/sycl -isystem external/local_config_sycl/sycl/include -isystem bazel-out/host/genfiles/external/local_config_sycl/sycl/include -isystem bazel-out/host/bin/external/local_config_sycl/sycl/include -isystem external/gif_archive/lib -isystem bazel-out/host/genfiles/external/gif_archive/lib -isystem bazel-out/host/bin/external/gif_archive/lib -isystem external/protobuf_archive/src -isystem bazel-out/host/genfiles/external/protobuf_archive/src -isystem bazel-out/host/bin/external/protobuf_archive/src -isystem external/farmhash_archive/src -isystem bazel-out/host/genfiles/external/farmhash_archive/src -isystem bazel-out/host/bin/external/farmhash_archive/src -isystem external/png_archive -isystem bazel-out/host/genfiles/external/png_archive -isystem bazel-out/host/bin/external/png_archive -isystem external/zlib_archive -isystem bazel-out/host/genfiles/external/zlib_archive -isystem bazel-out/host/bin/external/zlib_archive -g0 ‘-march=native’ -g0 -DEIGEN_AVOID_STL_ARRAY -Iexternal/gemmlowp -Wno-sign-compare ‘-ftemplate-depth=900’ -msse3 -pthread -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE
=“redacted”’ ‘-D__TIMESTAMP__=“redacted”’ ‘-D__TIME__=“redacted”’ -c tensorflow/core/framework/bfloat16.cc -o bazel-out/host/bin/tensorflow/core/_objs/framework_internal_impl/bfloat16.pic.o)
In file included from ./third_party/eigen3/unsupported/Eigen/CXX11/FixedPoint:42:0,
from ./tensorflow/core/framework/numeric_types.h:24,
from ./tensorflow/core/framework/bfloat16.h:19,
from tensorflow/core/framework/bfloat16.cc:16:
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatMatProductAVX2.h:52:397: error: type/value mismatch at argument 4 in template parameter list for ‘template<class ResScalar, class LhsScalar, class RhsScalar, class StorageIndex, int ShardingType> class Eigen::internal::TensorContractionBlocking’
class TensorContractionBlocking<TensorContractionInputMapper<QInt8, Index, Lhs, LeftTensor, left_nocontract_t, left_contract_t, 32, left_inner_dim_contiguous, left_inner_dim_reordered, LeftAlignment>, TensorContractionInputMapper<QUInt8, Index, Rhs, RightTensor, right_nocontract_t, right_contract_t, 32, right_inner_dim_contiguous, right_inner_dim_reordered, RightAlignment>, Index, ShardingType> {
^
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatMatProductAVX2.h:52:397: note: expected a type, got ‘ShardingType’
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatMatProductAVX2.h:1273:42: error: type/value mismatch at argument 6 in template parameter list for ‘template<class Scalar, class Index, class DataMapper, int Pack1, int Pack2, class Packet, int StorageOrder, bool Conjugate, bool PanelMode> struct Eigen::internal::gemm_pack_lhs’
Conjugate, PanelMode> {
^
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatMatProductAVX2.h:1273:42: note: expected a type, got ‘ColMajor’
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatMatProductAVX2.h:1282:68: error: type/value mismatch at argument 6 in template parameter list for ‘template<class Scalar, class Index, class DataMapper, int Pack1, int Pack2, class Packet, int StorageOrder, bool Conjugate, bool PanelMode> struct Eigen::internal::gemm_pack_lhs’
ColMajor, Conjugate, PanelMode>::
^
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatMatProductAVX2.h:1282:68: note: expected a type, got ‘ColMajor’
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatMatProductAVX2.h:1284:38: error: ‘void Eigen::internal::operator()(Eigen::QInt8*, const DataMapper&, Index, Index, Index, Index)’ must be a nonstatic member function
Index stride, Index offset) {
^
Target //tensorflow/tools/pip_package:build_pip_package failed to build

What am I doing wrong?

Hope someone helps!

Thanks,
Viacheslav

It looks like the issue you are seeing is due to the -march=native flag being added and this is typically added by --config=opt. Are you using this flag? If so if you remove this flag things should work. Otherwise perhaps you are adding the flag another way?

Just as an FYI this is an issue in the Eigen operations we use, we are aware of it and are working on a fix so that this flag can be used in the future.