CUDA 5.5 出现 MSB3721 问题,求各路大神解决!
用的是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;
}