CUDA + Qt + VS2008 编程环境的配置

文章描述:-2022年3月28日发(作者:张作霖)CUDA + Qt + VS2008 编程环境的配置- 按照常规生成pro文件,进而得到vs的工程文件后,- 项目名右键,选择自定义生成规则,在可用规则文件里面选择 CUDA Runtime API Rule(v3.2)- 在配置属性—链接器—常规选项的附加库目录里面,添加 $(VSDKCOMPUTE_ROOT)Ccommonlib 和$(CUDA_LIB

-

CUDA + Qt + VS2008 编程环境的配置2022年3月28日发(作者:张作霖)

CUDA + Qt + VS2008 编程环境的配置



- 按照常规生成pro文件,进而得到vs的工程文件后,



- 项目名右键,选择自定义生成规则,在可用规则文件里面选择 CUDA Runtime API Rule(v3.2)



- 在配置属性—链接器—常规选项的附加库目录里面,添加 $(VSDKCOMPUTE_ROOT)Ccommonlib 和$(CUDA_LIB_PATH)



注:参考CUDA SDK中例子的工程文件,它们添加的附加库目录是:$(CUDA_PATH)/lib/$(Platformame);../../common/lib/$(Platformame)



以本机为例,各环境变量的值如下:



CUDA_PATH - E:Program Files (x86)VIDIA GPU Computing ToolkitCUDAv4.2

$(CUDA_PATH)/lib/$(Platformame)就相当于E:Program Files (x86)VIDIA GPU Computing ToolkitCUDAv4.2libWin32,

其中的lib文件是, , , , , , , , , ,



../../common/lib/$(Platformame),各个例子上溯两级目录后是E:ProgramDataVIDIA CorporationVIDIA GPU Computing SDK 4.2C,

所以../../common/lib/$(Platformame)就相当于E:ProgramDataVIDIA CorporationVIDIA GPU Computing SDK 4.2CcommonlibWin32,

其中的lib文件是, , ,



CUDA_LIB_PATH - %CUDA_PATH%libWin32就相当于E:Program Files (x86)VIDIA GPU Computing ToolkitCUDAv4.2libWin32



VSDKCOMPUTE_ROOT - E:ProgramDataVIDIA CorporationVIDIA GPU Computing SDK 4.2

$(VSDKCOMPUTE_ROOT)Ccommonlib - E:ProgramDataVIDIA CorporationVIDIA GPU Computing SDK 4.2Ccommonlib,相比之下似乎应该再多一级Win32



- 在配置属性—链接器—输入选项的附加依赖项里添加



注:关于文件,在VIDIA CUDA GETTIG STARTED GUIDE FOR MICROSOFT WIDOWS文档中(对应的文件名可能是 CUDA_Getting_Started_)指出,好像是需要再编译一次对应的工程才能生成的。实际上结合之前的路径,似乎可以把需要的lib文件都复制到统一的目录下,或者在pro文件中指定,而相应的exe文件(比如nvcc、nvvp等)和dll文件则都可以通过环境变量PATH(用户)和Path(系统)中所设置的路径值获得——这应该是在安装CUDA SDK时,安装程序自动完成的设置。



Most samples link to a utility library called cutil, the source code for which is in VIDIA GPU Computing SDKCcommrc. The release versi of these

samples link to (or ) and dynamically load (or ). The debug versi of these samples link to and dynamically load (or their 64-bit equivalents on 64-bit versi of Windows).



To build the Win32 release and/or debug configurati of the cutil library, use the solution files located in VIDIA GPU Computing SDKCcommon. The output

of the compilation process should be placed in

VIDIA GPU Computing SDKCcommonlib:



and (or and ) are the release and debug import libraries.



and (or and ) are the release and debug dynamic-link libraries, which also are copied to VIDIA GPU

Computing SDKCbinwin32
elease and VIDIA GPU Computing SDKCbinwin32debug respectively. (Substitute win64 for win32 on 64-bit Windows.)



ote: The cutil library is primarily intended as a tool for streamlining the GPU Computing SDK samples; its use outside of the SDK samples is not recommended, as the API for the library may change at any time.



These sample projects also make use of the $CUDA_PATH environment variable to locate the CUDA Toolkit and a .rules file to locate and configure the nvcc compiler. The environment variable is set automatically and the .rules file is installed automatically as part of the CUDA Toolkit installation process. The .rules file is installed into $VisualStudioInstallDirVCVCProjectDefaults. You can reference this .rules file from your Visual Studio project files when building your own CUDA applicati.





实际上,CUDA应用于Qt,相当于在已有的project中添加所谓的CUDA build customizati



在VIDIA CUDA GETTIG STARTED GUIDE FOR MICROSOFT WIDOWS文档中(对应的文件名可能是 CUDA_Getting_Started_)提到:



BUILD CUSTOMIZATIOS FOR EXISTIG PROJECTS



When adding CUDA acceleration to existing applicati, the relevant Visual Studio project file must be updated to include CUDA build customizati. For Visual Studio 2010, this can done using one of the following two methods:



1. Open the Visual Studio 2010 project, right click on the project name, and select “Build Customizati...”, then select the CUDA Toolkit version you would like to target.



注:在vs2008中,在右键点击project name后弹出的菜单中,只有Custom Build Rules,然后选择规则文件 CUDA Runtime API Rule



2. Alternatively, you can configure your project always to build with the most recently installed version of the CUDA Toolkit. First add a CUDA build customization to your project as above. Then, right click on the project name and select “Properties”.Under “CUDA C/C++”, select “Common”, and set the “CUDA Toolkit Custom Dir” field to “$(CUDA_PATH)” (without the quotes).



注:参考sdk的样例(convolutionFFT2D),点击Properties后,看到的是CUDA Runtime API,有General、GPU、Host和Command Line。

在General中,主要是指定了Compiler Path - $(CUDA_PATH)bin
和 Required Include Directories - $(CUDA_PATH)include

在GPU中,指定了VCC Compilation Type - Generate hybrid object file (--compile / -c) (当然,也有其它选项的),还有就是GPU Architecture(1) - sm_10;GPU Architecture(2) - sm_20;GPU Architecture(3) - sm_30。(至于其余的以及Host部分不是不

重要,只是看不懂:))

而Command Line则是包含了之前选项中所设定的内容,如下:

echo "E:Program Files (x86)VIDIA GPU Computing ToolkitCUDAv4.2bin
" -gencode=arch=compute_10,code="sm_10,compute_10" -gencode=arch=compute_20,code="sm_20,compute_20" -gencode=arch=compute_30,code="sm_30,compute_30" --machine 32 -ccbin "C:Program Files (x86)Microsoft Visual Studio 9.0VCbin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -I"E:Program Files (x86)VIDIA GPU Computing ToolkitCUDAv4.2include" -maxrregcount=0 --compile -o "Debug/convolutionFFT2D_" convolutionFFT2D_

"E:Program Files (x86)VIDIA GPU Computing ToolkitCUDAv4.2bin
" -gencode=arch=compute_10,code="sm_10,compute_10" -gencode=arch=compute_20,code="sm_20,compute_20" -gencode=arch=compute_30,code="sm_30,compute_30" --machine 32 -ccbin "C:Program Files (x86)Microsoft Visual Studio 9.0VCbin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -I"E:Program Files (x86)VIDIA GPU Computing ToolkitCUDAv4.2include" -maxrregcount=0 --compile -o "Debug/convolutionFFT2D_" "e:ProgramDataVIDIA CorporationVIDIA GPU Computing SDK 4.2CsrcconvolutionFFT2DconvolutionFFT2D_"



While Option 2 will allow your project to automatically use any new CUDA Toolkit version you may install in the future, selecting the toolkit version explicitly as in Option 1 is often better in practice, because if there are new CUDA configuration opti added to the build customization rules accompanying the newer toolkit, you would not see those new opti using Option 2.



ote for advanced users: if you wish to try building your project against a newer CUDA Toolkit without making changes to any of your project files, go to the Visual Studio 2010 command prompt, change the current directory to the location of your project, and execute a command such as the following:



msbuild /t:Rebuild

/p:CudaToolkitDir="drive:/path/to/new/toolkit/"

-

CUDA + Qt + VS2008 编程环境的配置

发布时间:2022-03-28 12:46:39
文章版权声明:除非注明,否则均为IT技术网-学习WEB前端开发等IT技术的网络平台原创文章,转载或复制请以超链接形式并注明出处。

发表评论

评论列表 (有 14 条评论,125人围观)
nvvp等)和dll文件则都可以通过环境变量PATH(用户)和Path(系统)中所设置的路径值获得——这应该是在安装CUDA SDK时
农药超标V铁粉19 minutes ago Google Chrome 93.0.4577.82 Windows 10 x64
止咳宝V铁粉1 minute ago Google Chrome 93.0.4577.82 Windows 10 x64
添加 $(VSDKCOMPUTE_ROOT)Ccommonlib 和$(CUDA_LIB_PATH) 注:参考CUDA SDK中例子的工程文件
广汽本田最新款V铁粉0 second ago Google Chrome 93.0.4577.82 Windows 10 x64
Most samples link to a utility library called cutil
新世纪星城V铁粉8 minutes ago Google Chrome 93.0.4577.82 Windows 10 x64
ProgramDataVIDIA CorporationVIDIA GPU Computing SDK 4.2Ccommonlib
寸和厘米的换算V铁粉8 minutes ago Google Chrome 93.0.4577.82 Windows 10 x64
什么是阴阳人V铁粉3 minutes ago Google Chrome 93.0.4577.82 Windows 10 x64
which also are copied to VIDIA GPU Computing SDKCbinwin32elease and VIDIA GPU Computing SDKCbinwin32debug respectively. (Substitute win64 for win32 on 64-bit Windows.) ote
道乐日本料理V铁粉17 minutes ago Google Chrome 93.0.4577.82 Windows 10 x64
GPU
家居卖场V铁粉23 minutes ago Google Chrome 93.0.4577.82 Windows 10 x64
as the API for the library may change at any time. These sample projects also make use of the $CUDA_PATH environment variable to locate the CUDA Toolkit and a .rules file to locate and configure the nvcc compiler. The environment variable is set automatically and the .rules file is installed automatically as part of the CUDA Toolkit installation process. The .rules file is installed into $VisualStudioInstallDirVCVCProjectDefaults. You can reference this .rules file from your Visual Studio project files when building your own CUDA applicati.实际上
保定现代妇产医院V铁粉17 minutes ago Google Chrome 93.0.4577.82 Windows 10 x64
实际上结合之前的路径
南宁电子地图V铁粉16 minutes ago Google Chrome 93.0.4577.82 Windows 10 x64
because if there are new CUDA configuration opti added to the build customization rules accompanying the newer toolkit
preventdefaultV铁粉19 minutes ago Google Chrome 93.0.4577.82 Windows 10 x64
Most samples link to a utility library called cutil
绿地国际花都V铁粉13 minutes ago Google Chrome 93.0.4577.82 Windows 10 x64
在General中

最近发表

随便看看

热门文章

标签列表