Vista(x64)でCuda2.0Betaがなかなか動かない
コンパイルするとエラーになる。
基本、SDK,TOOLKIT,CUDA対応ドライバーをインストールして環境変数をせっとすればコンパイルできるようになるのだが
WinXPマシンに入れて、エミュレートではコンパイルできたのだが、
肝心のGeForceを入れているVista(x64)マシンでうまく行かん。
ネットのサンプルや解説ブログのほとんどは、XPで32bit版で、CUDA1.1あたりだと思われるんで、あまり情報がない。
もうVistaをやめてWinXPをインストールした方が早いかもしれない。
C:\misaki2>nvcc cudatest.cu cudatest.cu cudatest.cu(7) : warning C4003: マクロ 'CUT_DEVICE_INIT' に指定された実引数の数 が少なすぎます。 cudatest.cu(7): error: expected an expression cudatest.cu(7): error: type name is not allowed cudatest.cu(7): error: expected an expression 3 errors detected in the compilation of "C:\Users\user\AppData\Local\Temp/tmpxft _00000b60_00000000-6_cudatest.cpp1.ii".
ちなみにサンプル
C:\misaki2>type cudatest.cu //cudatest.cu #include <iostream> #include <cutil.h> int main( int argc, char** argv) { //デバイスの初期化 CUT_DEVICE_INIT(); //デバイス(通常はビデオカードの数)を取得 int numofdev; CUDA_SAFE_CALL(cudaGetDeviceCount(&numofdev)); //デバイスの数だけループを回してプロパティを取得 for (int n = 0; n < numofdev; n++) { //プロパティを格納する構造体 cudaDeviceProp devprop; //n番目のデバイスのプロパティを取得 CUDA_SAFE_CALL(cudaGetDeviceProperties(&devprop, n)); //n番目のデバイスの表示 cout<<n+1<<"番目のデバイスのプロパティ"<<endl; cout<<"デバイス名:"<<devprop.name<<endl; cout<<"グローバルメモリの合計値:"<<devprop.totalGlobalMem/1024/1024<<" M B"<<endl; cout<<"各ブロックに割り当てられる最大シェアードメモリ:"<<devprop.sharedM emPerBlock/1024<<" KB"<<endl; cout<<"各ブロックのレジスタ数:"<<devprop.regsPerBlock<<endl; cout<<"ワープサイズ:"<<devprop.warpSize<<endl; cout<<"メモリピッチ:"<<devprop.memPitch<<endl; cout<<"1ブロックあたりの最大スレッド数:"<<devprop.maxThreadsPerBlock<<en dl; cout<<"ブロックの最大次元:("<<devprop.maxThreadsDim[0]<<","<<devprop.max ThreadsDim[1]<<","<<devprop.maxThreadsDim[2]<<")"<<endl; cout<<"グリッドの最大次元:("<<devprop.maxGridSize[0]<<","<<devprop.maxGr idSize[1]<<","<<devprop.maxGridSize[2]<<")"<<endl; cout<<"最大コンスタントメモリ:"<<devprop.totalConstMem/1024<<" KB"<<endl ; cout<<"バージョン:"<<devprop.major<<"."<<devprop.minor<<endl; cout<<"クロック周波数:"<<devprop.clockRate/1000<<"MHz"<<endl; cout<<"デバイス名:"<<devprop.textureAlignment<<endl; } //終了処理 CUT_EXIT(argc, argv); }
cuda2.0beta動きました!!
GA将!さんがコメントでMycomジャーナルの記事を紹介してくれましたが、
http://journal.mycom.co.jp/special/2008/cuda/004.html
CUT_DEVICE_INIT();
を
CUT_DEVICE_INIT(argc, argv);
と書いたらコンパイル通りました。
後は、
C:\misaki2>nvcc cudatest.cu -lcutil64 -o cudatest.exe cudatest.cu tmpxft_00000c34_00000000-3_cudatest.cudafe1.gpu tmpxft_00000c34_00000000-8_cudatest.cudafe2.gpu tmpxft_00000c34_00000000-3_cudatest.cudafe1.cpp tmpxft_00000c34_00000000-12_cudatest.ii
と64bitのライブラリを指定する必要がありました。
実行時に、このcutil64.dllにもパスが通っている必要があります。
動かすと
C:\misaki2>cudatest Using device 0: GeForce 9600 GT 1番目のデバイスのプロパティ デバイス名:GeForce 9600 GT グローバルメモリの合計値:512 MB 各ブロックに割り当てられる最大シェアードメモリ:16 KB 各ブロックのレジスタ数:8192 ワープサイズ:32 メモリピッチ:262144 1ブロックあたりの最大スレッド数:512 ブロックの最大次元:(512,512,64) グリッドの最大次元:(65535,65535,1) 最大コンスタントメモリ:64 KB バージョン:1.1 クロック周波数:1600MHz デバイス名:256 Press ENTER to exit... C:\misaki2>