在win 10以bazel方式源码构建tensorflow 1.12的过程中,报如下错误:
more than one instance of overloaded function "__hadd" matches the argument list: function "__hadd(int, int)" function "__hadd(__half, __half)" argument types are: (const Eigen::half, const Eigen::half)
是因为Eigen本身的bug,解决方法是修改tensorflow-master\bazel-tensorflow-master\external\eigen_archive\Eigen\src\Core\arch\CUDA\Half.h的代码:
将
EIGEN_STRONG_INLINE __device__ half operator + (const half& a, const half& b) { return __hadd(a, b); }
修改为:
EIGEN_STRONG_INLINE __device__ half operator + (const half& a, const half& b) { #if defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER >= 90000 return __hadd(::__half(a), ::__half(b)); #else return __hadd(a, b); #endif }
将
EIGEN_STRONG_INLINE __device__ half operator / (const half& a, const half& b) { float num = __half2float(a); float denom = __half2float(b); return __float2half(num / denom); }
修改为:
EIGEN_STRONG_INLINE __device__ half operator / (const half& a, const half& b) { #if defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER >= 90000 return __hdiv(a, b); #else float num = __half2float(a); float denom = __half2float(b); return __float2half(num / denom); #endif }
微信
支付宝