3
爲什麼下面的代碼在主的末尾崩潰?使用推力device_vector作爲全局變量
#include <thrust/device_vector.h>
thrust::device_vector<float4> v;
int main(){
v.resize(1000);
return 0;
}
的錯誤是:
terminate called after throwing an instance of 'thrust::system::system_error'
what(): unspecified driver error
如果我使用host_vector
代替device_vector
代碼運行正常。
你認爲這是一個Thrust錯誤,還是我在這裏做錯了什麼?
我在ubuntu 10.10上用cuda 4.0和Windows 7用cuda 6.5試過了。 在這兩種情況下,Thrust版本都是1.7。
謝謝
@RobertCrovella:這不是在這裏發生的事情。發生這種情況的原因是,該向量在CUDA上下文被刪除之後掉出範圍並被銷燬。所以有效地調用cudaFree時沒有工作的運行時API連接,導致運行時錯誤 – talonmies 2014-08-28 12:30:14