Problems and solutions about building Tensorflow-1.8 with TensorRT 4.0

Robin Dong 2018-06-29 10:41

Problem:
When compiling Tensorflow-1.8 with CUDA-9.2, it reports:

bazel-out/host/bin/_solib_local/_U_S_Stensorflow_Spython_Cgen_Unn_Uops_Upy_Uwrappers_Ucc___Utensorflow/libtensorflow_framework.so: undefined reference to `cublasGemmEx@libcublas.so.9.0'
bazel-out/host/bin/_solib_local/_U_S_Stensorflow_Spython_Cgen_Unn_Uops_Upy_Uwrappers_Ucc___Utensorflow/libtensorflow_framework.so: undefined reference to `cublasZhpmv_v2@libcublas.so.9.0'
bazel-out/host/bin/_solib_local/_U_S_Stensorflow_Spython_Cgen_Unn_Uops_Upy_Uwrappers_Ucc___Utensorflow/libtensorflow_framework.so: undefined reference to `cufftExecD2Z@libcufft.so.9.0'
bazel-out/host/bin/_solib_local/_U_S_Stensorflow_Spython_Cgen_Unn_Uops_Upy_Uwrappers_Ucc___Utensorflow/libtensorflow_framework.so: undefined reference to `cublasSrotg_v2@libcublas.so.9.0'
bazel-out/host/bin/_solib_local/_U_S_Stensorflow_Spython_Cgen_Unn_Uops_Upy_Uwrappers_Ucc___Utensorflow/libtensorflow_framework.so: undefined reference to `cufftExecR2C@libcufft.so.9.0'
...

Solution:
Add ‘/usr/local/cuda-9.2/lib64’ into ‘/etc/ld.so.conf’ and run ‘sudo ldconfig’ to make it works.

Problem:
When compiling Tensorflow-1.8, it reports:

./tensorflow/python/client/tf_session_helper.h:19:20: fatal error: Python.h: No such file or directory
...

Solution:
In ‘.tf_configure.bazelrc’ file, use real python location instead of soft link:

#don't use "/usr/bin/python"
build --action_env PYTHON_BIN_PATH="/usr/bin/python2.7"

Problem:
When running TensorRT, it reports:

ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/web_server/dlpy72/dlpy/lib/python2.7/site-packages/tensorrt/infer/_nv_infer_bindings.so)

Solution:
Run TensorRT with LD_LIBRARY_PATH:

LD_LIBRARY_PATH=/usr/local/gcc-5.3/lib64:$LD_LIBRARY_PATH python run_tensorrt.py

[返回] [原文链接]