thrust::device_vector error

2019-05-26 04:39发布

问题:

I'm new to Thrust. I'm trying to copy from a thrust::host_vector to a thrust::device_vector, both of type Sequence which is a class I already implemented.

I do however get an error "Invalid Device Function". I'm using CUDA 4.0 VS2010 on a GeForce GT 540.

thrust::host_vector <Sequence> Ind_Tabel_V; 
void Ind_Table_Filling() 
{ 
    //some Code 
    Sequence s; 
    // some code 
    Ind_Tabel_V.push_back(s); 
    try 
    { 
        thrust::device_vector<Sequence> d_vec=Ind_Tabel_V; 
    } 
    catch (thrust::system_error &e) 
    { 
        std::cerr << "Error accessing vector element: " << e.what() << std::endl; 
    } 
} 

Can anyone help please?

回答1:

That error message typically means the runtime cannot find a binary matching your GPU architecture, i.e. you have not included the correct GPU SM version in your compilation. Since you're using VS2010 the GPU architecture is usually set via the build customisation. In the project properties under CUDA C/C++, Device you should see the "Code Generation" option. I'm not sure what generation your GPU is but you could try "compute_20,sm_20;compute_20,sm_21" to build for both Fermi architectures.



标签: cuda thrust