void Test_Thread()
{
int id;
cudaGetDevice(&id);
cout << " thread "<<id << endl;
}
void Tt()
{
cudaSetDevice(1);
int id;
cudaGetDevice(&id);
cout <<"main "<< id << endl;
thread t(Test_Thread);
t.join();
}
主线程设置的GPU不会被继承,子线程会默认切换到0号GPU上。
主线程设置的GPU不会被继承,子线程会默认切换到0号GPU上。
主线程设置的GPU不会被继承,子线程会默认切换到0号GPU上。
需要重新设置工作的GPU id