tensorflow: Problems when building tensorflow with CUDA

When I built tensorflow from source with CUDA using bazel,I got the following errors:

external/com_google_absl/absl/strings/string_view.h(496): warning: expression has no effect
external/com_google_absl/absl/strings/str_cat.h(259): error: expression must have a constant value
external/com_google_absl/absl/strings/str_cat.h(259): error: expression must have a constant value

I add some codes like std::cout<<"using cpu for Launch<Device>"<<std::endl;.Is there anything wrong? Thanks for any help.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Latest version of TensorFlow is tested against CUDA 9.0. If you are using a different version of CUDA you have to build TF from sources yourself. Feel free to open a new and fill all the information provided by the template if you are facing problems. This will help us to focus on a specific issues since system configurations can vary widely from user to user. Thanks!

@yunjiangster try clean previous build and add --copt="-fPIC" and then build again. I can successfully build tf-serving with CUDA 9 on CentOS 7 using script like bellow (change the values of env variables according to your system):

#!/bin/sh
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/usr/bin:/bin:/root/bin
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH
export BAZEL_VERSION=0.23.1
export CUDNN_VERSION=7.5.0
export TF_TENSORRT_VERSION=5.0.2
export TF_NEED_CUDA=1
export TF_NEED_TENSORRT=1
export TENSORRT_INSTALL_PATH=/usr/local/tensorRT/lib
export TF_CUDA_COMPUTE_CAPABILITIES=3.0,3.5,5.2,6.0,6.1
export TF_CUDA_VERSION=9.0
export TF_CUDNN_VERSION=7
export TF_NCCL_VERSION=
export TMP="/home/tcheng/serving/tmp"

bazel build --color=yes --curses=yes --config=cuda --copt="-fPIC" --copt=-O3 --verbose_failures --output_filter=DONT_MATCH_ANYTHING --config=nativeopt --incompatible_disallow_data_transition=false tensorflow_serving/model_servers:tensorflow_model_server

You can try to install tensorflow-gpu from anaconda