Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On GPU-Accelerated Computer Vision with OpenCV and CUDA

You're reading from   Hands-On GPU-Accelerated Computer Vision with OpenCV and CUDA Effective techniques for processing complex image data in real time using GPUs

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher Packt
ISBN-13 9781789348293
Length 380 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Bhaumik Vaidya Bhaumik Vaidya
Author Profile Icon Bhaumik Vaidya
Bhaumik Vaidya
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Introducing CUDA and Getting Started with CUDA 2. Parallel Programming using CUDA C FREE CHAPTER 3. Threads, Synchronization, and Memory 4. Advanced Concepts in CUDA 5. Getting Started with OpenCV with CUDA Support 6. Basic Computer Vision Operations Using OpenCV and CUDA 7. Object Detection and Tracking Using OpenCV and CUDA 8. Introduction to the Jetson TX1 Development Board and Installing OpenCV on Jetson TX1 9. Deploying Computer Vision Applications on Jetson TX1 10. Getting Started with PyCUDA 11. Working with PyCUDA 12. Basic Computer Vision Applications Using PyCUDA 13. Assessments 14. Other Books You May Enjoy

Installing the CUDA toolkit on all operating systems

This section covers instructions on how to install CUDA on all supported platforms. It also describes steps to verify installation. While installing CUDA, you can choose between a network installer and an offline local installer. A network installer has a lower initial download size, but it needs an internet connection while installing. A local offline installer has a higher initial download size. The steps discussed in this book are for local installation. A CUDA toolkit can be downloaded for Windows, Linux, and macOS for both 32-bit and 64-bit architecture from the following link: https://developer.nvidia.com/cuda-downloads.

After downloading the installer, refer to the following steps for your particular operating system. CUDAx.x is used as notation in the steps, where x.x indicates the version of CUDA that you have downloaded.

Windows

This section covers the steps to install CUDA on Windows, which are as follows:

  1. Double-click on the installer. It will ask you to select the folder where temporary installation files will be extracted. Select the folder of your choice. It is recommended to keep this as the default.
  2. Then, the installer will check for system compatibility. If your system is compatible, you can follow the on screen prompt to install CUDA. You can choose between an express installation (default) and a custom installation. A custom installation allows you to choose which features of CUDA to install. It is recommended to select the express default installation.
  3. The installer will also install CUDA sample programs and the CUDA Visual Studio integration.
Please make sure you have Visual Studio installed before running this installer.

To confirm that the installation is successful, the following aspects should be ensured:

  1. All the CUDA samples will be located at C:\ProgramData\NVIDIA Corporation\CUDA Samples\vx.x if you have chosen the default path for installation.
  2. To check installation, you can run any project.
  3. We are using the device query project located at C:\ProgramData\NVIDIA Corporation\CUDA Samples\vx.x\1_Utilities\deviceQuery.
  4. Double-click on the *.sln file of your Visual Studio edition. It will open this project in Visual Studio.
  5. Then you can click on the local Windows debugger in Visual Studio. If the build is successful and the following output is displayed, then the installation is complete:

Linux

This section covers the steps to install CUDA on Linux distributions. In this section, the installation of CUDA in Ubuntu, which is a popular Linux distribution, is discussed using distribution-specific packages or using the apt-get command (which is specific to Ubuntu).

The steps to install CUDA using the *.deb installer downloaded from the CUDA website are as follows:

  1. Open Terminal and run the dpkg command, which is used to install packages in Debian-based systems:
sudo dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb
  1. Install the CUDA public GPG key using the following command:
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
  1. Then, update the apt repository cache using the following command:
sudo apt-get update
  1. Then you can install CUDA using the following command:
sudo apt-get install cuda
  1. Include the CUDA installation path in the PATH environment variable using the following command:
If you have not installed CUDA at default locations, you need to change the path to point at your installation location.
  export PATH=/usr/local/cuda-x.x/bin${PATH:+:${PATH}}
  1. Set the LD_LIBRARY_PATH environment variable:
export LD_LIBRARY_PATH=/usr/local/cuda-x.x/lib64\
${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

You can also install the CUDA toolkit by using the apt-get package manager, available with Ubuntu OS. You can run the following command in Terminal:

sudo apt-get install nvidia-cuda-toolkit

To check whether the CUDA GPU compiler has been installed, you can run the nvcc -V command from Terminal. It calls the GCC compiler for C code and the NVIDIA PTX compiler for the CUDA code.

You can install the NVIDIA Nsight Eclipse plugin, which will give the GUI Integrated Development Environment for executing CUDA programs, using the following command:

sudo apt install nvidia-nsight

After installation, you can run the deviceQuery project located at ~/NVIDIA_CUDA-x.x_Samples. If the CUDA toolkit is installed and configured correctly, the output for deviceQuery should look similar to the following:

Mac

This section covers steps to install CUDA on macOS. It needs the *.dmg installer downloaded from the CUDA website. The steps to install after downloading the installer are as follows:

  1. Launch the installer and follow the onscreen prompt to complete the installation. It will install all prerequisites, CUDA, toolkit, and CUDA samples.
  1. Then, you need to set environment variables to point at CUDA installation using the following commands:
If you have not installed CUDA at the default locations, you need to change the path to point at your installation location.
  export PATH=/Developer/NVIDIA/CUDA-x.x/bin${PATH:+:${PATH}}
export DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-x.x/lib\
${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
  1. Run the script: cuda-install-samples-x.x.sh. It will install CUDA samples with write permissions.
  2. After it has completed, you can go to bin/x86_64/darwin/release and run the deviceQuery project. If the CUDA toolkit is installed and configured correctly, it will display your GPU's device properties.
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image