# Too many resources requested for launch

**URL:** <https://discourse.julialang.org/t/too-many-resources-requested-for-launch/69100>\
**Category:** GPU\
**Created:** [October 2, 2021, 7:44am UTC](https://discourse.julialang.org/t/too-many-resources-requested-for-launch/69100 "2021-10-02T07:44:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakub\_Mitura](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakub_mitura/32/19496_2.png) [@Jakub\_Mitura](https://discourse.julialang.org/u/Jakub_Mitura)\
**Post date:** [October 2, 2021, 7:44am UTC](https://discourse.julialang.org/t/too-many-resources-requested-for-launch/69100/1 "2021-10-02T07:44:25Z")

</div>

I get “too many resources requested for launch” in CUDA.jl kernel when I try to either

set value to the array set in global memory like

> mainWorkQueue[1,1]=1

OR print anything using

> CUDA.@cuprint “aa”

I suspect that It is becouse the amount of registers use is too high so

1. I suppose that in this case it may be related to caching reasults fetched from global memory - can i swith it off?
2. can i run GC on variables in register memory - so I would manually clear it before problem arise (CUDA.unsafe\_free!() seems to work on arrays only - am I wrong? )
3. How can I increase maxrregcount in CUDA.jl ?

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [October 4, 2021, 5:51am UTC](https://discourse.julialang.org/t/too-many-resources-requested-for-launch/69100/2 "2021-10-04T05:51:07Z")

</div>

Please don’t double-post. Here’s my response from Slack:

> can’t you just launch fewer threads? it’s recommended to use the occupancy API to have it automatically decide how many threads to launch
> 
> maxregcount is an argument to @cuda, but it’ll result in spilling, so your kernel will be slow
> 
> you need to try and reduce register pressure, e.g., by avoiding converting values between types, or throwing exceptions, etc. inspect the generated code for that
> 
> GC doesn’t apply at all here
> 
> as a last-resort solution you can try splitting the kernel
> 
> but you probably don’t need all that, just make sure your kernel can handle any thread count and use the occupancy API
