在cudaStreamSynchronize之前需要cudaSetDevice吗?

问题描述

在我的系统中,我同时编程多个GPU。我需要在致电cudaSetDevice()之前先致电cudaStreamSynchronize()吗?

在创建cudaStream_t对象时,我确实在调用cudaStreamCreate()之前正确设置了设备。

解决方法

我可能是错的,但是如果您在创建流时已经使用过函数cudaSetDevice(),那么我认为您不需要再次调用该函数。{p>

资源:

https://developer.nvidia.com/blog/cuda-pro-tip-always-set-current-device-avoid-multithreading-bugs/

https://forums.developer.nvidia.com/t/how-many-times-does-cudasetdevice-need-to-be-called/10646

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...