- Hands-On GPU:Accelerated Computer Vision with OpenCV and CUDA
- Bhaumik Vaidya
- 248字
- 2021-08-13 15:48:21
Accessing GPU device properties from CUDA programs
CUDA provides a simple interface to find the information such as determining which CUDA-enabled GPU devices (if any) are present and what capabilities each device supports. First, it is important to get a count of how many CUDA-enabled devices are present on the system, as a system may contain more than one GPU-enabled device. This count can be determined by the CUDA API cudaGetDeviceCount(). The program for getting a number of CUDA enabled devices on the system is shown here:
#include <memory>
#include <iostream>
#include <cuda_runtime.h>
// Main Program
int main(void)
{
int device_Count = 0;
cudaGetDeviceCount(&device_Count);
// This function returns count of number of CUDA enable devices and 0 if there are no CUDA capable devices.
if (device_Count == 0)
{
printf("There are no available device(s) that support CUDA\n");
}
else
{
printf("Detected %d CUDA Capable device(s)\n", device_Count);
}
}
The relevant information about each device can be found by querying the cudaDeviceProp structure, which returns all the device properties. If you have more than one CUDA-capable device, then you can start a for loop to iterate over all device properties. The following section contains the list of device properties divided into different sets and small code snippets used to access them from CUDA programs. These properties are provided by the cudaDeviceProp structure in CUDA 9 runtime.
- 新編Visual Basic程序設(shè)計(jì)上機(jī)實(shí)驗(yàn)教程
- Spring Boot 2實(shí)戰(zhàn)之旅
- HTML5移動(dòng)Web開發(fā)技術(shù)
- Mastering Zabbix(Second Edition)
- JavaScript:Functional Programming for JavaScript Developers
- OpenCV實(shí)例精解
- 前端跨界開發(fā)指南:JavaScript工具庫(kù)原理解析與實(shí)戰(zhàn)
- Learning Bayesian Models with R
- 神經(jīng)網(wǎng)絡(luò)編程實(shí)戰(zhàn):Java語(yǔ)言實(shí)現(xiàn)(原書第2版)
- Java游戲服務(wù)器架構(gòu)實(shí)戰(zhàn)
- Cocos2d-x學(xué)習(xí)筆記:完全掌握Lua API與游戲項(xiàng)目開發(fā) (未來(lái)書庫(kù))
- Apache Kafka Quick Start Guide
- Python Data Structures and Algorithms
- HTML+CSS+JavaScript編程入門指南(全2冊(cè))
- Extending Unity with Editor Scripting