Issue 1:
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template

System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow):

Yes I have written code which takes an image from a OpenFX framework and passes it as input to a Tensorflow session in C++, runs the feed forward and returns the result to a pixel buffer

OS Platform and Distribution (e.g., Linux Ubuntu 16.04):

Linux CentOS 6.10, using gcc/4.8.5 and bazel 0.11.0 with CUDA 9.1 and cuDNN 7.1.2

Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:

TensorFlow installed from (source or binary):

from source v1.6.0 zip here:

https://github.com/tensorflow/tensorflow/archive/v1.6.0.zip

TensorFlow version (use command below):

NA

Python version:

2.7.13 NA

Bazel version (if compiling from source):

0.11.0

GCC/Compiler version (if compiling from source):

gcc 4.8.5

CUDA/cuDNN version:

CUDA 9.1 with 3 updates, cuDNN 7.1.3

GPU model and memory:

GTX 1060 6Gb

You can collect some of this information using our environment capture script

You can also obtain the TensorFlow version with

python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"

Describe the current behavior

the code will no longer compile when I moved to a machine with a GPU

CXX Linux-64-debug/rotobot.o
rotobot.cpp: In function ‘void drawMasks(OpenImageIO::v1_6::ImageBuf&, std::unique_ptr<tensorflow::Session>&, OpenImageIO::v1_6::ImageBuf&, std::string&, bool, const bool*, const bool*, const bool*, double, double, double, double, double, double, bool)’:
rotobot.cpp:435:68: error: ‘inputTensor2’ was not declared in this scope
tensorflow::Status run_status = tfSession->Run({ { "input_image", inputTensor2 },{ "input_image_meta", inputMetadataTensor } },
^
rotobot.cpp:439:11: error: no matching function for call to ‘tensorflow::Session::Run(<brace-enclosed initializer list>, <brace-enclosed initializer list>, <brace-enclosed initializer list>, std::vector<tensorflow::Tensor>*)’
&outputs);
^
rotobot.cpp:439:11: note: candidates are:
In file included from rotobot.cpp:32:0:
/home/sam/dev/tensorflow-1.6.0/tensorflow/core/public/session.h:121:18: note: virtual tensorflow::Status tensorflow::Session::Run(const std::vector<std::pair<std::basic_string<char>, tensorflow::Tensor> >&, const std::vector<std::basic_string<char> >&, const std::vector<std::basic_string<char> >&, std::vector<tensorflow::Tensor>*)
virtual Status Run(const std::vector<std::pair<string, Tensor> >& inputs,
^
/home/sam/dev/tensorflow-1.6.0/tensorflow/core/public/session.h:121:18: note: no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const std::vector<std::pair<std::basic_string<char>, tensorflow::Tensor> >&’
/home/sam/dev/tensorflow-1.6.0/tensorflow/core/public/session.h:150:18: note: virtual tensorflow::Status tensorflow::Session::Run(const tensorflow::RunOptions&, const std::vector<std::pair<std::basic_string<char>, tensorflow::Tensor> >&, const std::vector<std::basic_string<char> >&, const std::vector<std::basic_string<char> >&, std::vector<tensorflow::Tensor>*, tensorflow::RunMetadata*)
virtual Status Run(const RunOptions& run_options,
^
/home/sam/dev/tensorflow-1.6.0/tensorflow/core/public/session.h:150:18: note: candidate expects 6 arguments, 4 provided
In file included from /home/sam/dev/tensorflow-1.6.0/tensorflow/core/framework/tensor.h:23:0,
from /home/sam/dev/tensorflow-1.6.0/tensorflow/core/public/session.h:24,
from rotobot.cpp:32:
/home/sam/dev/tensorflow-1.6.0/tensorflow/core/framework/types.h: In instantiation of ‘struct tensorflow::DataTypeToEnum<long int>’:
/home/sam/dev/tensorflow-1.6.0/tensorflow/core/framework/tensor.h:566:46: required from ‘typename tensorflow::TTypes<T, NDIMS>::Tensor tensorflow::Tensor::tensor() [with T = long int; long unsigned int NDIMS = 3ul; typename tensorflow::TTypes<T, NDIMS>::Tensor = Eigen::TensorMap<Eigen::Tensor<long int, 3, 1, long int>, 16, Eigen::MakePointer>]’
rotobot.cpp:1743:53: required from here
/home/sam/dev/tensorflow-1.6.0/tensorflow/core/framework/types.h:356:3: error: static assertion failed: Specified Data Type not supported
static_assert(IsValidDataType<T>::value, "Specified Data Type not supported");
^
In file included from /home/sam/dev/tensorflow-1.6.0/tensorflow/core/public/session.h:24:0,
from rotobot.cpp:32:
/home/sam/dev/tensorflow-1.6.0/tensorflow/core/framework/tensor.h: In instantiation of ‘typename tensorflow::TTypes<T, NDIMS>::Tensor tensorflow::Tensor::tensor() [with T = long int; long unsigned int NDIMS = 3ul; typename tensorflow::TTypes<T, NDIMS>::Tensor = Eigen::TensorMap<Eigen::Tensor<long int, 3, 1, long int>, 16, Eigen::MakePointer>]’:
rotobot.cpp:1743:53: required from here
/home/sam/dev/tensorflow-1.6.0/tensorflow/core/framework/tensor.h:566:46: error: ‘v’ is not a member of ‘tensorflow::DataTypeToEnum<long int>’

Describe the expected behavior

The code was compiling previously

The previous build environment was v1.6.0.2-gcbc6580

But was built without CUDA options.

I am linking against

-ltensorflow -ltensorflow_cc and -ltensorflow_framework -lnsync

and a few more

but I am not compiling yet.

lines 31,32,33 respectively are:

#include <tensorflow/core/platform/init_main.h>

#include <tensorflow/core/public/session.h>

#include <tensorflow/core/framework/tensor_shape.h>

Code to reproduce the issue

Provide a reproducible test case that is the bare minimum necessary to generate the problem.

lines 31,32,33 respectively are:

#include <tensorflow/core/platform/init_main.h>

#include <tensorflow/core/public/session.h>

#include <tensorflow/core/framework/tensor_shape.h>

Other info / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

see:

https://stackoverflow.com/questions/54033100/tensorflow-1-6-0-with-cuda-support-on-centos-6-10-c-linking-against-libtensorf

Issue 2:
System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes

OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Mint 18.2 Sonya (based on Ubuntu 16.04)

TensorFlow installed from (source or binary): Source

TensorFlow version (use command below): latest master (last commit b2fe2a8)

Python version: 3.5.2

Bazel version (if compiling from source): 0.15.0

GCC/Compiler version (if compiling from source): 7.3.0

CUDA/cuDNN version: 9.2/7.1

GPU model and memory: GX1080Ti 11GB

Exact command to reproduce: N/A

Describe the problem

When writing a custom op and registering a kernel builder using REGISTER_KERNEL_BUILDER, specifying a type constraint of int64_t will fail on some machines. This also fails for unsigned types too (as you would expect).

The problem occurs due to lines 381-403 in tensorflow/core/framework/types.h

MATCH_TYPE_AND_ENUM(float, DT_FLOAT);
MATCH_TYPE_AND_ENUM(double, DT_DOUBLE);
MATCH_TYPE_AND_ENUM(int32, DT_INT32);
MATCH_TYPE_AND_ENUM(uint32, DT_UINT32);
MATCH_TYPE_AND_ENUM(uint16, DT_UINT16);
MATCH_TYPE_AND_ENUM(uint8, DT_UINT8);
MATCH_TYPE_AND_ENUM(int16, DT_INT16);
MATCH_TYPE_AND_ENUM(int8, DT_INT8);
MATCH_TYPE_AND_ENUM(string, DT_STRING);
MATCH_TYPE_AND_ENUM(complex64, DT_COMPLEX64);
MATCH_TYPE_AND_ENUM(complex128, DT_COMPLEX128);
MATCH_TYPE_AND_ENUM(int64, DT_INT64);
MATCH_TYPE_AND_ENUM(uint64, DT_UINT64);
MATCH_TYPE_AND_ENUM(bool, DT_BOOL);
MATCH_TYPE_AND_ENUM(qint8, DT_QINT8);
MATCH_TYPE_AND_ENUM(quint8, DT_QUINT8);
MATCH_TYPE_AND_ENUM(qint16, DT_QINT16);
MATCH_TYPE_AND_ENUM(quint16, DT_QUINT16);
MATCH_TYPE_AND_ENUM(qint32, DT_QINT32);
MATCH_TYPE_AND_ENUM(bfloat16, DT_BFLOAT16);
MATCH_TYPE_AND_ENUM(Eigen::half, DT_HALF);
MATCH_TYPE_AND_ENUM(ResourceHandle, DT_RESOURCE);
MATCH_TYPE_AND_ENUM(Variant, DT_VARIANT);

In this case, int64 is being typedef'd to long long (tensorflow/core/platform/default/integral_types.h), however on some systems int64_t is typedef'd as __int64 (or potentially some other variation that results in a 64-bit signed type). Because of this int64_t != to int64 and the type constraint check fails.

On my system in particular, this code

#include <cstdint>
#include <iostream>

int main(void) {
std::cout << "int64_t...............: "
<< "(" << typeid(int64_t).name() << ") " << sizeof(int64_t) << std::endl;
std::cout << "long..................: "
<< "(" << typeid(long).name() << ") " << sizeof(long) << std::endl;
std::cout << "long int..............: "
<< "(" << typeid(long int).name() << ") " << sizeof(long int) << std::endl;
std::cout << "long long int.........: "
<< "(" << typeid(long long int).name() << ") " << sizeof(long long int) << std::endl;
std::cout << "long long.............: "
<< "(" << typeid(long long).name() << ") " << sizeof(long long) << std::endl;
std::cout << "uint64_t..............: "
<< "(" << typeid(uint64_t).name() << ") " << sizeof(int64_t) << std::endl;
std::cout << "unsigned long.........: "
<< "(" << typeid(unsigned long).name() << ") " << sizeof(unsigned long) << std::endl;
std::cout << "unsigned long int.....: "
<< "(" << typeid(unsigned long int).name() << ") " << sizeof(unsigned long int) << std::endl;
std::cout << "unsigned long long int: "
<< "(" << typeid(unsigned long long int).name() << ") " << sizeof(unsigned long long int) << std::endl;
std::cout << "unsigned long long....: "
<< "(" << typeid(unsigned long long).name() << ") " << sizeof(unsigned long long) << std::endl;
std::cout << "long long == int64_t? " << (std::is_same<long long, int64_t>::value ? "yes" : "no") << std::endl;
std::cout << "(sizeof(long long) == 8) && std::is_signed<long long>::value? "
<< ((sizeof(long long) == 8) && std::is_signed<long long>::value ? "yes" : "no") << std::endl;
std::cout << "(sizeof(int64_t) == 8) && std::is_signed<int64_t>::value? "
<< ((sizeof(int64_t) == 8) && std::is_signed<int64_t>::value ? "yes" : "no") << std::endl;
std::cout << "unsigned long long == uint64_t? "
<< (std::is_same<unsigned long long, uint64_t>::value ? "yes" : "no") << std::endl;
std::cout << "(sizeof(unsigned long long) == 8) && !std::is_signed<unsigned long long>::value? "
<< ((sizeof(unsigned long long) == 8) && !std::is_signed<unsigned long long>::value ? "yes" : "no")
<< std::endl;
std::cout << "(sizeof(uint64_t) == 8) && !std::is_signed<uint64_t>::value? "
<< ((sizeof(uint64_t) == 8) && !std::is_signed<uint64_t>::value ? "yes" : "no") << std::endl;
return 0;
}

produces this output

int64_t...............: (l) 8
long..................: (l) 8
long int..............: (l) 8
long long int.........: (x) 8
long long.............: (x) 8
uint64_t..............: (m) 8
unsigned long.........: (m) 8
unsigned long int.....: (m) 8
unsigned long long int: (y) 8
unsigned long long....: (y) 8
long long == int64_t? no
(sizeof(long long) == 8) && std::is_signed<long long>::value? yes
(sizeof(int64_t) == 8) && std::is_signed<int64_t>::value? yes
unsigned long long == uint64_t? no
(sizeof(unsigned long long) == 8) && !std::is_signed<unsigned long long>::value? yes
(sizeof(uint64_t) == 8) && !std::is_signed<uint64_t>::value? yes

On a system where the current type constraint check works, the same code outputs this

int64_t...............: (x) 8
long..................: (l) 8
long int..............: (l) 8
long long int.........: (x) 8
long long.............: (x) 8
uint64_t..............: (y) 8
unsigned long.........: (m) 8
unsigned long int.....: (m) 8
unsigned long long int: (y) 8
unsigned long long....: (y) 8
long long == int64_t? yes
(sizeof(long long) == 8) && std::is_signed<long long>::value? yes
(sizeof(int64_t) == 8) && std::is_signed<int64_t>::value? yes
unsigned long long == uint64_t? yes
(sizeof(unsigned long long) == 8) && !std::is_signed<unsigned long long>::value? yes
(sizeof(uint64_t) == 8) && !std::is_signed<uint64_t>::value? yes

Since using an int64_t should be supported (as it is equivalent to long long), I propose that the code be modified to either use the integral types defined in cstdint (int8_t, int16_t, int32_t, int64_t), or the check should be changed to look for a 64-bit type that is signed using a combination of sizeof and std::is_signed

Source code / logs

The following example produces the error

#include <tensorflow/core/framework/op.h>
#include <tensorflow/core/framework/op_kernel.h>

REGISTER_OP("ExampleOp").Attr("T: {int32, int64, uint32, uint64}");

template <typename T>
class ExampleOp : public tensorflow::OpKernel {
public:
explicit ExampleOp(tensorflow::OpKernelConstruction* context) : OpKernel(context) {}

void Compute(tensorflow::OpKernelContext* context) override {}
};

REGISTER_KERNEL_BUILDER(Name("ExampleOp").Device(tensorflow::DEVICE_CPU).TypeConstraint<int32_t>("T"), ExampleOp<int32_t>);
REGISTER_KERNEL_BUILDER(Name("ExampleOp").Device(tensorflow::DEVICE_CPU).TypeConstraint<int64_t>("T"), ExampleOp<int64_t>);
REGISTER_KERNEL_BUILDER(Name("ExampleOp").Device(tensorflow::DEVICE_CPU).TypeConstraint<uint32_t>("T"), ExampleOp<uint32_t>);
REGISTER_KERNEL_BUILDER(Name("ExampleOp").Device(tensorflow::DEVICE_CPU).TypeConstraint<uint64_t>("T"), ExampleOp<uint64_t>);

Here is the resulting compilation log

/usr/bin/c++ -Dmwe_EXPORTS -isystem /usr/local/lib/python3.5/dist-packages/tensorflow/include -I../src -march=native -mtune=native -fPIC -O3 -DNDEBUG -fPIC -march=native -mtune=native -MD -MT CMakeFiles/mwe.dir/mwe.cpp.o -MF CMakeFiles/mwe.dir/mwe.cpp.o.d -o CMakeFiles/mwe.dir/mwe.cpp.o -c ../mwe.cpp
In file included from /usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/tensor.h:23:0,
from /usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/device_base.h:23,
from /usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/op_kernel.h:26,
from ../mwe.cpp:2:
/usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/types.h: In instantiation of ‘struct tensorflow::DataTypeToEnum<long int>’:
/usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/kernel_def_builder.h:82:62: required from ‘tensorflow::KernelDefBuilder& tensorflow::KernelDefBuilder::TypeConstraint(const char*) [with T = long int]’
../mwe.cpp:16:1: required from here
/usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/types.h:356:3: error: static assertion failed: Specified Data Type not supported
static_assert(IsValidDataType<T>::value, "Specified Data Type not supported");
^~~~~~~~~~~~~
In file included from /usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/op_kernel.h:28:0,
from ../mwe.cpp:2:
/usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/kernel_def_builder.h: In instantiation of ‘tensorflow::KernelDefBuilder& tensorflow::KernelDefBuilder::TypeConstraint(const char*) [with T = long int]’:
../mwe.cpp:16:1: required from here
/usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/kernel_def_builder.h:82:62: error: ‘v’ is not a member of ‘tensorflow::DataTypeToEnum<long int>’
return this->TypeConstraint(attr_name, DataTypeToEnum<T>::v());
~~~~~~~~~~~~~~~~~~~~^~
In file included from /usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/tensor.h:23:0,
from /usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/device_base.h:23,
from /usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/op_kernel.h:26,
from ../mwe.cpp:2:
/usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/types.h: In instantiation of ‘struct tensorflow::DataTypeToEnum<long unsigned int>’:
/usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/kernel_def_builder.h:82:62: required from ‘tensorflow::KernelDefBuilder& tensorflow::KernelDefBuilder::TypeConstraint(const char*) [with T = long unsigned int]’
../mwe.cpp:20:1: required from here
/usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/types.h:356:3: error: static assertion failed: Specified Data Type not supported
static_assert(IsValidDataType<T>::value, "Specified Data Type not supported");
^~~~~~~~~~~~~
In file included from /usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/op_kernel.h:28:0,
from ../mwe.cpp:2:
/usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/kernel_def_builder.h: In instantiation of ‘tensorflow::KernelDefBuilder& tensorflow::KernelDefBuilder::TypeConstraint(const char*) [with T = long unsigned int]’:
../mwe.cpp:20:1: required from here
/usr/local/lib/python3.5/dist-packages/tensorflow/include/tensorflow/core/framework/kernel_def_builder.h:82:62: error: ‘v’ is not a member of ‘tensorflow::DataTypeToEnum<long unsigned int>’
return this->TypeConstraint(attr_name, DataTypeToEnum<T>::v());
~~~~~~~~~~~~~~~~~~~~^~

EDIT: Added a minimal working example