VS2019上配置CUDA的環(huán)境步驟
本貼介紹一下CUDA編程的流程
1、打開VS,新建項(xiàng)目(空項(xiàng)目即可)
2、右鍵項(xiàng)目,生成依賴項(xiàng),自定義

3、勾選CUDA

4、源文件中新建.cu文件,右鍵.cu文件,屬性沒(méi)常規(guī),項(xiàng)類型,選中CUDA C/C++

5、添加屬性表

其中,屬性表由之前配置,保存,以后項(xiàng)目直接添加現(xiàn)有屬性表即可。屬性表中內(nèi)容為:



此處內(nèi)容,請(qǐng)參考其他博文內(nèi)容,添加cuda的相關(guān)庫(kù)文件,.lib文件等等。
例程:
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
void main() {
int deviceCount;
cudaGetDeviceCount(&deviceCount);
int dev;
for (dev = 0; dev < deviceCount; dev++)
{
int driver_version(0), runtime_version(0);
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, dev);
if (dev == 0)
if (deviceProp.minor = 9999 && deviceProp.major == 9999)
printf("\n");
printf("\nDevice%d:\"%s\"\n", dev, deviceProp.name);
cudaDriverGetVersion(&driver_version);
printf("CUDA驅(qū)動(dòng)版本: %d.%d\n", driver_version / 1000, (driver_version % 1000) / 10);
cudaRuntimeGetVersion(&runtime_version);
printf("CUDA運(yùn)行時(shí)版本: %d.%d\n", runtime_version / 1000, (runtime_version % 1000) / 10);
printf("設(shè)備計(jì)算能力: %d.%d\n", deviceProp.major, deviceProp.minor);
printf("Total amount of Global Memory: %u bytes\n", deviceProp.totalGlobalMem);
printf("Number of SMs: %d\n", deviceProp.multiProcessorCount);
printf("Total amount of Constant Memory: %u bytes\n", deviceProp.totalConstMem);
printf("Total amount of Shared Memory per block: %u bytes\n", deviceProp.sharedMemPerBlock);
printf("Total number of registers available per block: %d\n", deviceProp.regsPerBlock);
printf("Warp size: %d\n", deviceProp.warpSize);
printf("Maximum number of threads per SM: %d\n", deviceProp.maxThreadsPerMultiProcessor);
printf("Maximum number of threads per block: %d\n", deviceProp.maxThreadsPerBlock);
printf("Maximum size of each dimension of a block: %d x %d x %d\n", deviceProp.maxThreadsDim[0],
deviceProp.maxThreadsDim[1],
deviceProp.maxThreadsDim[2]);
printf("Maximum size of each dimension of a grid: %d x %d x %d\n", deviceProp.maxGridSize[0], deviceProp.maxGridSize[1], deviceProp.maxGridSize[2]);
printf("Maximum memory pitch: %u bytes\n", deviceProp.memPitch);
printf("Texture alignmemt: %u bytes\n", deviceProp.texturePitchAlignment);
printf("Clock rate: %.2f GHz\n", deviceProp.clockRate * 1e-6f);
printf("Memory Clock rate: %.0f MHz\n", deviceProp.memoryClockRate * 1e-3f);
printf("Memory Bus Width: %d-bit\n", deviceProp.memoryBusWidth);
}
system("pause");
//return 0;
}
到此這篇關(guān)于VS2019上配置CUDA的環(huán)境步驟的文章就介紹到這了,更多相關(guān)VS2019配置CUDA內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C語(yǔ)言高效實(shí)現(xiàn)向量循環(huán)移位
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言高效實(shí)現(xiàn)向量循環(huán)移位,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-03-03
數(shù)據(jù)結(jié)構(gòu)之帶頭結(jié)點(diǎn)的單鏈表
單鏈表是一種鏈?zhǔn)酱嫒〉臄?shù)據(jù)結(jié)構(gòu),用一組地址任意的存儲(chǔ)單元存放線性表中的數(shù)據(jù)元素。鏈表中的數(shù)據(jù)是以結(jié)點(diǎn)來(lái)表示的,每個(gè)結(jié)點(diǎn)的構(gòu)成:數(shù)據(jù)域(數(shù)據(jù)元素的映象)?+?指針域(指示后繼元素存儲(chǔ)位置),元素就是存儲(chǔ)數(shù)據(jù)的存儲(chǔ)單元,指針就是連接每個(gè)結(jié)點(diǎn)的地址數(shù)據(jù)2023-07-07
C++實(shí)現(xiàn)保存數(shù)據(jù)至EXCEL
這篇文章主要介紹了C++實(shí)現(xiàn)保存數(shù)據(jù)至EXCEL,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-11-11
C++實(shí)現(xiàn)LeetCode(172.求階乘末尾零的個(gè)數(shù))
這篇文章主要介紹了C++實(shí)現(xiàn)LeetCode(172.求階乘末尾零的個(gè)數(shù)),本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08
C++實(shí)現(xiàn)LeetCode(44.外卡匹配)
這篇文章主要介紹了C++實(shí)現(xiàn)LeetCode(44.外卡匹配),本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07

