chrxh / alien

ALIEN is a CUDA-powered artificial life simulation program.
https://alien-project.org
BSD 3-Clause "New" or "Revised" License
3.48k stars 106 forks source link

CUDA error at CudaSimulationFacade.cu:179 #54

Closed dcasbol closed 1 year ago

dcasbol commented 1 year ago

Hi, I'm getting this error right after running the simulator. I can see first the window and then the logo flashscreen, but then it aborts. Any idea?

Issue When running alien I get the following error:

The following exception occurred: CUDA error at CudaSimulationFacade.cu:179 code=999(cudaErrorUnknown) "cudaGraphicsGLRegisterImage(&cudaResource, image, GL_TEXTURE_2D, cudaGraphicsMapFlagsReadOnly)"

See log.txt for more detailed information.
terminate called after throwing an instance of 'BugReportException'
  what():  CUDA error at RawMemory.cuh:52 code=1(cudaErrorInvalidValue) "cudaMemcpy(&data, _data, sizeof(unsigned char*), cudaMemcpyDeviceToHost)"
Aborted (core)

Context I'm running on Linux Ubuntu 22.04.1 LTS My GPU is a RTX3060 (laptop)

gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0 g++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0 Cuda compilation tools, release 11.7, V11.7.99 Build cuda_11.7.r11.7/compiler.31442593_0

chrxh commented 1 year ago

Hi, is your graphics driver up to date? Every CUDA version requires a minimum driver version. Is there anything else in the log.txt? It could be important to know which graphics card was selected, if there are more than one.

dcasbol commented 1 year ago

I installed the most recent CUDA toolkit from NVidia for my GPU. I am using now nvidia-driver-515 As of the log.txt, it doesn't provide much more info:

2022-08-30 09-58-56: set full screen mode
2022-08-30 09-58-56: network: get simulation list
2022-08-30 09-58-58: 1 CUDA device found
2022-08-30 09-58-58: device 0: NVIDIA GeForce RTX 3060 Laptop GPU with compute capability 8.6
2022-08-30 09-58-58: device 0 is set
2022-08-30 09-58-58: initialize simulation
2022-08-30 09-58-59: resize arrays
2022-08-30 09-58-59: cell array size: 200000
2022-08-30 09-58-59: particle array size: 200000
2022-08-30 09-58-59: token array size: 66666
2022-08-30 09-58-59: 682 MB GPU memory acquired
2022-08-30 09-58-59: The following exception occurred: CUDA error at CudaSimulationFacade.cu:179 code=999(cudaErrorUnknown) "cudaGraphicsGLRegisterImage(&cudaResource, image, GL_TEXTURE_2D, cudaGraphicsMapFlagsReadOnly)"

I can tell the error is an exception launched here at line 179 but I'm not familiar with the code base.

chrxh commented 1 year ago

It seems to be a CUDA-OpenGL interoperability issue. A possible reason for this could be that your RTX 3060 is not set up for OpenGL rendering, but another onboard graphics card. Could you please check the Nvidia Control Panel under 3D Settings -> Global Settings to see what is selected for "OpenGL rendering GPU"? image

dcasbol commented 1 year ago

That is exactly what was happening! My laptop is using the lightweight onboard GPU for running OpenGL OpenGL renderer string: AMD RENOIR (LLVM 13.0.1, DRM 3.42, 5.15.0-46-generic) I found this solution but it will take me a while to confirm it works. I will get back to you very soon. Thanks! :)

chrxh commented 1 year ago

Ok super, please let me know if it worked.

dcasbol commented 1 year ago

I finally managed it to run :) I had to run sudo prime-select nvidia and reboot for setting the GPU card as the main renderer. I'm now somehow unable to open example sim files, but that's another issue and hopefully I can solve it on my own. Dankeschön! :+1: :smile: