CUDA 5.5 出现 MSB3721 问题,求各路大神解决!

MrChrist 2014-09-09 10:02:59
用的是VS2012+CUDA5.5,在windows8.1平台下。

使用的是Viennal-CL 提供的一个案例程序 wrap-cuda-buffer,运行后出现这样的问题:

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 5.5.targets(592,9): error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2012 -ccbin "G:\Program Files\Mircosoft\Visual Studio2012\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\wrap-cuda-buffer.cu.obj "G:\2014.8.16\cudadada4\cuda4\cuda4\wrap-cuda-buffer.cu"”已退出,返回代码为 2。

请大神们帮着看看呀……

代码是这样的:

/* =========================================================================
Copyright (c) 2010-2014, Institute for Microelectronics,
Institute for Analysis and Scientific Computing,
TU Wien.
Portions of this software are copyright by UChicago Argonne, LLC.

-----------------
ViennaCL - The Vienna Computing Library
-----------------

Project Head: Karl Rupp rupp@iue.tuwien.ac.at

(A list of authors and contributors can be found in the PDF manual)

License: MIT (X11), see file LICENSE in the base directory
============================================================================= */

/*
*
* Tutorial: Use ViennaCL with user-provided CUDA buffers
*
*/


//
// include necessary system headers
//
#include <iostream>
#include <cstdlib>
#include <string>
#include "cuda_runtime.h"
#include <cuda.h>

//
// ViennaCL includes
//
#include "viennacl/vector.hpp"
#include "viennacl/matrix.hpp"
#include "viennacl/linalg/matrix_operations.hpp"
#include "viennacl/linalg/norm_2.hpp"
#include "viennacl/linalg/prod.hpp"


// Some helper functions for this tutorial:
#include "Random.hpp"

//
// A simple CUDA kernel for the vector operation x += y
//
template <typename T>
__global__ void my_inplace_add_kernel(T * vec1, T * vec2, unsigned int size)
{
for (unsigned int i = blockDim.x * blockIdx.x + threadIdx.x;
i < size;
i += gridDim.x * blockDim.x)
vec1[i] += vec2[i];
}



int main()
{
typedef float ScalarType;

//
// Part 1: Allocate some CUDA memory
//
std::size_t size = 10;
ScalarType *cuda_x;
ScalarType *cuda_y;

cudaMalloc(&cuda_x, size * sizeof(ScalarType));
cudaMalloc(&cuda_y, size * sizeof(ScalarType));

// Initialize with data
std::vector<ScalarType> host_x(size, 1.0);
std::vector<ScalarType> host_y(size, 2.0);

cudaMemcpy(cuda_x, &(host_x[0]), size * sizeof(ScalarType), cudaMemcpyHostToDevice);
cudaMemcpy(cuda_y, &(host_y[0]), size * sizeof(ScalarType), cudaMemcpyHostToDevice);

// run kernel
my_inplace_add_kernel<<<128, 128>>>(cuda_x, cuda_y, static_cast<unsigned int>(1000));

// copy result back
std::vector<ScalarType> result_cuda(size);
cudaMemcpy(&(result_cuda[0]), cuda_x, size * sizeof(ScalarType), cudaMemcpyDeviceToHost);

std::cout << "Result with CUDA (native): ";
for (std::size_t i=0; i<size; ++i)
std::cout << result_cuda[i] << " ";
std::cout << std::endl;

//
// Part 2: Now do the same within ViennaCL
//

// wrap the existing CUDA buffers inside ViennaCL vectors
viennacl::vector<ScalarType> vcl_vec1(cuda_x, viennacl::CUDA_MEMORY, size); // Second parameter specifies that this is CUDA memory rather than host memory
viennacl::vector<ScalarType> vcl_vec2(cuda_y, viennacl::CUDA_MEMORY, size); // Second parameter specifies that this is CUDA memory rather than host memory

// reset values to 0 and 1, respectively
vcl_vec1 = viennacl::scalar_vector<ScalarType>(size, ScalarType(1.0));
vcl_vec2 = viennacl::scalar_vector<ScalarType>(size, ScalarType(2.0));

vcl_vec1 += vcl_vec2;

std::cout << "Result with ViennaCL: " << vcl_vec1 << std::endl;

// ViennaCL does not automatically free your buffers (you're still the owner), so don't forget to clean up :-)
cudaFree(cuda_x);
cudaFree(cuda_y);

//
// That's it.
//
std::cout << "!!!! TUTORIAL COMPLETED SUCCESSFULLY !!!!" << std::endl;

return EXIT_SUCCESS;
}
...全文
2490 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
silentteller 2017-03-27
  • 打赏
  • 举报
回复
请问您是如何解决的,我也有相同的问题。
风来我也来 2015-01-09
  • 打赏
  • 举报
回复
引用 4 楼 u013512179 的回复:
原来是我用的第三方库的头文件有个BUG,嘿嘿,结贴。
什么样的用法会导致这问题,怎么看?
米饭的白色 2014-11-15
  • 打赏
  • 举报
回复
引用 4 楼 u013512179 的回复:
原来是我用的第三方库的头文件有个BUG,嘿嘿,结贴。
我也遇到同样的问题,求指导!!不胜感激!!
MrChrist 2014-09-15
  • 打赏
  • 举报
回复
原来是我用的第三方库的头文件有个BUG,嘿嘿,结贴。
YCMyTot 2014-09-14
  • 打赏
  • 举报
回复
那就,不晓得了!
MrChrist 2014-09-10
  • 打赏
  • 举报
回复
没有哦,我的路径是这个,没有中文的 G:\2014.8.16\cudadada4\cuda4
YCMyTot 2014-09-10
  • 打赏
  • 举报
回复
是不是你的 路径下 ,包含 中文 ? CUDA 编译的时候,貌似 路径下 不能包含中文!

581

社区成员

发帖
与我相关
我的任务
社区描述
CUDA™是一种由NVIDIA推出的通用并行计算架构,该架构使GPU能够解决复杂的计算问题。 它包含了CUDA指令集架构(ISA)以及GPU内部的并行计算引擎。
社区管理员
  • CUDA编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧