Thanks for digging into that problem.
I’ve tested your code again on another server with GTX1080 and CUDA 8.0.61 and it ran successfully a lot of times.
However, I managed to get one error for a single run. I cannot reproduce the error currently, but will have a look at your code again.