CUDA error randomly occurring with specific files

I’m only asking for help after spending a LOT of time trying to solve this problem for myself.

I have been having an odd and distressing problem. Several times now I have had a scene I have been working on, that has rendered fine for days and days, and suddenly for no obvious reason, any attempt to render it (even in viewport) causes something odd to happen with my video card. The render will get partway through and then turn into garbage, and my console fills with errors like this:CUDA error: Launch failed in cuCtxSynchronize()

Refer to the Cycles GPU rendering documentation for possible solutions:
http://www.blender.org/manual/render/cycles/gpu_rendering.html

CUDA error: Launch failed in cuCtxSynchronize()
CUDA error: Launch failed in cuMemFree(cuda_device_ptr(mem.device_pointer))
CUDA error: Launch failed in cuMemFree(cuda_device_ptr(mem.device_pointer))
CUDA error: Launch failed in cuGraphicsUnregisterResource(pmem.cuPBOresource)
CUDA error: Launch failed in cuMemFree(cuda_device_ptr(mem.device_pointer))
CUDA error: Launch failed in cuMemFree(cuda_device_ptr(mem.device_pointer))
… snipped for repetition
CUDA error: Launch failed in cuMemFree(cuda_device_ptr(mem.device_pointer))
CUDA error: Launch failed in cuMemFree(cuda_device_ptr(mem.device_pointer))
CUDA error: Launch failed in cuMemFree(cuda_device_ptr(mem.device_pointer))
CUDA error at cuCtxCreate: Launch failed

Refer to the Cycles GPU rendering documentation for possible solutions:
http://www.blender.org/manual/render/cycles/gpu_rendering.html

CUDA error: Invalid context in cuMemAlloc(&device_pointer, size)
CUDA error: Invalid context in cuMemAlloc(&device_pointer, size)
CUDA error: Invalid context in cuMemAlloc(&device_pointer, size)

I know enough to tell that this is an issue with Blender communicating with my video card, but not what is causing it. I know it’s nothing to do with the complexity of the scene, because if I revert to a backup from some hours prior with NOTHING changed other than poses and other object translations, it will render just fine. And this has been happening with some very simple scenes and not with more complex ones.

I’ve gone to the link provided and found nothing apropos. Searching for the errors only gets me a lot of old and specific bug reports.

So basically when this happens, I can no longer render the file, and if I do not have an old enough backup, I have to go through the process of moving everything in the scene to a new file. And yes, moving EVERYTHING over, every single object and all of the render settings fixes the problem.

I can share my actual blend file if needed, but it’s a NSFW semi-commission so I’m not defaulting to throwing it out there immediately.

Addendum: It also only produces this video card crash(?) from certain viewpoints within the scene. I’ve tried using odd camera positions and it renders fine, but when I view even a viewport render from certain locations, then I get the CUDA error, and after that no rendering will work in that file until I close and restart.

Oh, additional info if it should be needed: I have a brand spanking new GTX 1080, and yes I updated to the latest drivers. I am running Blender 2.78 RC2

Ah, I found the issue. I apparently experimentally enabled branched path tracing and forgot I had done so… and managed to miss that when going over settings. I still don’t know WHY that caused the odd behavior sometimes and not others, but disabling it seems to have resolved the issue. Leaving this up in case anyone else has the same issue.

I’ve had this exact issue many times while rendering overclocked to 114% stock speeds on my STRIX GTX 1070. While this occurred on regular path tracing, the branched path tracing caused it to fail almost immediately. If you are overclocking, try resetting it to default speeds. Blender seems super sensitive to overclocking.

As it happens, I’m not, but that’s worth knowing