Tensorflow: Cuda compute capability 3.0. The minimum required Cuda capability is 3.5 Tensorflow: Cuda compute capability 3.0. The minimum required Cuda capability is 3.5 python python

Tensorflow: Cuda compute capability 3.0. The minimum required Cuda capability is 3.5


I have installed Tensorflow revision 1.8. It recommends CUDA 9.0. I am using a GTX 650M card which has CUDA compute capability 3.0 and now works like a charm. OS is ubuntu 18.04. Below are detailed steps:

Installing dependencies

I have included ffmpeg and some related packages for my opencv 3.4 compilation, if not required do not installRun the below commands:

sudo apt-get update sudo apt-get dist-upgrade -ysudo apt-get autoremove -ysudo apt-get upgradesudo add-apt-repository ppa:jonathonf/ffmpeg-3 -ysudo apt-get updatesudo apt-get install build-essential -ysudo apt-get install ffmpeg -ysudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -ysudo apt-get install python-dev libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev -ysudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -ysudo apt-get install libxvidcore-dev libx264-dev -ysudo apt-get install unzip qtbase5-dev python-dev python3-dev python-numpy python3-numpy -ysudo apt-get install libopencv-dev libgtk-3-dev libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev >libjasper-dev -ysudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev -ysudo apt-get install libv4l-dev libtbb-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev -ysudo apt-get install libvorbis-dev libxvidcore-dev v4l-utils vtk6 -ysudo apt-get install liblapacke-dev libopenblas-dev libgdal-dev checkinstall -ysudo apt-get install libgtk-3-dev -ysudo apt-get install libatlas-base-dev gfortran -ysudo apt-get install qt-sdk -ysudo apt-get install python2.7-dev python3.5-dev python-tk -ysudo apt-get install cython libgflags-dev -ysudo apt-get install tesseract-ocr -ysudo apt-get install tesseract-ocr-eng -y sudo apt-get install tesseract-ocr-ell -ysudo apt-get install gstreamer1.0-python3-plugin-loader -ysudo apt-get install libdc1394-22-dev -ysudo apt-get install openjdk-8-jdksudo apt-get install pkg-config zip g++-6 gcc-6 zlib1g-dev unzip  gitsudo wget https://bootstrap.pypa.io/get-pip.pysudo python get-pip.pysudo pip install -U pipsudo pip install -U numpysudo pip install -U pandassudo pip install -U wheelsudo pip install -U six

Installing the nvidia driver

Run the below commands:

sudo add-apt-repository ppa:graphics-drivers/ppasudo apt-get updatesudo apt-get install nvidia-390 -y

Reboot and run the below command and it should give you details as described in the image below:enter image description here

gcc-6 and g++-6 checks.

gcc-6 and g++-6 is required for CUDA 9.0, run the below commands:

cd /usr/bin sudo rm -rf gcc gcc-ar gcc-nm gcc-ranlib g++sudo ln -s gcc-6 gccsudo ln -s gcc-ar-6 gcc-arsudo ln -s gcc-nm-6 gcc-nmsudo ln -s gcc-ranlib-6 gcc-ranlibsudo ln -s g++-6 g++

Installing CUDA 9.0

Go to https://developer.nvidia.com/cuda-90-download-archive. Select options: Linux->x86_64->Ubuntu->17.04->deb(local).Download the main file and the two patches.Run below commands:

sudo dpkg -i cuda-repo-ubuntu1704-9-0-local_9.0.176-1_amd64.debsudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pubsudo apt-get updatesudo apt-get install cuda

Navigate to the first patch on your PC and double click it, it will automatically execute, follow same for second patch.

Add below to lines to your ~/.bashrc file and give it a reboot:

export PATH=/usr/local/cuda-9.0/bin${PATH:+:$PATH}}export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Installing cudnn 7.1.4 for CUDA 9.0

Download the tar file from https://developer.nvidia.com/cudnn and extract it to your Downloads folderDownload requires a nvidia developed login, free sign-upRun the below commands:

cd ~/Downloads/cudnn-9.0-linux-x64-v7.1/cudasudo cp include/* /usr/local/cuda/include/sudo cp lib64/libcudnn.so.7.1.4 lib64/libcudnn_static.a /usr/local/cuda/lib64/cd /usr/lib/x86_64-linux-gnusudo ln -s libcudnn.so.7.1.4 libcudnn.so.7sudo ln -s libcudnn.so.7 libcudnn.so

Installing NCCL 2.2.12 for CUDA 9.0

Download the tar file from https://developer.nvidia.com/nccl and extract it to your Downloads folderDownload requires a nvidia developed login, free sign-upRun the below commands:

sudo mkdir -p /usr/local/cuda/nccl/lib /usr/local/cuda/nccl/includecd ~/Downloads/nccl-repo-ubuntu1604-2.2.12-ga-cuda9.0_1-1_amd64/sudo cp *.txt /usr/local/cuda/ncclsudo cp include/*.h /usr/include/sudo cp lib/libnccl.so.2.1.15 lib/libnccl_static.a /usr/lib/x86_64-linux-gnu/sudo ln -s /usr/include/nccl.h /usr/local/cuda/nccl/include/nccl.hcd /usr/lib/x86_64-linux-gnusudo ln -s libnccl.so.2.1.15 libnccl.so.2sudo ln -s libnccl.so.2 libnccl.sofor i in libnccl*; do sudo ln -s /usr/lib/x86_64-linux-gnu/$i /usr/local/cuda/nccl/lib/$i; done

Install Bazel (the recomended manual installation of bazel worked, for reference: https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntu)

Download "bazel-0.13.1-installer-darwin-x86_64.sh" from https://github.com/bazelbuild/bazel/releasesRun the below commands:

chmod +x bazel-0.13.1-installer-darwin-x86_64.sh./bazel-0.13.1-installer-darwin-x86_64.sh --userexport PATH="$PATH:$HOME/bin"

Compiling Tensorflow

We will compile with CUDA, with XLA JIT (oh yeah) and jemalloc as malloc support. So we enter yes for these things.Run the below command and answer to the queries as described for running configuration

git clone https://github.com/tensorflow/tensorflow git checkout r1.8./configureYou have bazel 0.13.0 installed.Please specify the location of python. [Default is /usr/bin/python]:Please input the desired Python library path to use.  Default is [/usr/local/lib/python2.7/dist-packages]Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]: yjemalloc as malloc support will be enabled for TensorFlow.Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: nNo Google Cloud Platform support will be enabled for TensorFlow.Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: nNo Hadoop File System support will be enabled for TensorFlow.Do you wish to build TensorFlow with Amazon S3 File System support? [Y/n]: nNo Amazon S3 File System support will be enabled for TensorFlow.Do you wish to build TensorFlow with Apache Kafka Platform support? [Y/n]: nNo Apache Kafka Platform support will be enabled for TensorFlow.Do you wish to build TensorFlow with XLA JIT support? [y/N]: yXLA JIT support will be enabled for TensorFlow.Do you wish to build TensorFlow with GDR support? [y/N]: nNo GDR support will be enabled for TensorFlow.Do you wish to build TensorFlow with VERBS support? [y/N]: nNo VERBS support will be enabled for TensorFlow.Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: nNo OpenCL SYCL support will be enabled for TensorFlow.Do you wish to build TensorFlow with CUDA support? [y/N]: yCUDA support will be enabled for TensorFlow.Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to default to CUDA 9.0]:Please specify the location where CUDA 9.1 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7.0]: 7.1.4Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:Do you wish to build TensorFlow with TensorRT support? [y/N]: nNo TensorRT support will be enabled for TensorFlow.Please specify the NCCL version you want to use. [Leave empty to default to NCCL 1.3]: 2.2.12Please specify the location where NCCL 2 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:/usr/local/cuda/ncclPlease 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.0]Do you want to use clang as CUDA compiler? [y/N]: nnvcc will be used as CUDA compiler.Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/x86_64-linux-gnu-gcc-7]: /usr/bin/gcc-6Do you wish to build TensorFlow with MPI support? [y/N]: nNo MPI support will be enabled for TensorFlow.Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: nNot configuring the WORKSPACE for Android builds.Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See tools/bazel.rc for more details. --config=mkl          # Build with MKL support. --config=monolithic   # Config for mostly static monolithic build.Configuration finished

Now to compile tensorflow, run below command, this is super RAM consuming and will take time. You can remove "--local_resources 2048,.5,1.0" from below line if you have a lot of RAM or this will work on 2 GB of RAM

bazel build --config=opt --config=cuda --local_resources 2048,.5,1.0 //tensorflow/tools/pip_package:build_pip_package

Once the compilation is completed you will have thing appear as per the image below confirming it was a successenter image description here

Build the wheel file, run below:

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

Install the generated wheel file using pip

sudo pip install /tmp/tensorflow_pkg/tensorflow*.whl

To explore on the devices now you can run tensorflow, below image is the showcase on ipython terminal

enter image description here


In anaconda, tensorflow-gpu=1.12 with cudatoolkit=9.0 is compatible with gpu which has 3.0 compute capability. Here is the ccommand for creating new environment, and installation of necessary libraries for 3.0 gpus.

conda create -n tf-gpuconda activate tf-gpuconda install tensorflow-gpu=1.12conda install cudatoolkit=9.0

then you can try it by followings.

>pythonimport tensorflow as tftf.Session()

Here is my output

name: GeForce GT 650M major: 3 minor: 0 memoryClockRate(GHz): 0.95 pciBusID: 0000:01:00.0 totalMemory: 3.94GiB freeMemory: 3.26GiB 2019-12-09 13:26:11.753591: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0 2019-12-09 13:26:12.050152: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix: 2019-12-09 13:26:12.050199: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988] 0 2019-12-09 13:26:12.050222: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0: N 2019-12-09 13:26:12.050481: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 2989 MB memory) -> physical GPU (device: 0, name: GeForce GT 650M, pci bus id: 0000:01:00.0, compute capability: 3.0)

Enjoy !


@Taako, so sorry for this late response. I did not save the wheel file of the compilation displayed above. However, here is a new one for tensorflow 1.9. Hope this helps you enough. Kindly ensure of the below details used for the build.

Tensorflow: 1.9CUDA Toolkit: 9.2CUDNN: 7.1.4NCCL: 2.2.13

Below is the link to the wheel file:wheel file