CUDA on BackTrack 5

From BackTrack Linux
Jump to: navigation, search

This guide is a work in progress, and is meant to help those needing to get CUDA working on their BackTrack machines.

Start by preparing your kernel sources for the Nvidia driver installation:

root@bt:~# prepare-kernel-sources
root@bt:~# cd /usr/src/linux
root@bt:~# cp -rf include/generated/* include/linux/

Download Nvidia drivers according to your CPU architecture:

Make sure you are not in an X session (log out to console), and run the Nvidia driver installer.

Next, download the CUDA toolkit, according to your CPU architecture:

Ideally you should install the CUDA toolkit to /opt. this guide assumes this installation path. Configure your environment variables so that the nvcc command works. You can do this by appending the following lines in your /root/.bashrc file:

PATH=$PATH:/opt/cuda/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/cuda/lib
export PATH
export LD_LIBRARY_PATH

Then run:

root@bt:~# source /root/.bashrc
root@bt:~# ldconfig

The whole purpose of this was to get nvcc compiler installed. You can check that everything is set up correctly:

root@bt:~# which nvcc
/opt/cuda/bin/nvcc
root@bt:~# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2011 NVIDIA Corporation
Built on Sun_Mar_20_16:45:27_PDT_2011
Cuda compilation tools, release 4.0, V0.2.1221
root@bt:~# 


Now that the Nvidia driver and CUDA toolkit are installed, we can test their functionality with a GPU powered tool such as pyrit.

root@bt:~# svn checkout http://pyrit.googlecode.com/svn/trunk/ pyrit
root@bt:~# cd pyrit/pyrit && python setup.py build && python setup.py install
root@bt:~# cd ../../
root@bt:~# cd pyrit/cpyrit_cuda && python setup.py build && python setup.py install

Run a benchmark to see that everything works as expected:

root@bt:~# pyrit benchmark
Pyrit 0.4.1-dev (svn r308) (C) 2008-2011 Lukas Lueg http://pyrit.googlecode.com
This code is distributed under the GNU General Public License v3+

Running benchmark (63787.8 PMKs/s)... \ 

Computed 63787.82 PMKs/s total.
#1: 'CUDA-Device #1 'GeForce GTX 295: 11558.7 PMKs/s (RTT 3.0)
#2: 'CUDA-Device #2 'GeForce GTX 295: 10912.5 PMKs/s (RTT 2.9)
#3: 'CUDA-Device #3 'GeForce GTX 295: 10632.1 PMKs/s (RTT 3.0)
#4: 'CUDA-Device #4 'GeForce GTX 295: 11654.7 PMKs/s (RTT 2.9)
#5: 'CUDA-Device #5 'GeForce GTX 295: 10868.9 PMKs/s (RTT 2.9)
#6: 'CUDA-Device #6 'GeForce GTX 295: 10322.8 PMKs/s (RTT 3.0)
#7: 'CPU-Core (SSE2)': 500.7 PMKs/s (RTT 2.7)
#8: 'CPU-Core (SSE2)': 508.9 PMKs/s (RTT 2.8) 

Success! We can now use CUDA powered tools from within BackTrack.