tensorflow: nvcc error: string_view.h: constexpr function return is non-constant
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): This is what the bug is about, see below.
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 16.04
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: no
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): v1.11.0-0-gc19e29306c 1.11.0
- Python version: 3.6.3
- Bazel version (if compiling from source): none
- GCC/Compiler version (if compiling from source): 5.4.0
- CUDA/cuDNN version: 8.0, 9.0, 9.1
- GPU model and memory: doesn’t matter
- Exact command to reproduce: See below.
Describe the problem
Compiling some custom native op with nvcc fails, with basically this error:
absl/strings/string_view.h(501): error: constexpr function return is non-constant
Compiling the same code with g++ does not have this issue. This seems specifically related to the CUDA frontent cudafe.
Source code / logs
Example code test.cpp:
// For Eigen::GpuDevice.
#define EIGEN_USE_GPU 1
// For Eigen::ThreadPoolDevice.
#define EIGEN_USE_THREADS 1
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/common_runtime/device.h"
#include <cuda.h>
#include <cuda_runtime.h>
#include <cublas_v2.h>
#include <math_constants.h>
#include "tensorflow/core/platform/stream_executor.h"
Compile command:
/usr/local/cuda-8.0/bin/nvcc -shared -O2 -std=c++11 -I /u/zeyer/py-envs/py36-tf111/lib/python3.6/site-packages/tensorflow/include -I /u/zeyer/py-envs/py36-tf111/lib/python3.6/site-packages/tensorflow/include/external/nsync/public -I /usr/local/cuda-8.0/include -L /usr/local/cuda-8.0/lib64 -x cu -DGOOGLE_CUDA=1 -Xcompiler -fPIC -D_GLIBCXX_USE_CXX11_ABI=0 -g test.cpp -o test.so -lblas -lf77blas -L/u/zeyer/py-envs/py36-tf111/lib/python3.6/site-packages/numpy/.libs -lopenblasp-r0-8dca6697.3.0.dev -L/u/zeyer/py-envs/py36-tf111/lib/python3.6/site-packages/tensorflow -ltensorflow_framework -v -Xcompiler -v
The full compile output (including some more warnings) can be seen here in the StackOverflow question.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 19
- Comments: 19 (7 by maintainers)
Links to this issue
Commits related to this issue
- added -DNDEBUG as suggested from here: https://github.com/tensorflow/tensorflow/issues/22766 — committed to mattangus/TF-Custom-Op-Workshop by mattangus 6 years ago
- always add -DNDEBUG=1 now https://github.com/rwth-i6/returnn/issues/87 https://github.com/tensorflow/tensorflow/issues/17316 https://github.com/tensorflow/tensorflow/issues/22766 — committed to rwth-i6/returnn by albertz 5 years ago
A workaround is to add the flag
-DNDEBUG.Hm, yea, although I would want that my
asserts will fail. Maybe-Dconstexpr=would be another option (did not try), although not sure if that has other drawbacks.Another hack is to remove the
ABSL_ASSERTfrom the offending line. wfm, ymmv.I second @albertz: the problem can be masked as suggested by @ppwwyyxx, but it’s not addressing the source of the issue.
In my environment, I can get past this error by replacing the call to
ABSL_ASSERT()intensorflow/include/absl/strings/string_view.h:501by0(but it is arguably just as ugly as-DNDEBUG).