I want to use my two graphic cards for calculation with CUDA Thrust.
Running on single cards works well for both cards, even when I store two device_vectors in the std::vector.
If I use both cards at the same time, the first cycle in the loop works and causes no error. After the first run it causes an error, probably because the device pointer is not valid.
I am not sure what the exact problem is, or how to use both cards for calculation. Could it be, that thrust::device_vector is instantiated already in the std::vector before the device was set?
Minimal code sample:
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;
}