2
votes

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
The code looks ok. I think the error is elsewhere in your code. Make sure that you check the return from each CUDA call you make before calling the code above. - Roger Dahl
Can you provide the definition of class Sequence? - harrism

1 Answers

4
votes

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.