Fix multithreaded cuda select device
Merge pull request #739 from sklam/fix_cuda_mt_select_device

Fix multithreaded cuda select device