How to build Tensorflow-serving r1.7 with TensorRT? How to pass the path of specific python to the compilation configure?
Have I written custom code : No OS Platform and Distribution: CentOS 7 TensorFlow installed from: source TensorFlow version: tensorflow-serving branch r1.7 Bazel version: 0.11.1 CUDA/cuDNN version: CUDA9.0, cuDNN 7.0.5, TensorRT4.0.4 (actually)
I tried to compile tensorflow-serving r1.7, and encountered an error:
ERROR:
/home/web_server/.cache/bazel/_bazel_web_server/7039d45003118564d66f2b06f1b7ea68/external/org_tensorflow/tensorflow/python/BUILD:4855:1: C++ compilation of rule '@org_tensorflow//tensorflow/python:framework/fast_tensor_util.so' failed (Exit 1)
bazel-out/k8-opt/genfiles/external/org_tensorflow/tensorflow/python/framework/fast_tensor_util.cpp:4:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
INFO: Elapsed time: 1.034s, Critical Path: 0.15s
FAILED: Build did NOT complete successfully
Seems that Tensoflow compilation couldn't find the Python.h, when #include <Python.h>. The python in my computer is located in a specified path, not in the default path. Every time I need to use python, I will export the xxx/python2.7/bin to $PATH, I think tensorflow-serving 1.7 shall also accept user specified python.
However, seems the tensorflow-serving r1.7 compilation couldn't find where the python is located? I tried to export $PYTHON_INCLUDE_PATH to environment, but it doesn't work. I tried to follow the tensorflow-serving installation tutorial, but the file structure seems changed (https://github.com/tensorflow/tensorflow/issues/19006), there is no ./configure or tensorflow/ under in root dir.
The question is how can I pass the python include path to the compilation?
I solved this by passing python path to bazel:
bazel build --config=cuda --action_env PYTHON_BIN_PATH=/your/python/path -c opt tensorflow_serving/...
https://github.com/tensorflow/serving/blob/master/tensorflow_serving/model_servers/BUILD#L283
add a line
"@org_tensorflow//tensorflow/contrib/tensorrt:trt_engine_op_kernel",
SUPPORTED_TENSORFLOW_OPS = [
"@org_tensorflow//tensorflow/contrib:contrib_kernels",
"@org_tensorflow//tensorflow/contrib:contrib_ops_op_lib",
"@org_tensorflow//tensorflow/contrib/tensorrt:trt_engine_op_kernel",
]
then , I find TensorRT in dynamic link so file.
0000000006ec8f60 V _ZTSN10tensorflow8tensorrt10TRTCalibOpE
0000000006ec9160 V _ZTSN10tensorflow8tensorrt11TRTEngineOpE
0000000006ec9320 V _ZTSN10tensorflow8tensorrt17TRTInt8CalibratorE
0000000006ec8fa0 V _ZTSN10tensorflow8tensorrt22TRTCalibrationResourceE
hope useful.
Hi, I'm pretty new for tensorrt. So does it means that if I use the converter to optimize the forzen graph and compile the tf serving with tensorrt support then I will be able to provide the services? Thank you guys in advance. @qiaohaijun @oscarriddle