Installing Tensorflow on ArchLinux

Based on this guide1

Installing packages

Important note: You should start by installing Bumblebee and making sure it works: (Arch Linux Wiki Bumblebee

My package versions:

nvidia 396.24-7
python-numpy 1.14.3-1
swig 3.0.12-1
cudnn 7.1.4-1
cuda 9.0.176-4
python 3.6.5-3
python-virtualenv 15.1.0-3
pacman -S nvidia python-numpy swig cudnn cuda python3 python-virtualenv

Then reboot. This should install all necessary packages.

In my case I also had to downgrade CUDA to version 9.x. I used this AUR Package.

sudo downgrade cuda

(and select the highest version 9.0.x)


My PIP packages:


Next create a new Python3 virtualenv.

virtualenv -p python3 tensorflow-env
source tensorflow/bin/activate

We’ll need to update PIP and install the latest tensorflow-gpu package

pip install --upgrade pip

pip install --upgrade tensorflow-gpu

Validating our installation

Based on this guide2

To validate our installation we’ll use the following Python file

import tensorflow as tf

hello = tf.constant('Hello, TensorFlow!')

sess = tf.Session()


I saved it to, and ran it using the command:

optirun python

(optirun is required to turn on the GPU)

The output should be something similar to this:

2018-06-05 09:44:13.468281: I tensorflow/core/platform/] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-06-05 09:44:13.545180: I tensorflow/stream_executor/cuda/] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-06-05 09:44:13.545552: I tensorflow/core/common_runtime/gpu/] Found device 0 with properties:
name: GeForce GTX 1050 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.62
pciBusID: 0000:01:00.0
totalMemory: 3.95GiB freeMemory: 3.89GiB
2018-06-05 09:44:13.545566: I tensorflow/core/common_runtime/gpu/] Adding visible gpu devices: 0
2018-06-05 09:44:13.733866: I tensorflow/core/common_runtime/gpu/] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-06-05 09:44:13.733913: I tensorflow/core/common_runtime/gpu/]      0
2018-06-05 09:44:13.733919: I tensorflow/core/common_runtime/gpu/] 0:   N
2018-06-05 09:44:13.734069: I tensorflow/core/common_runtime/gpu/] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3623 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
b'Hello, TensorFlow!'

If you run it without optirun it will look like this (does not detect GPU):

2018-06-05 09:11:15.197152: I tensorflow/core/platform/] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-06-05 09:11:15.375056: E tensorflow/stream_executor/cuda/] failed call to cuInit: CUDA_ERROR_UNKNOWN
2018-06-05 09:11:15.375095: I tensorflow/stream_executor/cuda/] kernel driver does not appear to be running on this host (saber): /proc/driver/nvidia/version does not exist
b'Hello, TensorFlow!'