简体   繁体   English

CUDA推力的2D device_vector错误

[英]2D device_vector error with CUDA Thrust

I wrote a simple code using CUDA Thrust. 我使用CUDA Thrust编写了一个简单的代码。 I need to allocate a 2D vector on the GPU, but I am getting error MSB3721 我需要在GPU上分配2D向量,但error MSB3721

D:\\Cuda\\NVIDIA GPU Computing Toolkit\\CUDA\\v6.0\\include\\thrust/device_vector.h(52): error : External calls are not supported (found non-inlined call to _ZN6thrust6detail11vector_baseIiNS_23device_malloc_allocatorIiEEED2Ev) kernel.cu C:\\Program Files (x86)\\MSBuild\\Microsoft.Cpp\\v4.0\\V110\\BuildCustomizations\\CUDA 6.0.targets(597,9): error MSB3721: The command ""D:\\Cuda\\NVIDIA GPU Computing Toolkit\\CUDA\\v6.0\\bin\\nvcc.exe" -gencode=arch=compute_10,code=\\"sm_10,compute_10\\" --use-local-env --cl-version 2012 -ccbin "D:\\Microsoft Visual Studio 11.0\\VC\\bin\\x86_amd64" -I"D:\\Cuda\\NVIDIA GPU Computing Toolkit\\CUDA\\v6.0\\include" -I"D:\\Cuda\\NVIDIA GPU Computing Toolkit\\CUDA\\v6.0\\include" -G --keep-dir x64\\Debug -maxrregcount=0 --machine 64 --compile -cudart static -g -DWIN32 -DWIN64 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o x64\\Debug\\kernel.cu.obj "D:\\VS Codes\\Projects\\CUDASimpleImageProcessing\\CUDASimpleImageProcessing\\kernel.cu"" exited with code 2. ======== D:\\ Cuda \\ NVIDIA GPU Computing Toolkit \\ CUDA \\ v6.0 \\ include \\ thrust / device_vector.h(52):错误:不支持外部调用(发现对_ZN6thrust6detail11vector_baseIiNS_23device_malloc_allocatorIiEEED2Ev的非内联调用)kernel.cu C:\\ Program文件(x86)\\ MSBuild \\ Microsoft.Cpp \\ v4.0 \\ V110 \\ BuildCustomizations \\ CUDA 6.0.targets(597,9):错误MSB3721:命令“” D:\\ Cuda \\ NVIDIA GPU Computing Toolkit \\ CUDA \\ v6。 0 \\ bin \\ nvcc.exe“ -gencode = arch = compute_10,code = \\” sm_10,compute_10 \\“ --use-local-env --cl-version 2012 -ccbin” D:\\ Microsoft Visual Studio 11.0 \\ VC \\ bin \\ x86_amd64“ -I” D:\\ Cuda \\ NVIDIA GPU计算工具包\\ CUDA \\ v6.0 \\ include“ -I” D:\\ Cuda \\ NVIDIA GPU计算工具包\\ CUDA \\ v6.0 \\ include“ -G- keep-dir x64 \\ Debug -maxrregcount = 0 --machine 64 --compile -cudart static -g -DWIN32 -DWIN64 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler“ / EHsc / W3 / nologo / Od / Zi / RTC1 / MDd” -o x64 \\ Debug \\ kernel.cu.obj“ D:\\ VS Codes \\ Projects \\ CUDASimpleImageProcessing \\ CUDASimpleImageProcessing \\ kernel.cu”“用代码2退出。======== == Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ==构建:0成功,1失败,0最新,跳过0 ==========

The code is 该代码是

#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
using namespace thrust;
int main()
{
int height = 5, width = 5;
device_vector<device_vector<int>> d_ndata (height, device_vector<int> (width, 0));
//  d_ndata.resize(newheight, vector<uchar> (newwidth, 0));

return 0;
}

Help pls... 帮助请...

Thrust doesn't enable to deal with vectors of vectors. 推力无法处理向量的向量。 You should flatten your matrix to a single vector like the following example: 您应该将矩阵展平为单个矢量,如以下示例所示:

#include <thrust/host_vector.h>
#include <thrust/device_vector.h>

using namespace thrust;

int main()
{
    int height = 5, width = 5;
    device_vector<int> d_ndata(height*width);

    return 0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM