Install CUDA for computer with NVIDIA graphic card
Last updated
Last updated
INSTALL CUDA ON YOUR PC (Ubuntu Operating System):
Go to the website https://developer.nvidia.com/cuda-downloads and then select the target platform depending on the type of operating system you are using and also the architecture of your pc. Below is a small snapshot of the target platform I used.
Once you have downloaded the correct file you need to do the following steps using the ubuntu terminal:
sudo dpkg -i cuda-repo-ubuntu1604-10-1-local-10.1.105-418.39_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-1-local-10.1.105-418.39/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda
After the installation you need to include Cuda in your PATH variable and you also need to include the cuda library in the LD_LIBRARY_PATH. This can be done by including the following two line in your .bashrc file.
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH(for 64bit system) and export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib:$LD_LIBRARY_PATH(for 32but system).
export PATH=/usr/local/cuda-10.1/bin:$PATH
Once you have installed CUDA you need to install the Cuda samples by running the following command, where <target_path> is the location where to install the samples:
<target_path>can be /home/auv/Desktop/cudasamples
In order to build the cuda samples go to the target directory where you installed the samples in the previous step. Then run the following command:
make
Once the samples are build you need to run the DeviceQuery sample which gives the properties of the CUDA system present in your CPU. First you need to go to the folder (in my case)
/home/ninad/NVIDIA_CUDA-8.0_Samples/bin/x86_64/linux/release
and then type the command ./deviceQuery to run the sample. You will get an output similar to the picture below:
The most important thing is the Cuda Capability Major/Minor number which is highlighted in the picture above. You need this in order to compile opencv with cuda library.
In order to compile opencv with cuda you need to to type in the following two commands in the build directory of opencv:
cmake -DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=ON
-DCUDA_ARCH_BIN="5.2" -DCMAKE_INSTALL_PREFIX=/usr/local -DCUDA_ARCH_PTX="5.2" -DCUDA_GENERATION="" ..
5.2 is the Cuda Capability Major/Minorversionnumber
make -j8
INSTALLATION in auv7530
auv@auv7530:~/Desktop/cudasamples/NVIDIA_CUDA-10.1_Samples/bin/x86_64/linux/release$ ./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "Quadro P3200"
CUDA Driver Version / Runtime Version 10.1 / 10.1
CUDA Capability Major/Minor version number: 6.1
Total amount of global memory: 6078 MBytes (6373572608 bytes)
(14) Multiprocessors, (128) CUDA Cores/MP: 1792 CUDA Cores
GPU Max Clock rate: 1240 MHz (1.24 GHz)
Memory Clock rate: 3505 Mhz
Memory Bus Width: 192-bit
L2 Cache Size: 1572864 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 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 2 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 supports Compute Preemption: Yes
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: 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 = 10.1, CUDA Runtime Version = 10.1, NumDevs = 1
Result = PASS
*****
For checking which CUDA version is installed