fix compilation crash recently introduced on the cuda code.
Merge pull request #1671 from nouiz/crash-fix

fix compilation crash recently introduced on the cuda code.