This is unlikely to be a latent issue in CUDA. My guess would be that the problem is some sort of installation problem - e.g. out of disk space, not having permissions for various directories (for example compiling code in a directory structure you don’t have write access to), incorrect install location, etc. There’s not enough information here to diagnose the problem, and I wouldn’t be able to give you a recipe of all the things to check. There may also be some sort of unexpected project setting. Are you able to compile successfully one of the CUDA sample projects using the supplied project file?
A few things I noticed are:
you don’t have a #include <cstdio> statement or similar, which is needed for printf, but you may have that in your actual test case, and I think in windows it may be included automatically.
You have a single quote at the end of your posted code: ’
Your code is not formatted properly (see here for typical instructions
I don’t think any of those statement are related to the cudafe++ issue.
Historically, the most common reason for this particular kind of error in this particular toolchain component has been the mixing of a toolchain from one CUDA version with the header files from a different CUDA version.
My hypothesis is that you either have an incomplete or corrupted installation of CUDA, or a configuration issue (e.g. environment variables) that cause mixing of components from multiple installed CUDA versions.
If you only ever installed one CUDA version, that would eliminate the possibility of the latter scenario. De-installing and wiping the current CUDA installation, then re-installing CUDA would address the former scenario. When doing so, make sure there is sufficient disk space (in the partition you are installing in) and your user account has the necessary operating system permissions for installing software.
I reinstalled and installed cuda 11.6 multiple times and it still gives me the error. I also tried installing cuda 10.2 after uninstalling 11 but gave me the same error. Cuurently i have only 11.6 version
Multiple CUDA versions reporting an access violation in cudafe++is a very strange scenario. I would suggest double checking available disk space and file permissions. I have no additional ideas. It is difficult to diagnose these issues over the internet.
I had the same issue and thought I would share my issue for future viewers. In short, I was using the x86 version of cl.exe when I was getting this error. Once I switched to the x64 version everything compiled without error. Since I am writing code for personal use I don’t really care whether I get a 32bit or 64bit executable.
I m having the same issue. Mine was already on x64 build and debug. Im new to cuda and VS.
My code`#include include “cuda_runtime.h” include “device_launch_parameters.h”
include <stdio.h> global void add(int a, int b, int* c) { c = a + b;
}
int main(void) {
int c;
int dev_c;
cudaMalloc((void**)&dev_c, sizeof(int));
add <<<1,1>>> (2, 7, dev_c);
cudaDeviceSynchronize();
cudaMemcpy(&c,dev_c,sizeof(int),cudaMemcpyDeviceToHost);
printf(“2 + 7 = %d\n”, c);
cudaFree(dev_c);
return 0;
}`