我想用我的兩個圖形卡進行CUDA Thrust計算。多GPU與CUDA Thrust的使用
我有兩個圖形卡。即使我在std :: vector中存儲了兩個device_vector,運行在單張卡片上的效果也非常好。
如果我同時使用兩張卡片,循環中的第一個循環將起作用並且不會導致錯誤。第一次運行後,它會導致錯誤,可能是因爲設備指針無效。
我不確定確切的問題是什麼,或者如何使用兩張卡進行計算。
最少的代碼示例:在執行
std::vector<thrust::device_vector<float> > TEST() {
std::vector<thrust::device_vector<float> > vRes;
unsigned int iDeviceCount = GetCudaDeviceCount();
for(unsigned int i = 0; i < iDeviceCount; i++) {
checkCudaErrors(cudaSetDevice(i));
thrust::host_vector<float> hvConscience(1024);
// first run works, runs afterwards cause errors ..
vRes.push_back(hvConscience); // this push_back causes the error on exec
}
return vRes;
}
錯誤消息:
terminate called after throwing an instance of 'thrust::system::system_error'
what(): invalid argument
您是使用主機副本還是使用主機緩衝區? –
不知道你的意思。此代碼從主機複製到設備。 – dgrat
所以他們不在SLI模式? –