Tensorflow_GPU version 1.12 UBUNTU 18.04 for old CPU with no AVX support.
Build a TensorFlow pip package from source and install it on Ubuntu Linux and macOS.
Install Software requirements : link _ https://www.tensorflow.org/install/gpu
The following NVIDIA® software must be installed on your system:
- NVIDIA® GPU drivers —CUDA 9.0 requires 384.x or higher. ( SHOULD BE VERSION 9.0)
- CUDA® Toolkit —TensorFlow supports CUDA 9.0.
- CUPTI ships with the CUDA Toolkit.
- cuDNN SDK (>= 7.2)
- (Optional) NCCL 2.2 for multiple GPU support.
- (Optional) TensorRT 4.0 to improve latency and throughput for inference on some models.
- sudo apt install python-dev python-pip # or python3-dev python3-pip
Install the TensorFlow pip package dependencies (if using a virtual environment, omit the --user argument):
- pip install -U --user pip six numpy wheel mock
- pip install -U --user keras_applications==1.0.6 --no-deps
- pip install -U --user keras_preprocessing==1.0.5 --no-deps
- sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python
- chmod +x bazel-0.19.2-installer-linux-x86_64.sh
- ./bazel-0.19.2-installer-linux-x86_64.sh --user
- export PATH="$PATH:$HOME/bin"
- sudo apt-get install openjdk-8-jdk
- echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
- curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
- sudo apt-get update && sudo apt-get install bazel
- git clone https://github.com/tensorflow/tensorflow.git
- cd tensorflow
- git checkout branch_name # r1.9, r1.10, etc. (for example, git checkout r1.12 for tensorflow version 1.12)
- ./configure *** (I hoose No for all except for those say about CUDA)
- Using bazel version of bazel 0.19.0, Added the content of file "/home//tensorflow/tools/bazel.rc" on top of (hidden) file "/home//tensorflow/.tf_configure.bazelrc".
- bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
- ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /mnt # create package
- nautilus /mnt
- pip3 install <name_of_file>.whl
for example: pip3 install tensorflow-1.12.0-cp36-cp36m-linux_x86_64.whl p/s: replace pip3 by pip for python2.
in terminal:
- python3
- import tensorflow as tf
- print(tf.contrib.eager.num_gpus())
output:
- yyyy-mm-dd hh:mm:ss.nnnnn: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 2212 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060 3GB, pci bus id: 0000:01:00.0, compute capability: 6.1)