I am new to thrust library and trying to use it in my project. Here is a very simple code example. It can be compiled without any problem. However, when I try to run it, it gives me an error:
terminate called after throwing an instance of 'thrust::system::detail::bad_alloc'
what(): std::bad_alloc: unknown error
The project can be reproduced by using the following two files.
test.cpp
#include <thrust/device_vector.h>
int main(){
thrust::device_vector<int> x;
x.resize(10);
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.9)
project(test_project)
find_package(CUDA QUIET REQUIRED)
list(APPEND CUDA_NVCC_FLAGS "-std=c++11;-arch=compute_52")
set(CUDA_SEPARABLE_COMPILATION ON)
cuda_add_executable("cuda_test" "test.cu")
After some testing, it is obvious that if the line "set(CUDA_SEPARABLE_COMPILATION ON)" is removed, the program runs without problem. But I really need spearable compilation activated for my project.
Any help or hint would be appreciated.
