Getting Started with CUDA


Interesting and challenging as I would define it. So get ready for a ride. If you are a applications developer, switch off now. This is a system programmer post, and someone who enjoys toying with the command prompt :).

To get started with CUDA, first thing you need is a 64bit OS. Without that CUDA wont work.

Once you have a 64 bit OS, goto, and follow the instructions. DONT download the run file, download the dpkg file for the installation. The run file is stupid and useless. Takes for ever to run and gets no results. You may also end up screwing up your OS.

So I ran the following

sudo dpkg -i cuda-repo-ubuntu1504-7-5-local_7.5-18_amd64.deb
sudo apt-get update
sudo apt-get install cuda
sudo apt-get install nvidia-cuda-toolkit
sudo apt-get install cuda-drivers
sudo apt-get install nvidia-nsight
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib:$LD_LIBRARY_PATH
cd /usr/local/cuda-7.5/
sh /home/<username>/development
sudo apt-get install nvidia-352
cd /home/<username>/development/<cuda samples folder>/

To check your installation

lspci | grep -i nvidia 
01:00.0 VGA compatible controller: NVIDIA Corporation GK110 [GeForce GTX 780] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GK110 HDMI Audio (rev a1)
sudo dpkg --list | grep nvidia
 ii nvidia-352 352.63-0ubuntu0.15.04.1 amd64 NVIDIA binary driver - version 352.63
 ii nvidia-352-dev 352.63-0ubuntu0.15.04.1 amd64 NVIDIA binary Xorg driver development files
 ii nvidia-352-uvm 352.39-0ubuntu1 amd64 Transitional package for nvidia-352
 ii nvidia-cuda-dev 6.5.14-1 amd64 NVIDIA CUDA development files
 ii nvidia-cuda-doc 6.5.14-1 all NVIDIA CUDA and OpenCL documentation
 ii nvidia-cuda-gdb 6.5.14-1 amd64 NVIDIA CUDA Debugger (GDB)
 ii nvidia-cuda-toolkit 6.5.14-1 amd64 NVIDIA CUDA development toolkit
 ii nvidia-modprobe 352.39-0ubuntu1 amd64 Load the NVIDIA kernel driver and create device files
 ii nvidia-nsight 6.5.14-1 amd64 NVIDIA Nsight Eclipse Edition
 ii nvidia-opencl-dev:amd64 6.5.14-1 amd64 NVIDIA OpenCL development files
 ii nvidia-opencl-icd-352 352.63-0ubuntu0.15.04.1 amd64 NVIDIA OpenCL ICDThis should
 ii nvidia-prime 0.8.1 amd64 Tools to enable NVIDIA's Prime
 ii nvidia-profiler 6.5.14-1 amd64 NVIDIA Profiler for CUDA and OpenCL
 ii nvidia-settings 352.39-0ubuntu1 amd64 Tool for configuring the NVIDIA graphics driver
 ii nvidia-visual-profiler 6.5.14-1 amd64 NVIDIA Visual Profiler for CUDA and OpenCL
cd ~/development/<cuda samples folder>

If this displays an error than run

sudo apt-get purge $(dpkg -l | awk '$2~/nvidia/ {print $2}') sudo add-apt-repository ppa:graphics-drivers/ppa 
sudo apt-get update 
sudo apt-get install cuda 
sudo apt-get install nvidia-cuda-toolkit 
sudo apt-get install cuda-drivers 
sudo apt-get install nvidia-nsight

Ideally ./deviceQuery should display

./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "GeForce GTX 780"
 CUDA Driver Version / Runtime Version 7.5 / 7.5
 CUDA Capability Major/Minor version number: 3.5
 Total amount of global memory: 3072 MBytes (3221028864 bytes)
 (12) Multiprocessors, (192) CUDA Cores/MP: 2304 CUDA Cores
 GPU Max Clock rate: 902 MHz (0.90 GHz)
 Memory Clock rate: 3004 Mhz
 Memory Bus Width: 384-bit
 L2 Cache Size: 1572864 bytes
 Maximum Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
 Maximum Layered 1D Texture Size, (num) layers 1D=(16384), 2048 layers
 Maximum Layered 2D Texture Size, (num) layers 2D=(16384, 16384), 2048 layers
 Total amount of constant memory: 65536 bytes
 Total amount of shared memory per block: 49152 bytes
 Total number of registers available per block: 65536
 Warp size: 32
 Maximum number of threads per multiprocessor: 2048
 Maximum number of threads per block: 1024
 Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
 Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
 Maximum memory pitch: 2147483647 bytes
 Texture alignment: 512 bytes
 Concurrent copy and kernel execution: Yes with 1 copy engine(s)
 Run time limit on kernels: Yes
 Integrated GPU sharing Host Memory: No
 Support host page-locked memory mapping: Yes
 Alignment requirement for Surfaces: Yes
 Device has ECC support: Disabled
 Device supports Unified Addressing (UVA): Yes
 Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
 Compute Mode:
 < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 7.5, CUDA Runtime Version = 7.5, NumDevs = 1, Device0 = GeForce GTX 780
 Result = PASS