CUDA Driver API Usage notes
1. Introduction
The Cuda Driver API is implemented in the Cuda Dynamic Library (libcuda.so). If you are developing in an eclipse environment, you need to add the path to the libcuda.so file and reference the Cuda.h file in your program.
2. Environment configuration
2.1 Source Program
For the use of the driver API simply include the corresponding header file Cuda.h in the source program, and before using the other driver APIs, you need to call the Cuinit () function to initialize the driver, as shown in the following program.
1#include <stdlib.h>
2
3#include <stdio.h>
4
5#include <cuda.h>
6
7intMainvoid){
8
9intDriverVersion;
Ten
OneCuinit (0);
A
-Cudrivergetversion (&driverversion);
-
theprintf"after:%d\n", driverversion);
-
-return 0;
-
+}
2.2 Eclipse Environment
If you develop cuda with the Eclipse platform, you need to add the directory where the libcuda.so library file is located, which is added in the Eclipse environment by Right-clicking the project àPropertiesàBuild à SettingsàTool Settingsànvcc lickerà miscellaneousàother objects, Then add the directory where the libcuda.so file is located in other objects.
Figure 1
Reference documents
Refer to Cuda Toolkit's own file,
- the cuda_c_programming_guide.pdf " Driver API section: Introduction to Using Driver API the way that quite is an introductory level introduction;
- vectoradddrv Project: This project is a driver API sample /root/nvidia_cuda-7.0_samples/0_simple/ Vectoradddrv
- the cuda_driver_api.pdf ": This document provides all relevant API , but does not describe how to use it, it is a API User Manual.
CUDA Driver API Usage notes