'cudafe++' died with status 0xC0000005 (ACCESS_VIOLATION)

I’m trying to compile this program:

global void cuda_hello(){

printf("Hello World from GPU!\n");

}

int main() {

cuda_hello<<<1,1>>>();

return 0;

}’
But I’m getting the following error:
cudafe++’ died with status 0xC0000005 (ACCESS_VIOLATION)

GPU: gtx 1650
OS : Win 11
CUDA : v11.6

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.

Hello!
I ran this on visual studio and got a more detailed error along with the access violation error:

Severity Code Description Project File Line Suppression State
Error MSB3722 The command C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\bin\nvcc.exe -gencode=arch=compute_52,code=\sm_52,compute_52\ –use-local-env -ccbin D:\Program Files\vs\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64 -x cu -IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\include -IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\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:\notes\pcap\cuda\proj\CudaRuntime1\CudaRuntime1\x64\Debug\kernel.cu.obj D:\notes\pcap\cuda\proj\CudaRuntime1\CudaRuntime1\kernel.cu exited with code 5. Please verify that you have sufficient rights to run this command. CudaRuntime1 D:\Program Files\vs\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 11.6.targets 790

Please help me if u can

Hello, thanks for the reply! Do you know how I can solve this issue, or diagnose it?

If you don’t want to answer the questions I ask, I won’t be able to help you. Perhaps someone else will know what to do.

I am not able to compile the sample code as well

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.

1 Like

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.

Thank you any way, :(

I am getting the same issue

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.

4 Likes

Thanks LazyStreamer this was a life saver, do we know why it dosen’t work on 32 bit or if someone experienced has an idea? Does it matter?

Edit: I found this in a post, so I guess this is the answer? Not exactly sure with all the terms and what not.

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;
}`

When I firstly installed Visual Studio, and simply open ‘Developer Command Prompt for VS 2022’, the ‘path’ indicate x86 version of build tools. and that was the reason of compliler crushed. so, you should just open NORMAL CMD PROMPT and set path manually to indicate x64 version of compiler by ‘set path=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64;%path%’ which is mine and you should change compiler path as your environment set.

In my case, switching from “x86” to “x64” fixed the issue.

I did this by keeping only the x64 path in the system environment variable: D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\Hostx64\x64 and restart successfully resolved the problem