Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Disable the GC after taking pool-related spinlocks. #693

Merged
merged 4 commits into from
Apr 28, 2020
Merged

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Apr 24, 2020

Potential fix for #685.

@denizyuret @colinxs @lpjiang97 could you try out this PR?

@maleadt maleadt added the bugfix label Apr 24, 2020
src/memory.jl Outdated Show resolved Hide resolved
@denizyuret
Copy link

This solves my test case (it doesn't lock up any more).

src/memory.jl Outdated Show resolved Hide resolved
@lpjiang97
Copy link

lpjiang97 commented Apr 26, 2020

@maleadt Commit df0dc90 also solves the issue for me! But not the latest Commit 2d99e03. The deadlock still seems to happen. Here's the full stacktrace:

Stacktrace:
 [1] lock(::Base.Threads.SpinLock) at ./locks-mt.jl:71
 [2] macro expansion at ./lock.jl:181 [inlined]
 [3] free(::CUDAdrv.CuPtr{Nothing}) at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/memory/binned.jl:393
 [4] macro expansion at /home/lpjiang97/.julia/packages/TimerOutputs/NvIUx/src/TimerOutput.jl:245 [inlined]
 [5] macro expansion at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/memory.jl:245 [inlined]
 [6] macro expansion at ./util.jl:234 [inlined]
 [7] free at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/memory.jl:244 [inlined]
 [8] _unsafe_free!(::CuArray{Float32,3,Nothing}) at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/array.jl:51
 [9] unsafe_free!(::CuArray{Float32,3,Nothing}) at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/array.jl:40
 [10] enable_finalizers at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/memory.jl:16 [inlined]
 [11] macro expansion at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/memory.jl:23 [inlined]
 [12] macro expansion at ./lock.jl:183 [inlined]
 [13] alloc(::Int64) at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/memory/binned.jl:383
 [14] macro expansion at /home/lpjiang97/.julia/packages/TimerOutputs/NvIUx/src/TimerOutput.jl:245 [inlined]
 [15] macro expansion at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/memory.jl:196 [inlined]
 [16] macro expansion at ./util.jl:234 [inlined]
 [17] alloc at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/memory.jl:195 [inlined]
 [18] CuArray{Float32,2,P} where P(::UndefInitializer, ::Tuple{Int64,Int64}) at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/array.jl:107
 [19] similar at /home/lpjiang97/.julia/packages/CuArrays/DO2vR/src/array.jl:139 [inlined]
 [20] similar at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/adjtrans.jl:197 [inlined]
 [21] * at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/matmul.jl:153 [inlined]
 [22] #1285 at /home/lpjiang97/.julia/packages/Zygote/4tJp5/src/lib/array.jl:292 [inlined]
 [23] (::Zygote.var"#3260#back#1287"{Zygote.var"#1285#1286"{CuArray{Float32,2,Nothing},CuArray{Float32,2,Nothing}}})(::CuArray{Float32,2,Nothing}) at /home/lpjiang97/.julia/packages/ZygoteRules/6nssF/src/adjoint.jl:49
 [24] Dense at /home/lpjiang97/.julia/packages/Flux/Fj3bt/src/layers/basic.jl:122 [inlined]
 [25] (::typeof((invoke)))(::CuArray{Float32,2,Nothing}) at /home/lpjiang97/.julia/packages/Zygote/4tJp5/src/compiler/interface2.jl:0
 [26] Dense at /home/lpjiang97/.julia/packages/Flux/Fj3bt/src/layers/basic.jl:133 [inlined]
 [27] (::typeof((λ)))(::CuArray{Float32,2,Nothing}) at /home/lpjiang97/.julia/packages/Zygote/4tJp5/src/compiler/interface2.jl:0
 [28] #3 at /home/lpjiang97/Research/probabilistic-pc/foo/debug.jl:21 [inlined]
 [29] (::typeof((λ)))(::Float32) at /home/lpjiang97/.julia/packages/Zygote/4tJp5/src/compiler/interface2.jl:0
 [30] (::Zygote.var"#48#49"{Zygote.Params,Zygote.Context,typeof((λ))})(::Float32) at /home/lpjiang97/.julia/packages/Zygote/4tJp5/src/compiler/interface.jl:108
 [31] gradient(::Function, ::Zygote.Params) at /home/lpjiang97/.julia/packages/Zygote/4tJp5/src/compiler/interface.jl:45
 [32] ISTA(::CuArray{Float32,2,Nothing}, ::Dense{typeof(identity),CuArray{Float32,2,Nothing},CuArray{Float32,1,Nothing}}, ::Float64, ::Int64, ::Float64, ::Float64) at /home/lpjiang97/Research/probabilistic-pc/foo/debug.jl:20
 [33] top-level scope at /home/lpjiang97/Research/probabilistic-pc/foo/debug.jl:48
 [34] include(::String) at ./client.jl:439
 [35] top-level scope at none:1
 [36] eval(::Module, ::Any) at ./boot.jl:331
 [37] exec_options(::Base.JLOptions) at ./client.jl:264
 [38] _start() at ./client.jl:484

@maleadt
Copy link
Member Author

maleadt commented Apr 26, 2020

Alright, another attempt. Could you test again?

@lpjiang97
Copy link

This seems to have fixed it! Thanks @maleadt !

@denizyuret
Copy link

Still passes my tests.

@maleadt maleadt merged commit 2258a24 into master Apr 28, 2020
@bors bors bot deleted the tb/disable_gc branch April 28, 2020 06:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants