Download and install the latest stable version. In my case:
debian-8.6.0-amd64-netinst.iso
Kernel version: 3.16.0-4-amd64
I did it by creating a bootable USB stick using UNetBootin. Install debian step by step. Leave enough space for your root
file system. The install some packages:
apt-get update
apt-get install sudo aptitude screen mc git netselect-apt htop emacs-nox tree ncdu gfortran deborphan
apt-get install build-essential linux-headers-$(uname -r)
###Installing CUDA
First read the official installation guide. Check the GPU cards are known to the system:
lspci | grep -i nvidia
Check your linux and GCC version:
uname -m && cat /etc/*release
gcc --version
Download the latest CUDA Toolkit and run it as root:
sudo sh cuda_8.0.44_linux-run
You may check the md5
checksum before running. During the installation, you may tell the script to install the examples in your home directory, not the one of root
. You may also need to stop the display manager, which also stops X
:
sudo /etc/init.d/lightdm stop
and then start it again after finishing the installation. At some point the installer asks you to overwrite the xconfig
. I usually say no in order to avoid messing up with the actual graphics driver that shows the content on the screen (not the GPU).
If the installation is done correctly, then the following messages appear:
===========
= Summary =
===========
Driver: Installed
Toolkit: Installed in /usr/local/cuda-8.0
Samples: Installed in /home/User, but missing recommended libraries
Please make sure that
- PATH includes /usr/local/cuda-8.0/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin
To uninstall the NVIDIA Driver, run nvidia-uninstall
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.
Logfile is /tmp/cuda_install_1625.log
In order to make sure the paths are set, do as described in the message, by adding the paths or running the ldcondig (also described here). Just add to the end of the system wide profile /etc/profile
or your local .profile
:
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib
export CUDA_HOME=/usr/local/cuda
or run the following once:
ldconfig /usr/local/cuda/lib64
or alternatively:
sudo bash -c "echo /usr/local/cuda/lib64/ > /etc/ld.so.conf.d/cuda.conf"
sudo ldconfig
Now check nvidia:
lsmod | grep nv
Check the installation by going to the example directory and compile the examples:
cd NVIDIA_CUDA-8.0_Samples
make
If the compilation goes well, you may run one of the examples, like:
./NVIDIA_CUDA-8.0_Samples/0_Simple/simplePrintf/simplePrintf
Alternatively, you may download and run a CUDA Hello World program.
Before updating CUDA, then you first need to unload NVIDIA modules using:
sudo rmmod nvidia
Install python:
aptitude install python3 python3-dev python3-venv python3-pip libfreetype6 libpng3 libblas-dev liblapack-dev
Update pip
itself:
python3 -m pip install --upgrade pip
Install the Scipy/Numpy stack:
pip3 install numpy scipy matplotlib ipython jupyter pandas sympy nose
Other packages:
sudo pip3 install pyzmq prettyplotlib beautifulsoup4 Flask fortranformat
Now you can install pycuda
, remember you should have the library path (where cuda.h
is) exported also as root:
sudo PATH=/usr/local/cuda/bin:$PATH D_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib pip install pycuda
Apparently pip
has its own shell so it needs the above path is needed.
Test PyCUDA:
python3 -c 'import pycuda.driver as cuda'
Sometimes there is an error, you need to:
sudo ldconfig /usr/local/cuda/lib64
If there are no errors, then you have installed CUDA and PyCUDA successfully. Alternatively you may run the demo.py from the PyCUDA example directory.
Additional to the CUDA drivers, you need to have the right cuDNN library installed. Basically you have to just unpack and copy the cuDNN files to the CUDA installtion path.
Finally you install tensorflow:
sudo pip install tensorflow-gpu tflearn h5py
There is a very good documentation on the TensorFlow website. There you find a simpe hello world program to check your installation.