I would suggest using the method outlined here to identify the specific line of code that is generating the cuda-memcheck error. Work backwards from that point to identify precisely how the invalid address is being generated. If you need help with that, get the process started, post your results including the line of code, and ask questions about what to do next.