試著編譯第一隻程式出現錯誤

配置WIN7 X64是5.0+vs2010

請問我哪個環節的設定出了問題呢

CUDA範例程式只有一半能跑 其他都閃一下跳掉

kernel.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;}
錯誤如下
‘12.exe’: 已載入 ‘C:\Users\Administrator\Documents\Visual Studio 2010\Projects\12\x64\Debug\12.exe’,已載入符號’12.exe’: 已載入 ‘C:\Windows\System32\ntdll.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\kernel32.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\KernelBase.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Users\Administrator\Documents\Visual Studio 2010\Projects\12\x64\Debug\cudart64_50_35.dll’,二進位碼不是以偵錯資訊而建置。‘12.exe’: 已載入 ‘C:\Windows\System32\msvcr100d.dll’,已載入符號’12.exe’: 已載入 ‘C:\Windows\System32\nvcuda.dll’,二進位碼不是以偵錯資訊而建置。‘12.exe’: 已載入 ‘C:\Windows\System32\user32.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\gdi32.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\lpk.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\usp10.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\msvcrt.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\setupapi.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\cfgmgr32.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\rpcrt4.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\advapi32.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\sechost.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\oleaut32.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\ole32.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\devobj.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\shell32.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\shlwapi.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\imm32.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\msctf.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\dwmapi.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已卸載 ‘C:\Windows\System32\dwmapi.dll’‘12.exe’: 已載入 ‘C:\Windows\System32\nvapi64.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\version.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\wintrust.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\crypt32.dll’,找不到或無法開啟 PDB 檔案’12.exe’: 已載入 ‘C:\Windows\System32\msasn1.dll’,找不到或無法開啟 PDB 檔案

你肯定是目录错误了,另外新建一个CUDA项目,然后把现在这个无法编译的源代码复制到那个项目的文件夹下,导入新项目,编译

不太懂意思 …
問為何我執行devicequery只會跑一下就跳離呢

剛剛發現如果我跑偵錯是失敗的
ctrl+f5是成功的

為何無法偵錯呢?!= =

敢問是否有 新手入門的地方好讓我參考

楼主你好!

你没有“编译出错”。你的编译很成功!!所以你的问题无需回复。

至于提示,那个是你调试的时候,告诉你无法载入调试信息的。具体说,是无法为windows的众多dll载入它们的调试信息。因为一般我们用的windows都是去掉了调试信息的版本。以及它们也不妨碍你实际调试你的“代码”。

如何为windows的dll们载入调试信息已经超出了本论坛的技术支持范围,当然,如果你真的需要为它们载入,请继续回复。我将看到你的重复确认后,给予回复此额外问题。

总之,你的代码编译OK. 你的编译失败的说法是错误的。实际上,能看到这个提示,你已经在运行你的exe了。

关于楼主的第二个问题,“問為何我執行devicequery只會跑一下就跳離呢”。

(A)如果您直接在5.0例子浏览器里面run的,那么的确会运行一遍瞬间窗口消失。
此时有2种方式解决,(A-1)在运行瞬间右键点击窗口->选中Mark, 用鼠标确定范围,用回车复制内容。在你复制之前,不会瞬间消失。(A-2)启动cmd.exe, 输入cd “C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\bin\win64\Release” (注意,如果你用的是32位的,请将win64替换为win32),并按您的Enter键,然后继续输入devicequery, 会按回车键。然后可以慢慢观察结果。

(B)如果您是在Visual Studio中打开的源代码,那么
(B-1)如果你是使用的调试启动的,请在main最后的return前加入断点,然后再重新调试,即可再结束前给您足够的时间观察。
(B-2)如果您是直接非调试运行的,请直接CTRL-F5, 会提示您按任意键继续的。

如果楼主还有其他更多问题,欢迎继续发问。

謝謝 我了解了 成功執行囉
請問一下有能讓新手的好地方嗎 目前我是加入兩個論壇

个人建议:
1:加讨论群和论坛
2:通过iTunes U或者其他在线课程观看一些大学的CUDA公开课,如UIUC,斯坦福,MIT,以及台大当年的课程。
3:参考随CUDA附带的pdf资料,NV网站有在线版的文档可以看。
4:参考一些常见的教材。
5:参考一些人写的专题blog,这个似乎英文的居多。

大致如上,请您参考,祝您编码愉快~