jan-van-bergen / GPU-Raytracer

GPU Raytracer from scratch in C++/CUDA
MIT License
818 stars 46 forks source link

Building on CUDA 10.2. Problem with CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES. #27

Closed openGLnoob closed 2 years ago

openGLnoob commented 2 years ago

First of all thank you Jan for this great library! I try to build this on my old GPU (CC 3.0 and CUDA 10.2 as maximum compabilility). I solved some problem with "--std=c++17" or __ldg but I can't to solve a problem with exception:

CUDAKernel.h line 120 failed with error CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES! too many resources requested for launch

I get exception on calling the execute_material_kernel. I checked parameters of cuLaunchKernel and it's fine. If I disable scene.has_diffuse, scene.has_plastica and scene.has_dielectric I get a black scene but everything works. I am trying to decrease some value: BATCH_SIZE, PARAMETER_BUFFER_SIZE, WARP_SIZE, MAX_REGISTERS, width and height the screen, bounse/samples, scenes but nothing helps. What parameters of scene could I change for my weak configuration? :( Thank you!

jan-van-bergen commented 2 years ago

Thank you for reporting this, I recently made changes to the way the Material kernels work and it seems I've made a mistake. The kernels were being called with too many arguments (not really sure why I didn't get an error about this myself).

I've fixed this in 994d01d02cc9bb24334a763c6d04d43c13ab0d88, hopefully this also fixes the error.

openGLnoob commented 2 years ago

Thank you for responce!!!! I hope this is a general issue, not related to my specific configuration of CUDA 10.2. I'll try it and give feedback. Thank you again! :)

openGLnoob commented 2 years ago

Yes, this fixed the problem with starting CUDA! Thank you! But BTW I get this errors when compile the kernel:

 Pathtracer(515): error: class "MaterialDielectric" has no member "texture_id"...
 Pathtracer(537): error: class "BSDFDielectric" has no member "calc_albedo"...

If I replace BSDF bsdf; to BSDFDiffuse bsdf; or another BSDF it fixed problems. I think this is C++17 template problem or somethink like that.

jan-van-bergen commented 2 years ago

Hmm that seems to be caused by the if constexpr at line 512 not being available pre C++17.

Why are you not able to use C++ 17 exactly, is it not supported for some reason? I could try to make some changes so it at least works with C++14 if needed.

openGLnoob commented 2 years ago

Thank you for responce! You are right! if constexpr is not availabe in c++14. When I compile with:

const char * options[] = {
"--std=c++17"...

I get the error: nvrtc: error: invalid value for --std (-std) with my CUDA 10.2. This is why I need to set "--std=c++14" and delete if constexpr. :( If it doesn't make it difficult, it would be great if you could tell me what to fix.

jan-van-bergen commented 2 years ago

Ah I see, I had no idea there was a limit on C++ standard for different versions of CUDA.

I have changed things so the device code now builds under C++11. There was no real need to rely on C++14 or C++17 features and its probably better have less dependency anyway.

It should now compile then.

openGLnoob commented 2 years ago

Thank you! Now it works as expected! \(≧▽≦)/