# Using multiple GPU devices from a single host thread

**URL:** <https://forums.developer.nvidia.com/t/using-multiple-gpu-devices-from-a-single-host-thread/19615>\
**Category:** CUDA Programming and Performance\
**Created:** [November 7, 2010, 6:04pm UTC](https://forums.developer.nvidia.com/t/using-multiple-gpu-devices-from-a-single-host-thread/19615 "2010-11-07T18:04:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vRavi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@vRavi](https://forums.developer.nvidia.com/u/vRavi)\
**Post date:** [November 7, 2010, 6:04pm UTC](https://forums.developer.nvidia.com/t/using-multiple-gpu-devices-from-a-single-host-thread/19615/1 "2010-11-07T18:04:18Z")

</div>

Hi,

I am trying to use multiple GPU devices (say deviceid 0 and 1) from a single host thread. I create 2 CUcontexts at the beginning one for each device (0 and 1). The place where the runtime APIs (cudamalloc, cudamemcpy, kernel launch etc.) are called, I try to switch between different CUcontexts that were created for each device. For switching, I use ctxPushCurrent and ctxPopCurrent around 1 or set of cudaRuntime APIs. But it seems like I cannot switch between device contexts. I have manually written code in such a way that two devices are operating on different set of memories. However, what I am experimenting is the use of multiple devices from a single host thread.

Please share your ideas, if you did any experiments on this topic.

Thank you!

---

<div class="post-metadata">

**Author:** ![vRavi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@vRavi](https://forums.developer.nvidia.com/u/vRavi)\
**Post date:** [November 7, 2010, 6:04pm UTC](https://forums.developer.nvidia.com/t/using-multiple-gpu-devices-from-a-single-host-thread/19615/2 "2010-11-07T18:04:18Z")

</div>

Hi,

I am trying to use multiple GPU devices (say deviceid 0 and 1) from a single host thread. I create 2 CUcontexts at the beginning one for each device (0 and 1). The place where the runtime APIs (cudamalloc, cudamemcpy, kernel launch etc.) are called, I try to switch between different CUcontexts that were created for each device. For switching, I use ctxPushCurrent and ctxPopCurrent around 1 or set of cudaRuntime APIs. But it seems like I cannot switch between device contexts. I have manually written code in such a way that two devices are operating on different set of memories. However, what I am experimenting is the use of multiple devices from a single host thread.

Please share your ideas, if you did any experiments on this topic.

Thank you!
