Skip to content

Instantly share code, notes, and snippets.

@Brainiarc7
Last active September 9, 2024 22:48
Show Gist options
  • Select an option

  • Save Brainiarc7/6d6c3f23ea057775b72c52817759b25c to your computer and use it in GitHub Desktop.

Select an option

Save Brainiarc7/6d6c3f23ea057775b72c52817759b25c to your computer and use it in GitHub Desktop.

Revisions

  1. Brainiarc7 revised this gist Jul 21, 2019. 1 changed file with 18 additions and 5 deletions.
    23 changes: 18 additions & 5 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -150,13 +150,26 @@ Output:

    Then call bazel to build the TensorFlow pip package:

    bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=cuda //tensorflow/tools/pip_package:build_pip_package


    bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

    ```sh
    bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=cuda //tensorflow/tools/pip_package:build_pip_package

    bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
    ```

    This will build the package with optimizations for FMA, AVX and SSE.

    To build the C library as a tarball (which you can install as needed) with the optimizations above:

    ```sh
    bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=cuda //tensorflow/tools/lib_package:libtensorflow
    ```

    Which should produce an archive in:

    ```sh
    bazel-bin/tensorflow/tensorflow/tools/lib_package/libtensorflow.tar.gz
    ```

    A stock build would be as such:

    ```
  2. Brainiarc7 revised this gist Jun 30, 2018. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -32,6 +32,13 @@ sudo apt-get update && sudo apt-get -y upgrade
    ```

    On Ubuntu 18.04LTS, this should be enough for the device driver:

    ```
    sudo apt-get install nvidia-kernel-source-396 nvidia-driver-396
    ```
    Failure to do this will result in a broken driver installation.


    When done, create a library configuration file for cupti:

  3. Brainiarc7 revised this gist Jun 6, 2018. 1 changed file with 3 additions and 50 deletions.
    53 changes: 3 additions & 50 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -2,17 +2,17 @@

    TensorFlow is now distributed under an Apache v2 open source license on GitHub.

    **On Ubuntu 16.04LTS:**
    **On Ubuntu 16.04LTS+:**


    **Step 1. Install NVIDIA CUDA:**

    To use TensorFlow with NVIDIA GPUs, the first step is to install the CUDA Toolkit as shown:

    ```
    wget -c -v -nc http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.1.85-1_amd64.deb
    wget -c -v -nc https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.2.88-1_amd64.deb
    sudo dpkg -i cuda-repo-ubuntu1604_9.1.85-1_amd64.deb
    sudo dpkg -i cuda-repo-ubuntu1604_9.2.88-1_amd64.deb
    sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
    @@ -69,33 +69,6 @@ When done, remember to source the file:

    You can also install CUDA manually. However, take care not to install its' bundled driver.

    **On Ubuntu 18.04LTS:**

    You can simply install the `nvidia-cuda-toolkit` and the `libcupti` packages, available directly from the repositories:

    ```
    sudo apt install nvidia-cuda-toolkit libcupti9.1 libcupti-dev
    ```

    Then install the latest driver manually, as of the time of writing:

    (a). Add the repository:

    ```
    sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt-get update && sudo apt-get -y upgrade
    ```

    (b). Install the driver:

    ```
    sudo apt install nvidia-driver-396
    ```


    No further setup is necessary.


    **Step 2. Install NVIDIA cuDNN:**
    @@ -106,27 +79,7 @@ Once downloaded, uncompress the files and copy them into the CUDA Toolkit direct

    $ sudo tar -xvf cudnn-9.1-* -C /usr/local

    For **Ubuntu 18.04LTS**, extract the same as shown:

    $ sudo tar -xvf cudnn-9.1-* -C /usr/lib

    Then create a library configuration file for cupti:

    /etc/ld.so.conf.d/cupti.conf

    With the content:

    /usr/lib/cuda/lib64


    Then run:

    sudo ldconfig -vvvv

    To apply the new library configuration settings.



    **Step 3. Install and upgrade PIP:**

    TensorFlow itself can be installed using the pip package manager. First, make sure that your system has pip installed and updated:
  4. Brainiarc7 revised this gist Jun 4, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -155,6 +155,9 @@ First, clone the TensorFlow source code repository:

    $ git clone https://github.com/tensorflow/tensorflow
    $ cd tensorflow

    The last step is no longer needed:

    $ git reset --hard a23f5d7

    Then run the configure script as follows:
  5. Brainiarc7 revised this gist Jun 4, 2018. 1 changed file with 53 additions and 1 deletion.
    54 changes: 53 additions & 1 deletion build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@

    TensorFlow is now distributed under an Apache v2 open source license on GitHub.

    **On Ubuntu 16.04LTS:**


    **Step 1. Install NVIDIA CUDA:**

    @@ -19,6 +21,7 @@ sudo apt-get update
    sudo apt-get install cuda
    ```
    Keep checking the NVIDIA CUDA webpage for new releases as applicable. This article is accurate as at the time of writing.

    Ensure that you have the latest driver:

    @@ -66,14 +69,63 @@ When done, remember to source the file:

    You can also install CUDA manually. However, take care not to install its' bundled driver.

    **On Ubuntu 18.04LTS:**

    You can simply install the `nvidia-cuda-toolkit` and the `libcupti` packages, available directly from the repositories:

    ```
    sudo apt install nvidia-cuda-toolkit libcupti9.1 libcupti-dev
    ```

    Then install the latest driver manually, as of the time of writing:

    (a). Add the repository:

    ```
    sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt-get update && sudo apt-get -y upgrade
    ```

    (b). Install the driver:

    ```
    sudo apt install nvidia-driver-396
    ```


    No further setup is necessary.


    **Step 2. Install NVIDIA cuDNN:**

    Once the CUDA Toolkit is installed, download the latest cuDNNN Library for Linux, based on the CUDA version you're using. In this case, we're on CUDA 9.1, so we will refer to the version name below (note that you will need to register for the Accelerated Computing Developer Program).

    Once downloaded, uncompress the files and copy them into the CUDA Toolkit directory (assumed here to be in `/usr/local/cuda/`):
    Once downloaded, uncompress the files and copy them into the CUDA Toolkit directory (assumed here to be in `/usr/local/cuda/` for Ubuntu 16.04LTS):

    $ sudo tar -xvf cudnn-9.1-* -C /usr/local

    For **Ubuntu 18.04LTS**, extract the same as shown:

    $ sudo tar -xvf cudnn-9.1-* -C /usr/lib

    Then create a library configuration file for cupti:

    /etc/ld.so.conf.d/cupti.conf

    With the content:

    /usr/lib/cuda/lib64


    Then run:

    sudo ldconfig -vvvv

    To apply the new library configuration settings.



    **Step 3. Install and upgrade PIP:**

  6. Brainiarc7 revised this gist May 17, 2018. 1 changed file with 17 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -142,6 +142,23 @@ Then call bazel to build the TensorFlow pip package:

    This will build the package with optimizations for FMA, AVX and SSE.

    A stock build would be as such:

    ```
    bazel build //tensorflow/tools/pip_package:build_pip_package
    bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
    ```

    You can use the stock build as shown above if you had passed the configuration flags (for optimization) directly to the configure script above. Use this string:

    --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2

    Which will replace `--march=native` (the default).

    If you're on Skylake to Coffee lake, this is what you need.

    And finally install the TensorFlow pip package

    For Python 2.7:
  7. Brainiarc7 revised this gist May 17, 2018. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    **Building Tensorflow from source on Linux for maximum performance:**
    **Building Tensorflow from source on Ubuntu 16.04LTS for maximum performance:**

    TensorFlow is now distributed under an Apache v2 open source license on GitHub.

    @@ -63,15 +63,17 @@ Now, append the PATH variable with the following:
    When done, remember to source the file:

    source /etc/environment

    You can also install CUDA manually. However, take care not to install its' bundled driver.


    **Step 2. Install NVIDIA cuDNN:**

    Once the CUDA Toolkit is installed, download the latest cuDNNN Library for Linux (note that you will need to register for the Accelerated Computing Developer Program).
    Once the CUDA Toolkit is installed, download the latest cuDNNN Library for Linux, based on the CUDA version you're using. In this case, we're on CUDA 9.1, so we will refer to the version name below (note that you will need to register for the Accelerated Computing Developer Program).

    Once downloaded, uncompress the files and copy them into the CUDA Toolkit directory (assumed here to be in `/usr/local/cuda/`):

    $ sudo tar -xvf cudnn-9.0-* -C /usr/local
    $ sudo tar -xvf cudnn-9.1-* -C /usr/local

    **Step 3. Install and upgrade PIP:**

  8. Brainiarc7 revised this gist May 16, 2018. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -210,6 +210,16 @@ You should now be able to run a Hello World application:
    ```

    **Tips:**

    To achieve similar results without building the packages, you can deploy nvidia-docker and install tensorflow from NVIDIA's NGC registry.

    Use this to deploy nvidia-docker on Ubuntu: https://gist.github.com/Brainiarc7/a8ab5f89494d053003454efc3be2d2ef

    Use the NGC to deploy the preconfigured containers. Optimized builds for Tensorflow, Caffe, Torch, etc are also available: https://www.nvidia.com/en-us/gpu-cloud/deep-learning-containers/

    Also see the NGC panel: https://ngc.nvidia.com/registry




  9. Brainiarc7 revised this gist May 16, 2018. 1 changed file with 69 additions and 7 deletions.
    76 changes: 69 additions & 7 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -5,28 +5,84 @@ TensorFlow is now distributed under an Apache v2 open source license on GitHub.

    **Step 1. Install NVIDIA CUDA:**

    To use TensorFlow with NVIDIA GPUs, the first step is to install the CUDA Toolkit.
    To use TensorFlow with NVIDIA GPUs, the first step is to install the CUDA Toolkit as shown:

    ```
    wget -c -v -nc http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.1.85-1_amd64.deb
    sudo dpkg -i cuda-repo-ubuntu1604_9.1.85-1_amd64.deb
    sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
    sudo apt-get update
    sudo apt-get install cuda
    ```

    Ensure that you have the latest driver:

    ```
    sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt-get update && sudo apt-get -y upgrade
    ```


    When done, create a library configuration file for cupti:

    /etc/ld.so.conf.d/cupti.conf

    With the content:

    /usr/local/cuda/extras/CUPTI/lib64

    Confirm that the library configuration file for CUDA libraries also exists with the correct settings:

    /etc/ld.so.conf.d/cuda.conf

    The content should be:

    /usr/local/cuda/lib64

    When done, load the new configuration:

    sudo ldconfig -vvvv

    **Useful environment variables for CUDA:**

    Edit the `/etc/environment` file and append the following:

    CUDA_HOME=/usr/local/cuda

    Now, append the PATH variable with the following:

    /usr/local/cuda/bin:$HOME/bin

    When done, remember to source the file:

    source /etc/environment


    **Step 2. Install NVIDIA cuDNN:**

    Once the CUDA Toolkit is installed, download cuDNN v5.1 Library for Linux (note that you will need to register for the Accelerated Computing Developer Program).
    Once the CUDA Toolkit is installed, download the latest cuDNNN Library for Linux (note that you will need to register for the Accelerated Computing Developer Program).

    Once downloaded, uncompress the files and copy them into the CUDA Toolkit directory (assumed here to be in /usr/local/cuda/):
    Once downloaded, uncompress the files and copy them into the CUDA Toolkit directory (assumed here to be in `/usr/local/cuda/`):

    $ sudo tar -xvf cudnn-8.0-* -C /usr/local
    $ sudo tar -xvf cudnn-9.0-* -C /usr/local

    **Step 3. Install and upgrade PIP:**

    Here. we are using a custom built Python binary, loaded via the modules system. We will handle its' installation from there.

    TensorFlow itself can be installed using the pip package manager. First, make sure that your system has pip installed and updated:

    $ sudo apt-get install python-pip python-dev
    $ pip install --upgrade pip

    **Step 4. Install Bazel:**

    To build TensorFlow from source, the Bazel build system must first be installed as follows.
    To build TensorFlow from source, the Bazel build system (and the latest available openjdk) must first be installed as follows.

    $ sudo apt-get install software-properties-common swig
    $ sudo add-apt-repository ppa:webupd8team/java
    @@ -110,6 +166,7 @@ For Python 3.4:

    To test the installation, open an interactive Python shell and import the TensorFlow module:

    ```
    $ cd
    $ python
    @@ -120,6 +177,8 @@ To test the installation, open an interactive Python shell and import the Tensor
    tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcufft.so locally
    tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcuda.so.1 locally
    tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcurand.so locally
    ```

    With the TensorFlow module imported, the next step to test the installation is to create a TensorFlow Session, which will initialize the available computing devices and provide a means of executing computation graphs:

    @@ -142,11 +201,14 @@ To manually control which devices are visible to TensorFlow, set the `CUDA_VISIB

    You should now be able to run a Hello World application:

    ```
    >>> hello_world = tf.constant("Hello, TensorFlow!")
    >>> print sess.run(hello_world)
    Hello, TensorFlow!
    >>> print sess.run(tf.constant(123)*tf.constant(456))
    56088
    ```



  10. Brainiarc7 revised this gist May 16, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@ To build TensorFlow from source, the Bazel build system must first be installed
    $ sudo add-apt-repository ppa:webupd8team/java
    $ sudo apt-get update
    $ sudo apt-get install oracle-java8-installer
    $ echo "deb http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
    $ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
    $ curl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add -
    $ sudo apt-get update
    $ sudo apt-get install bazel
  11. Brainiarc7 revised this gist Mar 27, 2017. No changes.
  12. Brainiarc7 revised this gist Mar 27, 2017. 1 changed file with 8 additions and 7 deletions.
    15 changes: 8 additions & 7 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    **Download and Installation Instructions for Tensorflow:**
    **Building Tensorflow from source on Linux for maximum performance:**

    TensorFlow is now distributed under an Apache v2 open source license on GitHub.

    @@ -113,13 +113,13 @@ To test the installation, open an interactive Python shell and import the Tensor
    $ cd
    $ python


    >>> import tensorflow as tf
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcublas.so locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcudnn.so locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcufft.so locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcuda.so.1 locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcurand.so locally
    tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcublas.so locally
    tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcudnn.so locally
    tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcufft.so locally
    tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcuda.so.1 locally
    tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcurand.so locally

    With the TensorFlow module imported, the next step to test the installation is to create a TensorFlow Session, which will initialize the available computing devices and provide a means of executing computation graphs:

    @@ -151,3 +151,4 @@ You should now be able to run a Hello World application:




  13. Brainiarc7 revised this gist Mar 25, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ Once the CUDA Toolkit is installed, download cuDNN v5.1 Library for Linux (note

    Once downloaded, uncompress the files and copy them into the CUDA Toolkit directory (assumed here to be in /usr/local/cuda/):

    $ sudo tar -xvf cudnn-8.0-linux-x64-v5.1-rc.tgz -C /usr/local
    $ sudo tar -xvf cudnn-8.0-* -C /usr/local

    **Step 3. Install and upgrade PIP:**

    @@ -45,7 +45,7 @@ First, clone the TensorFlow source code repository:

    $ git clone https://github.com/tensorflow/tensorflow
    $ cd tensorflow
    $ git reset --hard 70de76e
    $ git reset --hard a23f5d7

    Then run the configure script as follows:

  14. Brainiarc7 revised this gist Mar 25, 2017. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -77,8 +77,12 @@ Output:

    Then call bazel to build the TensorFlow pip package:

    bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
    bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=cuda //tensorflow/tools/pip_package:build_pip_package


    bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

    This will build the package with optimizations for FMA, AVX and SSE.

    And finally install the TensorFlow pip package

  15. Brainiarc7 revised this gist Mar 8, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -84,11 +84,11 @@ And finally install the TensorFlow pip package

    For Python 2.7:

    $ sudo pip install --upgrade /tmp/tensorflow_pkg/tensorflow-0.9.0-*.whl
    $ sudo pip install --upgrade /tmp/tensorflow_pkg/tensorflow-*.whl

    Python 3.4:

    $ sudo pip install --upgrade /tmp/tensorflow_pkg/tensorflow-0.9.0-*.whl
    $ sudo pip install --upgrade /tmp/tensorflow_pkg/tensorflow-*.whl

    Step 5. Upgrade protobuf:

  16. Brainiarc7 created this gist Mar 8, 2017.
    149 changes: 149 additions & 0 deletions build-tensorflow-from-source.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,149 @@
    **Download and Installation Instructions for Tensorflow:**

    TensorFlow is now distributed under an Apache v2 open source license on GitHub.


    **Step 1. Install NVIDIA CUDA:**

    To use TensorFlow with NVIDIA GPUs, the first step is to install the CUDA Toolkit.

    **Step 2. Install NVIDIA cuDNN:**

    Once the CUDA Toolkit is installed, download cuDNN v5.1 Library for Linux (note that you will need to register for the Accelerated Computing Developer Program).

    Once downloaded, uncompress the files and copy them into the CUDA Toolkit directory (assumed here to be in /usr/local/cuda/):

    $ sudo tar -xvf cudnn-8.0-linux-x64-v5.1-rc.tgz -C /usr/local

    **Step 3. Install and upgrade PIP:**

    Here. we are using a custom built Python binary, loaded via the modules system. We will handle its' installation from there.

    TensorFlow itself can be installed using the pip package manager. First, make sure that your system has pip installed and updated:

    $ sudo apt-get install python-pip python-dev
    $ pip install --upgrade pip

    **Step 4. Install Bazel:**

    To build TensorFlow from source, the Bazel build system must first be installed as follows.

    $ sudo apt-get install software-properties-common swig
    $ sudo add-apt-repository ppa:webupd8team/java
    $ sudo apt-get update
    $ sudo apt-get install oracle-java8-installer
    $ echo "deb http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
    $ curl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add -
    $ sudo apt-get update
    $ sudo apt-get install bazel

    **Step 5. Install TensorFlow**

    To obtain the best performance with TensorFlow we recommend building it from source.

    First, clone the TensorFlow source code repository:

    $ git clone https://github.com/tensorflow/tensorflow
    $ cd tensorflow
    $ git reset --hard 70de76e

    Then run the configure script as follows:

    $ ./configure

    Output:

    Please specify the location of python. [Default is /usr/bin/python]: [enter]
    Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] n
    No Google Cloud Platform support will be enabled for TensorFlow
    Do you wish to build TensorFlow with GPU support? [y/N] y
    GPU support will be enabled for TensorFlow
    Please specify which gcc nvcc should use as the host compiler. [Default is /usr/bin/gcc]: [enter]
    Please specify the Cuda SDK version you want to use, e.g. 7.0. [Leave empty to use system default]: 8.0
    Please specify the location where CUDA 8.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: [enter]
    Please specify the Cudnn version you want to use. [Leave empty to use system default]: 5
    Please specify the location where cuDNN 5 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: [enter]
    Please specify a list of comma-separated Cuda compute capabilities you want to build with.
    You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
    Please note that each additional compute capability significantly increases your build time and binary size.
    [Default is: "3.5,5.2"]: 5.2,6.1 [see https://developer.nvidia.com/cuda-gpus]
    Setting up Cuda include
    Setting up Cuda lib64
    Setting up Cuda bin
    Setting up Cuda nvvm
    Setting up CUPTI include
    Setting up CUPTI lib64
    Configuration finished

    Then call bazel to build the TensorFlow pip package:

    bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
    bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

    And finally install the TensorFlow pip package

    For Python 2.7:

    $ sudo pip install --upgrade /tmp/tensorflow_pkg/tensorflow-0.9.0-*.whl

    Python 3.4:

    $ sudo pip install --upgrade /tmp/tensorflow_pkg/tensorflow-0.9.0-*.whl

    Step 5. Upgrade protobuf:

    Upgrade to the latest version of the protobuf package:

    For Python 2.7:

    $ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/protobuf-3.0.0b2.post2-cp27-none-linux_x86_64.whl

    For Python 3.4:

    $ sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/protobuf-3.0.0b2.post2-cp34-none-linux_x86_64.whl

    **Step 6. Test your installation:**

    To test the installation, open an interactive Python shell and import the TensorFlow module:

    $ cd
    $ python

    >>> import tensorflow as tf
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcublas.so locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcudnn.so locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcufft.so locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcuda.so.1 locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcurand.so locally

    With the TensorFlow module imported, the next step to test the installation is to create a TensorFlow Session, which will initialize the available computing devices and provide a means of executing computation graphs:

    >>> sess = tf.Session()

    This command will print out some information on the detected hardware configuration. For example, the output on a system containing a Tesla M40 GPU is:

    >>> sess = tf.Session()
    I tensorflow/core/common_runtime/gpu/gpu_init.cc:102] Found device 0 with properties:
    name: Tesla M40
    major: 5 minor: 2 memoryClockRate (GHz) 1.112
    pciBusID 0000:04:00.0
    Total memory: 11.25GiB
    Free memory: 11.09GiB


    To manually control which devices are visible to TensorFlow, set the `CUDA_VISIBLE_DEVICES` environment variable when launching Python. For example, to force the use of only GPU 0:

    $ CUDA_VISIBLE_DEVICES=0 python

    You should now be able to run a Hello World application:

    >>> hello_world = tf.constant("Hello, TensorFlow!")
    >>> print sess.run(hello_world)
    Hello, TensorFlow!
    >>> print sess.run(tf.constant(123)*tf.constant(456))
    56088