# Free GPU resources?

**URL:** <https://discourse.julialang.org/t/free-gpu-resources/40653>\
**Category:** GPU\
**Created:** [June 3, 2020, 8:52am UTC](https://discourse.julialang.org/t/free-gpu-resources/40653 "2020-06-03T08:52:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ferran\_Mazzanti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ferran_mazzanti/32/7458_2.png) [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Post date:** [June 3, 2020, 8:52am UTC](https://discourse.julialang.org/t/free-gpu-resources/40653/1 "2020-06-03T08:52:07Z")

</div>

Hi,  
I’m running the same Julia code using CuArrays etc in two machines, one at home and one at work. At home my code works well, this is a 16Gb RAM, Ubuntu 18.04 linux box with a Geoforce 1050Ti, 4Gb RAM. On the computer at wok I have a Xeon with 32Gb RAM, same ubuntu, and a GPU (don’t remember the model) that has 6Gb. But in this case running the exact same code says

CUDA error: too many resources requested for launch (code 701, ERROR\_LAUNCH\_OUT\_OF\_RESOURCES)

Stacktrace:  
[1] throw\_api\_error(::CUDAdrv.cudaError\_enum) at /home/mazzanti/.julia/packages/CUDAdrv/Uc14X/src/error.jl:105  
[2] macro expansion at /home/mazzanti/.julia/packages/CUDAdrv/Uc14X/src/error.jl:112 [inlined]  
[3] cuLaunchKernel(::CuFunction, ::UInt32, ::UInt32, ::UInt32, ::UInt32, ::UInt32, ::UInt32, ::Int64, ::CuStream, ::Array{Ptr{Nothing},1}, ::Ptr{Nothing}) at /home/mazzanti/.julia/packages/CUDAapi/XuSHC/src/call.jl:93  
[4] (::CUDAdrv.var"#566#567"{Bool,Int64,CuStream,CuFunction})(::Array{Ptr{Nothing},1}) at /home/mazzanti/.julia/packages/CUDAdrv/Uc14X/src/execution.jl:67  
[5] macro expansion at /home/mazzanti/.julia/packages/CUDAdrv/Uc14X/src/execution.jl:33 [inlined]  
[6] pack\_arguments(::CUDAdrv.var"#566#567"{Bool,Int64,CuStream,CuFunction}, ::CuDeviceArray{Float64,2,CUDAnative.AS.Global}, ::CuDeviceArray{Float64,2,CUDAnative.AS.Global}) at /home/mazzanti/.julia/packages/CUDAdrv/Uc14X/src/execution.jl:10  
[7] launch(::CuFunction, ::CuDeviceArray{Float64,2,CUDAnative.AS.Global}, ::Vararg{CuDeviceArray{Float64,2,CUDAnative.AS.Global},N} where N; blocks::Int64, threads::Int64, cooperative::Bool, shmem::Int64, stream::CuStream) at /home/mazzanti/.julia/packages/CUDAdrv/Uc14X/src/execution.jl:60  
[8] #571 at /home/mazzanti/.julia/packages/CUDAdrv/Uc14X/src/execution.jl:136 [inlined]  
[9] macro expansion at /home/mazzanti/.julia/packages/CUDAdrv/Uc14X/src/execution.jl:95 [inlined]  
[10] convert\_arguments at /home/mazzanti/.julia/packages/CUDAdrv/Uc14X/src/execution.jl:78 [inlined]  
[11] #cudacall#570 at /home/mazzanti/.julia/packages/CUDAdrv/Uc14X/src/execution.jl:135 [inlined]  
[12] #cudacall#120 at /home/mazzanti/.julia/packages/CUDAnative/e0IdN/src/execution.jl:217 [inlined]  
[13] macro expansion at /home/mazzanti/.julia/packages/CUDAnative/e0IdN/src/execution.jl:198 [inlined]  
[14] #call#104 at /home/mazzanti/.julia/packages/CUDAnative/e0IdN/src/execution.jl:170 [inlined]  
[15] #\_#123 at /home/mazzanti/.julia/packages/CUDAnative/e0IdN/src/execution.jl:345 [inlined]  
[16] macro expansion at /home/mazzanti/.julia/packages/CUDAnative/e0IdN/src/execution.jl:109 [inlined]  
[17] Log\_Unnorm\_Probs\_CUDA(::CuArray{Float64,2,Nothing}, ::CuArray{Float64,2,Nothing}, ::RBM\_net{Float64}, ::Binary\_01) at /home/mazzanti/Julia\_1/Modules/CUDA/RBM\_module\_CUDA\_J1.jl:152  
[18] Log\_Z\_CUDA(::CuArray{Float64,2,Nothing}, ::RBM\_net{Float64}) at /home/mazzanti/Julia\_1/Modules/CUDA/RBM\_module\_CUDA\_J1.jl:185  
[19] Log\_Z\_CUDA(::RBM\_net{Float64}, ::Int64) at /home/mazzanti/Julia\_1/Modules/CUDA/RBM\_module\_CUDA\_J1.jl:300  
[20] Log\_Z\_CUDA(::RBM\_net{Float64}; Mblock::Int64) at /home/mazzanti/Julia\_1/Modules/CUDA/RBM\_module\_CUDA\_J1.jl:219  
[21] Log\_Z\_CUDA(::RBM\_net{Float64}) at /home/mazzanti/Julia\_1/Modules/CUDA/RBM\_module\_CUDA\_J1.jl:210  
[22] top-level scope at ./In[18]:33

is there a way to fix that? to free resources from within the code?

Best regards and thanks,

Ferran.

---

<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:** [June 3, 2020, 8:54am UTC](https://discourse.julialang.org/t/free-gpu-resources/40653/2 "2020-06-03T08:54:07Z")

</div>

> [@Ferran\_Mazzanti](#):
>
> is there a way to fix that?

Use the occupancy API to determine a legal launch configuration. Not all GPUs allow equal amount of threads. There aren’t resources to be freed, these are device limits.
