因此我成功地使CPU版本仅与我的软件一起使用。
现在,我已经安装了带有CUDA硬件的新计算机,该计算机已经在Windows下使用contrib cmake进行了工作。
Linux构建使用bazel并构建所需的目标
//tensorflow:libtensorflow.so
//tensorflow:libtensorflow_cc.so
//tensorflow:libtensorflow_framework.so
使用以下.zip文件: https://github.com/tensorflow/tensorflow/archive/v1.6.0.zip
在CentOS 6.10上使用CUDA 9.1 cudnn 7.1.2和gcc 4.8.5
用榛子制成
但是当我继续构建软件时,出现以下错误:
CXX Linux-64-debug/rotobot.o
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:1742: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:1742: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>’
CheckTypeAndIsAligned(DataTypeToEnum<T>::v());
^
make: *** [Linux-64-debug/rotobot.o] Error 1
有什么想法吗?
以下是第31-32行
#include <tensorflow/core/platform/init_main.h>
#include <tensorflow/core/public/session.h>
#include <tensorflow/core/framework/tensor_shape.h>
long一词根本没有出现在源代码中。
以前一切正常。
以前的构建环境是虚拟机CentOS 6.9,但几乎完全相同。
找到该产品编辑:
我可以看到问题有点不透明:
这是正在运行的命令
g++ -c -std=c++11 -g -L/home/sam/opt/standalone_tf/lib -ltensorflow_cc -L/home/sam/opt/standalone_tf/lib -ltensorflow_framework -I/home/sam/opt/standalone_tf/include/third_party -I/home/sam/opt/standalone_tf/include -I/home/sam/opt/standalone_tf/include/nsync/public/ -I/home/sam/opt/eigen3/include/eigen3 -I/home/sam/opt/ilmbase-2.2.0/include -I/home/sam/opt/oiio-1.6.18/include/ -I/home/sam/dev/RLM/src -L/home/samh/dev/RLM/x64_l1 -lrlm -I../..//../include -I../..//include -I../..//Plugins/include -m64 -fPIC -fvisibility=hidden rotobot.cpp -o Linux-64-debug/rotobot.o
感兴趣的内容包括: -I / home / sam / opt / standalone_tf / include / third_party -I / home / sam / opt / standalone_tf / include -I / home / sam / opt / standalone_tf / include / nsync / public / -I / home / sam / opt / eigen3 / include / eigen3
其中的内容 / home / sam / opt / standalone_tf
在本教程中选择目录/ home / standalone
https://tuanphuc.github.io/standalone-tensorflow-cpp/
以上教程中的示例构建并运行良好。
请参阅:
[sam@localhost Rotobot]$ cd ~/opt/standalone_tf/
[sam@localhost standalone_tf]$ make clean
rm -f main
[sam@localhost standalone_tf]$ make
g++ -std=c++11 -g -Wall -D_DEBUG -Wshadow -Wno-sign-compare -w -o main main.cc -I/usr/local/include/eigen3 -I./include/third_party -I./include -I./include/nsync/public/ -lprotobuf -pthread -lpthread -L/home/sam/opt/standalone_tf//lib/ -Wl,-R/home/sam/opt/standalone_tf//lib/ '-Wl,-R$ORIGIN' -ltensorflow_cc -ltensorflow_framework -lrt
[sam@localhost standalone_tf]$ make run
./main --image=./data/grace_hopper.jpg --graph=./data/inception_v3_2016_08_28_frozen.pb --labels=./data/imagenet_slim_labels.txt
2019-01-05 07:26:49.172451: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2
2019-01-05 07:26:49.804743: I main.cc:250] military uniform (653): 0.834307
2019-01-05 07:26:49.804781: I main.cc:250] mortarboard (668): 0.0218693
2019-01-05 07:26:49.804791: I main.cc:250] academic gown (401): 0.010358
2019-01-05 07:26:49.804799: I main.cc:250] pickelhaube (716): 0.00800808
2019-01-05 07:26:49.804807: I main.cc:250] bulletproof vest (466): 0.00535084
当将构建系统从VM中的旧框转移到新的CUDA HW解决方案中时,我似乎丢失了一些有关tensorflow头文件内容的配置。
现在,我将尝试在沙箱中构建示例,希望它可以将一些新知识转移到现有程序包中以进行部署。
只是让您知道这是可部署软件包的原型,所以我花时间在CentOS 6.x上的原因是,如果有一个到达此目的地的捷径,我需要该产品与glibc 2.12兼容。让我知道。
答案 0 :(得分:0)
这是原因
auto detectionsMap = outputs[0].tensor<int64_t, 3>();
这可行
auto detectionsMap = outputs[0].tensor<int64, 3>();
之所以这样做是因为tensorboard告诉了我,很有趣的是,它在VM中可以正常运行,但不能在真正的硬件上运行。
奇怪吗?