rogerallen/raytracinginoneweekendincuda

Error when initialize 'rand_state' at the start of render() kernel

ZhiquanW opened this issue · 10 comments

I tried to initialize the rand_state at the start of render kernel but caused CUDA Error 799.Here is the code.
image

I've not seen this before and I do not find error 799 in the cudaError enums.

Can you show the exact error output?

Did it ever work? Did you modify the code to create a different or different-sized image?

Also, can you provide more info about your system? OS & Version, GPU Type, NVIDIA Driver version & CUDA library version?

Sorry, The error num is error 700 and here is the error message:
image
I changed nothing except moving the curand_init() to the start of render kernel.
I'm running the program on Ubuntu 18.04.2lts and my GPU is GTX940mx.
Here is the GPU information:
image

I also had problems with the random numbers in this project, it was quite a headache. It ended up being that ptxas was crashing. I think I worked around it by passing the random number into the scatter(...) function where it’s called in color(...).

I can reproduce it if anyone is curious.

@ZhiquanW That error is:

cudaErrorIllegalAddress = 700
    The device encountered a load or store instruction on an invalid memory address. 
This leaves the process in an inconsistent state and any further CUDA work will return 
the same error. To continue using CUDA, the process must be terminated and relaunched. 

and I think I recall trying this and getting similar errors which is why I have a separate render_init kernel. After a quick browse, I cannot find specific documentation in the curand docs about why this is necessary, but this is definitely the pattern that the examples follow. See https://docs.nvidia.com/cuda/curand/device-api-overview.html#device-api-overview 3.6. Device API Examples I'll continue to look for documentation of this requirement.

So, I'm not sure it is possible to create & use curand values in the same kernel. I'm not a curand expert (as you can also see in issue #2 😃)

@josiahblaisdell if you had repeatable errors with the code here, please file an issue with enough detail to help us dig into it. There may be issues that only pop up under certain circumstances & it will help others.

I posted it just in case someone else encounters a similar issue. I am having a hard time reproducing it now. I am not sure why... It was quite easy to reproduce a month ago. The only change I can think of that I have made to this code was that I rearranged things so that static functions and singletons are now a member of a base class from which all my classes derive and I moved all my .cu code into the header files.

By moving the .cu code from the .h file to the .cu file I am getting the following error:

ptxas fatal   : Cannot take address of function '_ZNK10Lambertian7scatterERK3RayRK9HitRecordR4vec3RS0_P17curandStateXORWOW'
# --error 0xff --
make: *** [RayTracer.cu.o] Error 255

@ZhiquanW what I found is this note:

Initialization of the random generator state generally requires more registers and local memory than random number generation. It may be beneficial to separate calls to curand_init() and curand() into separate kernels for maximum performance.

I do not quite know why that would lead to an illegal address crash, but it seems to.

@rogerallen

  • Thank you for your information.Recently,I tried to use curand_init() at the start of render() kernel in the newest version (chapter 12).The result shows no error message but it seems that randomization failed as the spheres in the scene looks the same.I will keep trying to find the reason.
  • The document shows that separating calls to curand_init() and curand() can bring a better performance.If it is true,i think it might be a little meaningless to combine them together as they bring no advantage.

I hope you noticed & took advantage of the performance improvement via issue #2.

Is this issue good to close?

Sure,Thank you for your help