MSB 3721 and syntax error when running CUDA code

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.

We would need to know what is on line 42 in the file kernel.cu.

Apart from that, sm_52 is definitely not the right compute capability for your GT 710 GPU.

The TechPowerUp database lists two different variants of the GT 710, one based on GF119 (compute capability 2.1, sm_21), the other based on GK208B (compute capability 3.5, sm_35). The former is not supported by CUDA 11.7, while the latter is supported.

The release notes for CUDA 11.7 state that support for sm_35 is deprecated, which means that this support will likely disappear with the next major CUDA release.

This is line 42
addKernel << <1, arraySize >> > (dev_c, dev_a, dev_b);
but I didn’t get what do you mean?

sm_52 is definitely not the right compute capability for your GT 710 GPU

What is the right compute capability for my GPU?

Then I would say your CUDA install is broken. I won’t be able to diagnose it for you. Somehow the visual studio integration did not happen correctly.

I don’t know exactly what is the right compute capability for your GPU. It would require me to have a proper CUDA setup and run a sample code like deviceQuery.

Did you read the comments by njuffa? That is as much as I can say. Some GT 710 GPUs would be compute capability 2.1 (not supported by any CUDA version after 8.0. I don’t believe that is applicable here because you would be having driver troubles. But I don’t have your machine here in front of me to double check all my assumptions.) Some GT 710 GPUs would be compute capability 3.5, which would need to be specified explicitly in the visual studio project setup. There are various online forum posts explaining how to set compute capability in VS project setup.

Even if you fixed that compute capability issue, the E0029 is still going to be a roadblock.

maybe this helps. The compute_52 and sm_52 were already under CUDA C/C++ ,Device Code Generation. I didn’t add this.

yes, that will need to be changed for your device, if it works at all.

In CUDA 11.7, compute_52 and sm_52 are the default target architectures used by nvcc (see its documentation, section 4.2.7.1). In your case, this default is not applicable, and you must specify the architecture (compute capability) corresponding to your device.