I am trying to run the following code on VS 2022 using cuda_11.7.0_516.01 but I am getting two errors. The operating system is windows x64 and the GPU is GeForce GT 710, by the way I didn’t find this GPU in the nvidia enabled CUDA list but I guessed maybe they were different products under the same name and assumed it supports CUDA as far as I didn’t have any problem during installation.
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#define arraySize 1000
__global__ void addKernel( int *c, const int *a, const int *b )
{
int i = threadIdx.x;
if( i < arraySize )
c[i] = a[i] + b[i];
}
int main()
{
int a[arraySize];
int b[arraySize];
int c[arraySize];
int *dev_a = 0;
int *dev_b = 0;
int *dev_c = 0;
// fill the arrays 'a' and 'b' on the CPU
for( int i = 0 ; i < arraySize ; i++ ) {
a[i] = i;
b[i] = i;
}
// Add vectors in parallel.
// Allocate GPU buffers for three vectors (two input, one output)
cudaMalloc((void**)&dev_c, arraySize * sizeof(int));
cudaMalloc((void**)&dev_a, arraySize * sizeof(int));
cudaMalloc((void**)&dev_b, arraySize * sizeof(int));
// copy the arrays 'a' and 'b' to the GPU
cudaMemcpy(dev_a, a, arraySize * sizeof(int), cudaMemcpyHostToDevice);
cudaMemcpy(dev_b, b, arraySize * sizeof(int), cudaMemcpyHostToDevice);
addKernel<<<1, arraySize>>>(dev_c, dev_a, dev_b);
cudaDeviceSynchronize();
// copy the array 'c' back from the GPU to the CPU
cudaMemcpy(c, dev_c, arraySize * sizeof(int), cudaMemcpyDeviceToHost);
// display the results
for( int i = 0 ; i < arraySize ; i++ ) {
printf( "%d + %d = %d\n", a[i], b[i], c[i] );
}
// free the memory allocated on the GPU
cudaFree(dev_c);
cudaFree(dev_a);
cudaFree(dev_b);
return 0;
}
The errors are
Severity Code Description Project File Line Suppression State
Error MSB3721 The command ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin\nvcc.exe”
-gencode=arch=compute_52,code="sm_52,compute_52" --use-local-env -ccbin “C:\Program Files
\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64” -x cu
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include”
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\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 /Fdx64\Debug\vc143.pdb
/FS /Zi /RTC1 /MDd " -o “D:\Tested Code\CudaRuntime2\x64\Debug\kernel.cu.obj” “D:\Tested Code\CudaRuntime2
kernel.cu”” exited with code 1. CudaRuntime2 C:\Program Files\Microsoft Visual Studio\2022
\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\ CUDA 11.7.targets 790
and
Severity Code Description Project File Line Suppression State
Error (active) E0029 expected an expression CudaRuntime2 D:\Tested Code\CudaRuntime2\kernel.cu 42
It is worth mentioning that I don’t find the sm_52 in this path “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include”.
I appreciate your help in advance.