我知道已经存在一些问题,但我的系统仍完全无法编译支持的标准Cuda Runtime 9.1内核,有2个错误,
1>c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt/host_config.h(135): fatal error C1189: #error: -- unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\BuildCustomizations\CUDA 9.1.targets(707,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin\nvcc.exe" -gencode=arch=compute_30,code=\"sm_30,compute_30\" --use-local-env --cl-version 2017 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\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 /FS /Zi /RTC1 /MDd " -o x64\Debug\kernel.cu.obj "C:\Users\rjlea\OneDrive\Documents\Visual Studio 2017\Projects\CudaRuntime Experiment 3\CudaRuntime Experiment 3\kernel.cu"" exited with code 2.
我在编辑host_config.h时已经看过了,我已经多次这样做了,我根本不允许将它保存到目录中。
我是GPGPU编程的新手,我只是想让Cuda 9.1在Visual Studio 2017上运行。我还安装了VS 2015 v140平台工具集。这是我正在尝试运行的代码;
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#define SIZE 1024
__global__ void VectorAdd(int *a, int *b, int *c, int n)
{
int i = threadIdx.x;
if (i < n)
{
c[i] = a[i] + b[i];
}
}
int main()
{
int *a, *b, *c;
cudaMallocManaged(&a, SIZE * sizeof(int));
cudaMallocManaged(&b, SIZE * sizeof(int));
cudaMallocManaged(&c, SIZE * sizeof(int));
for (int i = 0; i < SIZE; ++i)
{
a[i] = i;
b[i] = i;
c[i] = 0;
}
VectorAdd <<<1, SIZE>>> (a, b, c, SIZE);
cudaDeviceSynchronize();
for (int i = 0; i < 10; ++i)
{
printf("c[%d] = %d\n", i, c[i]);
}
cudaFree(a);
cudaFree(b);
cudaFree(c);
return 0;
}
感谢。