cuda testing program is as follows
#include <thrust/device_vector.h>
int main(void)
{
try
{
thrust::device_vector<float> vec;
vec.resize(6);
}
catch (thrust::system_error e)
{
std::cerr << "device_vector resize error: " << e.what() << std::endl;
return -1;
}
return 0;
}
output window prints the following message
Exception thrown at 0x00007FFD8642CD29 in test.exe: Microsoft C++ exception: thrust::system::system_error at memory location 0x0000000A8D8FE0D0.
Exception thrown at 0x00007FFD8642CD29 in test.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
Exception thrown at 0x00007FFD8642CD29 in test.exe: Microsoft C++ exception: thrust::system::system_error at memory location 0x0000000A8D8FE0D0.
Unhandled exception at 0x00007FFD8642CD29 in test.exe: Microsoft C++ exception: thrust::system::system_error at memory location 0x0000000A8D8FE0D0.
console window prints the following message
CUDA error 8 [c:\program files\nvidia gpu computing toolkit\cuda\v10.0\include\thrust\system\cuda\detail\cub\iterator\../util_device.cuh, 151]: invalid device function
CUDA error 48 [C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include\thrust/system/cuda/detail/parallel_for.h, 143]: no kernel image is available for execution on the device
I was confused for a long time after searching so much information from the internet. Then I read the answers carefully again with this post CMakeLists Issue: bad_alloc error when calling resize() on thrust::device_vector. In this post, @Robert Crovella gave a solution link. I came across the answer. I tried to modify the architecture type with compute_30,sm_30, this problem was solved. Only then did I realize the reason is the architecture type for my GPU. More information is provided in this page. I set the compiling parameters in CMakeLists.txt from
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 75)
endif()
to
set(CMAKE_CUDA_ARCHITECTURES 53)
The architecture type will be set in the item of code generation.
No more errors occur.