Reset 'setdevice()' when creating thread

Even if I set it to run on GPU 1 from main() to setdevice(), if I create a thread and have the cuda function run inside the thread, it will reset back to GPU 0.

What’s wrong?

Do I always have to initialize GPU index to 1 every time I create a thread?