title: How do you build the example CUDA Thrust device sort?
body: <p>I am trying to build and run the Thrust example code in Visual Studio 2010 with the latest version (7.0) of CUDA and the THURST install that comes with it. I cannot get the example code to build and run. </p>
  
  <p>By eliminating parts of the code, I found the problem to be with the thrust::sort(..) call. Host vectors work great, but device vectors produce the following compile error:</p>
  
  <p><em>1>c:\program files\nvidia gpu computing toolkit\cuda\v7.0\include\thrust\system\cuda\detail\sort.inl(203): error C2027: use of undefined type 'thrust::detail::STATIC_ASSERTION_FAILURE' </em></p>
  
  <p>This is the example code I'm using that won't compile which is largely out of the CUDA trust example at <a href="https://developer.nvidia.com/Thrust" rel="nofollow">https://developer.nvidia.com/Thrust</a> </p>
  
  <pre><code>#include &lt;thrust/host_vector.h&gt;
  #include &lt;thrust/device_vector.h&gt;
  #include &lt;thrust/generate.h&gt;
  #include &lt;thrust/sort.h&gt;
  #include &lt;thrust/copy.h&gt;
  #include &lt;algorithm&gt;
  #include &lt;cstdlib&gt;
  #include &lt;time.h&gt;
  
  int main(void)
  {
     // generate 32M random numbers serially
     thrust::host_vector&lt;int&gt; h_vec(32 &lt;&lt; 20);
     std::generate(h_vec.begin(), h_vec.end(), rand);
  
     // transfer data to the device
     thrust::device_vector&lt;int&gt; d_vec = h_vec;
  
     // sort data on the device (This breaks the compile)
     thrust::sort(d_vec.begin(), d_vec.end());
  
     // sort data on the host (This works just fine)
     thrust::sort(h_vec.begin(), d_vec.end());
  
     // transfer data back to host
     thrust::copy(d_vec.begin(), d_vec.end(), h_vec.begin());
  
     return 0;
  }
  </code></pre>
  
  <p>Playing around I found that if you comment out the line that uses the device vector: </p>
  
  <pre><code>  // thrust::sort(d_vec.begin(), d_vec.end()); 
  </code></pre>
  
  <p>but leave the line that uses the host vector: </p>
  
  <pre><code>  thrust::sort(h_vec.begin(), d_vec.end()); 
  </code></pre>
  
  <p>it compiles and runs just fine, though the sort seems to be running on the host.</p>
  
  <p>How do I get the example code to compile and run so the sort will take place on the device vector and not the host vector?</p>
  
  <p>My system configuration includes:</p>
  
  <ul>
  <li>Visual Studio 2010 / SP1 installed</li>
  <li>Windows 7 pro, 64bit</li>
  <li>CUDA 7.0 Development kit</li>
  <li>NVIDA Quadro K4000 with recent drivers</li>
  </ul>