# Nested "for" in a device function

**URL:** <https://forums.developer.nvidia.com/t/nested-for-in-a-device-function/38070>\
**Category:** CUDA Programming and Performance\
**Created:** [May 23, 2015, 6:00pm UTC](https://forums.developer.nvidia.com/t/nested-for-in-a-device-function/38070 "2015-05-23T18:00:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dalspenguin](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@dalspenguin](https://forums.developer.nvidia.com/u/dalspenguin)\
**Post date:** [May 23, 2015, 6:00pm UTC](https://forums.developer.nvidia.com/t/nested-for-in-a-device-function/38070/1 "2015-05-23T18:00:50Z")

</div>

test

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [May 23, 2015, 6:53pm UTC](https://forums.developer.nvidia.com/t/nested-for-in-a-device-function/38070/2 "2015-05-23T18:53:59Z")

</div>

There’s no limit on the number of nested for loops. You probably have an indexing-out-of-bounds problem (perhaps in your texture accesses). Use debugging techniques like the method described in the answer here:

[url][cuda - Unspecified launch failure on Memcpy - Stack Overflow](http://stackoverflow.com/questions/27277365/unspecified-launch-failure-on-memcpy%5B/url%5D)

to prove or disprove this theory, isolate the out-of-bounds access to a specifc line of code, and then begin investigating your indexing in more detail.

---

<div class="post-metadata">

**Author:** ![dalspenguin](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@dalspenguin](https://forums.developer.nvidia.com/u/dalspenguin)\
**Post date:** [May 23, 2015, 7:49pm UTC](https://forums.developer.nvidia.com/t/nested-for-in-a-device-function/38070/3 "2015-05-23T19:49:45Z")

</div>

I guess, it’s something like timeout.

Is there any timeout settings in CUDA for a single device function?  
It’s just looked like only the number of iterations plays some kind of role.  
javascript:void();

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [May 23, 2015, 7:51pm UTC](https://forums.developer.nvidia.com/t/nested-for-in-a-device-function/38070/4 "2015-05-23T19:51:56Z")

</div>

Yes, there are timeout settings on both windows and linux.

There is a sticky thread right at the top of this forum that discusses the windows timeout settings:

[url][https://devtalk.nvidia.com/default/topic/459869/cuda-programming-and-performance/-quot-display-driver-stopped-responding-and-has-recovered-quot-wddm-timeout-detection-and-recovery-/[/url]](https://devtalk.nvidia.com/default/topic/459869/cuda-programming-and-performance/-quot-display-driver-stopped-responding-and-has-recovered-quot-wddm-timeout-detection-and-recovery-/%5B/url%5D)
