thrust::device_vector可以在核函数中使用吗?

假如我要在核函数中循环创建同一个数组,使用NEW创建数组,使用全局变量是不可以循环创建同一个数组的,我想使用 thrust::device_vector来实现循环创建数组.
我有一段代码,不知道怎么修改可以通过编译,
#include <cuda_runtime.h>
#include <thrust/reduce.h>
#include <thrust/device_ptr.h>
#include <thrust/device_malloc.h>
#include <thrust/device_free.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <thrust/fill.h>
#include <thrust/sequence.h>
#include <stdio.h>

global void gpu1(thrust::device_vector vectord,int n)
{
for(int i = 0; i < n; ++i)
{
printf(“vectord[%d] = %f\n”,i,vectord[i]);
}
}
global void gpu()
{
thrust::device_vector vectord(10);
for(int i = 0;i < 10; ++i)
{
vectord.push_back(i);
}
gpu1<<<1,1>>>(vectord,10);

}

int main()
{
gpu<<<1,4>>>();
cudaDeviceReset();
return 0;
}
nvcc device_vector.cu -arch=sm_52 -rdc=true
使用这行命令不能成功.

thrust::device_vector cannot be used in device code.

You can extract a pointer to the underlying data and use that if you wish, but the device_vector object itself is not usable in device code, nor are any of its methods such as push_back

If you need to do allocation in device code, you will need to use in-kernel malloc, or new, or cudaMalloc