Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tensorflow/core/kernels/split_op.cc:159:26: error: non-constant-expression cannot be narrowed from type 'int64' (aka 'long long') to 'int' in initializer list [-Wc++11-narrowing] #8894

Closed
lucasjinreal opened this issue Apr 1, 2017 · 2 comments
Labels
stat:awaiting response Status - Awaiting response from author type:build/install Build and install issues

Comments

@lucasjinreal
Copy link

Building tensorflow android error:

  • os: ubuntu16.04
  • tensorflow: 1.0.1

Before error comes, I followed the tips in android README

 bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so \
   --crosstool_top=//external:android/crosstool \
   --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
   --cpu=armeabi-v7a

then I just got these error:

ERROR: /media/work/CodeSpace/AISpace/tensorflow/tensorflow/core/kernels/BUILD:3944:1: C++ compilation of rule '//tensorflow/core/kernels:android_tensorflow_kernels' failed: clang failed: error executing command external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -gcc-toolchain external/androidndk/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -fpic -ffunction-sections ... (remaining 73 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
In file included from tensorflow/core/kernels/resize_nearest_neighbor_op.cc:20:
In file included from ./third_party/eigen3/unsupported/Eigen/CXX11/Tensor:4:
In file included from external/eigen_archive/unsupported/Eigen/CXX11/Tensor:152:
external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorMap.h:242:106: error: non-constant-expression cannot be narrowed from type 'long long' to 'int' in initializer list [-Wc++11-narrowing]
        const Index index = m_dimensions.IndexOfRowMajor(array<Index, NumDims>{{firstIndex, secondIndex, otherIndices...}});
                                                                                                         ^~~~~~~~~~~~
tensorflow/core/kernels/resize_nearest_neighbor_op.cc:69:24: note: in instantiation of function template specialization 'Eigen::TensorMap<Eigen::Tensor<const int, 4, 1, int>, 16, MakePointer>::operator()<long long, int>' requested here
          std::copy_n(&input_data(b, in_y, in_x, 0), st.channels,

I installed android sdk and ndk via android-studio, and here is my settings in WORKSPACE:

android_sdk_repository(
    name = "androidsdk",
    api_level = 23,
    # Ensure that you have the build_tools_version below installed in the
    # SDK manager as it updates periodically.
    build_tools_version = "25.0.2",
    # Replace with path to Android SDK on your system
    path = "/media/work/android/android-sdk",
)
#
# Android NDK r12b is recommended (higher may cause issues with Bazel)
android_ndk_repository(
    name="androidndk",
    path="/media/work/android/android-sdk/ndk-bundle",
    # This needs to be 14 or higher to compile TensorFlow. 
    # Note that the NDK version is not the API level.
    api_level=14)

Anybody occurred this problem too? I don't know what happed.

@andrewharp
Copy link
Contributor

Make sure you're building with NDK r12b, as other versions are known to cause issues with Bazel.

@aselle aselle added stat:awaiting response Status - Awaiting response from author type:build/install Build and install issues labels Apr 1, 2017
@aj-michael
Copy link
Contributor

Try building with bazel build --copt=-Wno-c++11-narrowing to disable this error. NDK13 switched from GCC to Clang, which has this check enabled by default.

meteorcloudy added a commit to bazelbuild/continuous-integration that referenced this issue Nov 15, 2018
Fix TF build error
```
external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h:340:167: error: non-constant-expression cannot be narrowed from type 'long long' to 'int' in initializer list [-Wc++11-narrowing]
```
Solution suggested at tensorflow/tensorflow#8894 (comment)
joeleba pushed a commit to joeleba/continuous-integration that referenced this issue Jun 17, 2019
Fix TF build error
```
external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h:340:167: error: non-constant-expression cannot be narrowed from type 'long long' to 'int' in initializer list [-Wc++11-narrowing]
```
Solution suggested at tensorflow/tensorflow#8894 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting response Status - Awaiting response from author type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

5 participants