您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)win7+VS2010如何安裝CUDA7.0,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
win7+ VS2010安裝CUDA7.0圖文說明
1. 查看本機(jī)配置,查看顯卡類型是否支持NVIDIA GPU,選中計(jì)算機(jī)--> 右鍵屬性 --> 設(shè)備管理器 --> 顯示適配器:NVIDIA GeForce GT 610,從https://developer.nvidia.com/cuda-gpus可以查到相應(yīng)顯卡的compute capability;
2. 從http://www.nvidia.cn/Download/index.aspx?lang=cn下載合適驅(qū)動(dòng)347.88-desktop-win8-win7-winvista-64bit-international-whql.exe 并安裝;
3. 從https://developer.nvidia.com/cuda-toolkit 根據(jù)本機(jī)類型下載相應(yīng)的最新版本CUDA7.0安裝;
4.按照http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-microsoft-windows/index.html#axzz3W8BU10Ol 步驟,驗(yàn)證是否安裝正確:
(1)、打開C:\ProgramData\NVIDIACorporation\CUDA Samples\v7.0目錄下的Samples_vs2010.sln工程,分別在Debug、Release x64下編譯整個(gè)工程;
(2)、編譯過程中,會(huì)提示找不到”d3dx9.h”、”d3dx10.h”、”d3dx11.h”頭文件,可以從http://www.microsoft.com/en-us/download/details.aspx?id=6812下載DXSDK_Jun10.exe,然后安裝到默認(rèn)目錄下;再編譯工程即可;
如果安裝DXSDK_Jun10.exe出錯(cuò),如下圖
解決辦法:
打開“控制面板”的“程序和功能”,果然計(jì)算機(jī)里之前有安裝“Microsoft Visual C++ 2010 x86 Redistributable - 1010.0.40219”,而DXSDK_Jun安裝的是“Microsoft Visual C++ 2010 x86 Redistributable - 1010.0.30319”,版本低于本機(jī)已安裝的版本,所以安裝出現(xiàn)s1023錯(cuò)誤。
卸載更高的版本“Microsoft Visual C++ 2010 x86 Redistributable - 1010.0.40219”和“Microsoft Visual C++ 2010 x64 Redistributable - 1010.0.40219”,再重新安裝即可。
重新啟動(dòng)vs2010,即可編譯通過。
(3)、打開C:\Program Files\NVIDIA Corporation\Installer2\CUDASamples_7.0.{658B19AF-1B62-4FD6-A2B7-9E653E4F2B7A}\bin\win64\Release目錄,打開cmd命令行,將deviceQuery.exe直接拖到cmd中,回車,會(huì)顯示GPU顯卡、CUDA版本等相關(guān)信息,最后一行顯示:Result = PASS;
(4)、將bandwidthTest.exe拖到cmd中,回車,會(huì)顯示Device0: GeForce GT 610等相關(guān)信息,后面也會(huì)有一行顯示:Result = PASS;
5. 配置VS2010
(1)、打開VS2010,新建工程,選win32,記得勾選”空項(xiàng)目“。
(2)、右鍵源文件->添加新建項(xiàng)->選擇CUDA C/C++File,名字任意了。
(3)、右鍵工程->生成自定義->勾選CUDA 5.5
(4)、右鍵main.cu->屬性->項(xiàng)類型 選擇"CUDA C/C++"
(5)、右鍵工程->屬性->鏈接器->常規(guī)->附加庫目錄->添加目錄$(CUDA_PATH_V7_0)\lib\$(Platform);
(6)、鏈接器->輸入->附加依賴項(xiàng) 添加cudart.lib
(7)、在main.cu中加入代碼,示例代碼如下:
#include< stdio.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
bool InitCUDA()
{
int count;
cudaGetDeviceCount(&count);
if(count == 0)
{
fprintf(stderr, "There is no device.\n");
return false;
}
int i;
for(i = 0; i < count; i++)
{
cudaDeviceProp prop;
if(cudaGetDeviceProperties(&prop, i) == cudaSuccess)
{
if(prop.major >= 1)
{
break;
}
}
}
if(i == count)
{
fprintf(stderr, "There is no device supporting CUDA 1.x.\n");
return false;
}
cudaSetDevice(i);
return true;
}
int main()
{
if(!InitCUDA())
{
return 0;
}
printf("HelloWorld, CUDA has been initialized.\n");
return 0;
}
windows7 64位 顯卡GT640M cuda7.5
下載了最新版本的cuda
http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_windows.exe
安裝python2.7.11 64bit
https://www.python.org/downloads/windows/
首先測(cè)試是否支持CUDA7.5
http://blog.sina.com.cn/s/blog_534497fd0102vbu3.html
打開C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5mu中.sln文件,在vs2012中打開,調(diào)試。
建立win32空工程,添加鏈接附件庫目錄$(CUDA_PATH_V7_5)\lib\$(Platform),添加鏈接 輸入 附加依賴項(xiàng)cudart.lib
添加cuda代碼 并在代碼屬性中設(shè)置項(xiàng)類型CUDA C/C++
運(yùn)行代碼
#include <stdio.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" bool InitCUDA() { int count; cudaGetDeviceCount(&count); if(count == 0) { fprintf(stderr, "There is no device.\n"); return false; } int i; for(i = 0; i < count; i++) { cudaDeviceProp prop; if(cudaGetDeviceProperties(&prop, i) == cudaSuccess) { if(prop.major >= 1) { break; } } } if(i == count) { fprintf(stderr, "There is no device supporting CUDA 1.x.\n"); return false; } cudaSetDevice(i); return true; } int main() { if(!InitCUDA()) { return 0; } printf("HelloWorld, CUDA has been initialized.\n"); return 0; }
關(guān)于“win7+VS2010如何安裝CUDA7.0”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。