Notes and links to install TensorFlow GPU
If pip 3 -U install tensorflow-gpu
did not work and you need compile TensorFlow GPU.
I had this messege: The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine.
If just want to download compiled version, go to Compiled python wheels
section
- Check versions of OS, CUDA capability of GPU, python
- Install nVidia driver
- Install CUDA
- Install cuDNN
- Compile TensorFlow GPU
- Install TensorFlow and some other useful packages
- Test installation
- Compiled python wheels
- Other useful links
GUI: Settings > Details > Ubuntu 18.04LTS
Bash: $ lsb_release -a
# See Description line
Find in table here: https://en.wikipedia.org/wiki/CUDA#GPUs_supported
$ python3 --version # e.g. Python 3.6.8
Check versions used for prebuilt packages: https://www.tensorflow.org/install/source#linux
For example, for TF 12
Version | Python version | Compiler | Build tools | cuDNN | CUDA |
---|---|---|---|---|---|
tensorflow_gpu-1.12.0 | 2.7, 3.3-3.6 | GCC 4.8 | Bazel 0.15.0 | 7 | 9 |
nvidia-390
is OK for CUDA 9.
Google for instructions.
CUDA Toolkit 9.0 for Ubuntu 18.04 is not available, but version for 17.04 should work fine.
- visit & download CUDA 9.0: official (recommended) | mirror
- base installer must suffice, read instructions there
cuDNN 7 (v7.0.5)
- download cuDNN 7 (v7.0.5): origina page (need account, recommended) | mirror
- download appropriate tar archive (
cuDNN vX.X.X
Library forCUDA Y.Y
)
$ tar -xzvf cudnn-9.0-linux-x64-v7.tgz
$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
installation instructions taken from here
- after installing driver, CUDA and cuDNN, to check whether installation is good, run
$ nvidia-smi
Table with info about GPU usage should be shown.
- build TF from source as in instructions here
- Note: Used Bazel version 0.19.2: official repo (recommended) | mirror
If done all above TensorFlow should have already been installed.
Additional packages you may like to install:
- keras
- numpy
- scikit-learn
- matplotlib
To test whether TF uses GPU, run in Terminal:
$ watch -n1 nvidia-smi
And run any example for model training.
TF Version | Python version | Compiler | Build tools | cuDNN | CUDA | Links |
---|---|---|---|---|---|---|
1.12.0 GPU | 3.6.8 | GCC 6.5 | Bazel 0.19.2 | 7.0.5 | 9 | download wheel |
- TF 1.12.0, CPU/GPU, CUDA 9.0, CuDNN 7.4, Python 3.5, Ubuntu 16.04, Skylake, -AVX, +SSE4 #99
- Prebuilt binaries do not work with CPUs that do not have AVX instruction sets. #19584
- My CPU doesn't support Tensorflow AVX instructions #34
- TensorFlow - Build from source
- Wikipedia > CUDA > GPUs supported
- CUDA Toolkit 9.0 Downloads
- Bazel 0.19.2
- cuDNN 7 Manual
- cuDNN Archive
If you have any corrections, recommendations or editions, please create issues