CUDA - Installation

In this chapter, we will learn how to install CUDA.
For installing the CUDA toolkit on Windows, you’ll need −
A CUDA enabled Nvidia GPU.
A supported version of Microsoft Windows.
A supported version of Visual Studio.
The latest CUDA toolkit.
Note that natively, CUDA allows only 64b applications. That is, you cannot develop 32b CUDA applications natively (exception: they can be developed only on the GeForce series GPUs). 32b applications can be developed on x86_64 using the cross-development capabilities of the CUDA toolkit. For compiling CUDA programs to 32b, follow these steps −
Step 1 − Add <installpath>\bin to your path.
Step 2 − Add -m32 to your nvcc options.
Step 3 − Link with the 32-bit libs in <installpath>\lib (instead of <installpath>\lib64).
You can download the latest CUDA toolkit from here.
As can be seen from the above tables, support for x86_32 is limited. Presently, only the GeForce series is supported for 32b CUDA applications. If you have a supported version of Windows and Visual Studio, then proceed. Otherwise, first install the required software.
Verifying if your system has a CUDA capable GPU − Open a RUN window and run the command  − control /name Microsoft.DeviceManager, and verify from the given information. If you do not have a CUDA capable GPU, or a GPU, then halt.
In this section, we will see how to install the latest CUDA toolkit.
Step 1 − Visit − https://developer.nvidia.com and select the desired operating system.
Step 2 − Select the type of installation that you would like to perform. The network installer will initially be a very small executable, which will download the required files when run. The standalone installer will download each required file at once and won’t require an Internet connection later to install.
Step 3 − Download the base installer.
The CUDA toolkit will also install the required GPU drivers, along with the required libraries and header files to develop CUDA applications. It will also install some sample code to help starters. If you run the executable by double-clicking on it, just follow the on-screen directions and the toolkit will be installed. This is the graphical way of installation, and the downside of this method is that you do not have control on what packages to install. This can be avoided if you install the toolkit using CLI. Here is a list of possible packages that you can control −
For example, to install only the compiler and the occupancy calculator, use the following command −
<PackageName>.exe -s nvcc_9.1 occupancy_calculator_9.1

Follow these steps to verify the installation −
Step 1 − Check the CUDA toolkit version by typing nvcc -V in the command prompt.
Step 2 − Run deviceQuery.cu located at: C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.1\bin\win64\Release to view your GPU card information. The output will look like −
Step 3 − Run the bandWidth test located at C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.1\bin\win64\Release. This ensures that the host and the device are able to communicate properly with each other. The output will look like −
If any of the above tests fail, it means the toolkit has not been installed properly. Re-install by following the above instructions.
CUDA can be uninstalled without any fuss from the ‘Control Panel’ of Windows.
At this point, the CUDA toolkit is installed. You can get started by running the sample programs provided in the toolkit.
For doing development work using CUDA on Visual Studio, it needs to be configured. To do this, go to − File → New | Project... NVIDIA → CUDA →. Now, select a template for your CUDA Toolkit version (We are using 9.1 in this tutorial). To specify a custom CUDA Toolkit location, under CUDA C/C++, select Common, and set the CUDA Toolkit Custom Directory.
 Print
 Add Notes
 Bookmark this page