CUDA DLLとリンクせず、動的にロードしてcudaGetDeviceCount()を呼び出してみましたか?このように:
typedef cudaError_t (*FnGetDeviceCount) ( int * count ) ;
HMODULE hCuda=LoadLibrary("cudart32_40_17.dll");
if(!hCuda) return ; // ERROR: cannot load dll, DllMain must have failed because cudart only depends on Kernel dll implicitly. Or cannot find dll in curent directory or in the path.
FnGetDeviceCount fnGetDeviceCount=(FnGetDeviceCount)GetProcAddress(hCuda, "cudaGetDeviceCount");
if(!fnGetDeviceCount) return; // ERROR: cudart has no entry point for cudaGetDeviceCount ?!
int count = 0;
if(cudaSuccess != (*fnGetDeviceCount)(&count)) return ;// ERROR: we don't wanna use CUDA if even device enumeration fails
if(!count) return; // FALLBACK: CUDA has no devices, don't try to use it, fallback to some other BLAS
あなただけcudartや他のライブラリをリンクすることはできませんので、それは不便だが、それは、ユーザーが恐ろしい起動エラーを見ることなくBLASにフォールバックすることを可能にします。免責事項:私はこのコードをテストしたりコンパイルしたりしていません。もしあなたがそれを使用すれば、私たちに知らせてください:
This threadは、特定のバージョンのCUDAツールキット(例:cudart64_40_17.dll )、それはいいです。
デバイスがあるかどうかを実行時に確認するための関数['cudaGetDeviceCount'](http://www.clear.rice.edu/comp422/resources/cuda/html/group__CUDART__DEVICE_g665468e8cb33be42434f11bee2684ec9.html)があります。 –
そうですが、始めるにはすべてのDLLが必要です。だから私は彼らに私のプログラムを供給しなければならないでしょう。しかし、私が提供したdllとインストールされたものとの間にバージョンの競合があると、物事が厄介になり始めます。 – FFox