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
along with a warning:
nvlink warning : SM Arch ('sm_20') not found in ...
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 separable compilation activated for my project.
Any help or hint would be appreciated.
UPDATE:
Requested by @RobertCrovella, here are some more infos.
The CUDA version is 7.5, which is newly installed on UBUNTU 14.04 with GTX980. I did not update the Thrust library after that.
The following is the actual command generated by cmake by using "make VERBOSE=1".
CMake script with separable compilation
CMake script without separable compilation
UPDATE 2:
The same error is confirmed by @merelyMark. Since both the code and the CMakeLists file are extremely simple, is it possible that this is a bug in Thrust / CUDA ? [EDIT] No.
UPDATE 3:
Pointed out by @RobertCrovella, thrust library is working fine with proper cmake comands. Now the question: how can I generate those commands using CMakeLists?