}

[SOLVED] Tensor flow compilation error: no such package '@local_config_cuda//cuda'

Created:

While trying to compile tensorflow from source using the command on linux ubuntu (but OSX is also affected):

./configure;bazel build -c opt config=cuda //tensorflow/tools/pip_package:build_pip_package

The bazel build fails with the following error:

ERROR: Skipping '//tensorflow/tools/pip_package:build_pip_package': error loading package 'tensorflow/tools/pip_package': Encountered error while reading extension file 'cuda/build_defs.bzl': no such package '@local_config_cuda//cuda': Traceback (most recent call last):
    File "/home/alex/tensorflow/third_party/gpus/cuda_configure.bzl", line 1039
        _create_local_cuda_repository(repository_ctx)
    File "/home/alex/tensorflow/third_party/gpus/cuda_configure.bzl", line 976, in _create_local_cuda_repository
        _host_compiler_includes(repository_ctx, cc)
    File "/home/alex/tensorflow/third_party/gpus/cuda_configure.bzl", line 145, in _host_compiler_includes
        get_cxx_inc_directories(repository_ctx, cc)
    File "/home/alex/tensorflow/third_party/gpus/cuda_configure.bzl", line 120, in get_cxx_inc_directories
        set(includes_cpp)
depsets cannot contain mutable items
WARNING: Target pattern parsing failed.
ERROR: error loading package 'tensorflow/tools/pip_package': Encountered error while reading extension file 'cuda/build_defs.bzl': no such package '@local_config_cuda//cuda': Traceback (most recent call last):
    File "/home/alex/tensorflow/third_party/gpus/cuda_configure.bzl", line 1039
        _create_local_cuda_repository(repository_ctx)
    File "/home/alex/tensorflow/third_party/gpus/cuda_configure.bzl", line 976, in _create_local_cuda_repository
        _host_compiler_includes(repository_ctx, cc)
    File "/home/alex/tensorflow/third_party/gpus/cuda_configure.bzl", line 145, in _host_compiler_includes
        get_cxx_inc_directories(repository_ctx, cc)
    File "/home/alex/tensorflow/third_party/gpus/cuda_configure.bzl", line 120, in get_cxx_inc_directories
        set(includes_cpp)
depsets cannot contain mutable items
INFO: Elapsed time: 13.663s
FAILED: Build did NOT complete successfully (0 packages loaded)
    currently loading: tensorflow/tools/pip_package

Solution

TO solve this issue rollback the version of bazel to 0.5.2. First delete it with apt (or apt-get) and then install bazel from source code.

sudo apt purge bazel

Install steps from source code:

sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python
# download the appropiate installer from https://github.com/bazelbuild/bazel/releases/tag/0.5.2
wget https://github.com/bazelbuild/bazel/releases/download/0.5.2/bazel-0.5.2-installer-linux-x86_64.sh
chmod +x bazel-0.5.2-installer-linux-x86_64.sh
./bazel-0.5.2-installer-linux-x86_64.sh --user

For OSX use this bazel installer

You can also use a custom APT repository:

sudo apt-get install openjdk-8-jdk

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update && sudo apt-get install oracle-java8-installer