Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of memory error caused by calling @btime on on a medium sized model #29085

Closed
DoktorMike opened this issue Sep 7, 2018 · 2 comments
Closed
Labels
GC Garbage collector

Comments

@DoktorMike
Copy link

I define the following function which requires some memory and call it twice with btime which results in an out of memory error. Code given below:

using Flux
using Flux.Tracker
using BenchmarkTools

function fluxderivtest(nhidden=100_000, ninput=1_000)
    W = param(rand(nhidden, ninput) .- 0.5)
    b = param(rand(nhidden) .- 0.5)
    x = rand(ninput)
    f(x) = tanh(sum(W*x .+ b))
    g = Tracker.gradient(() -> f(x), Params([W, b]))
    g[W], g[b]
end

@btime fluxderivtest()
@btime fluxderivtest()

which results in the following error:

ERROR: OutOfMemoryError()
Stacktrace:
 [1] Type at ./boot.jl:396 [inlined]
 [2] similar at ./array.jl:328 [inlined]
 [3] zero at ./abstractarray.jl:827 [inlined]
 [4] Type at /home/michael/.julia/packages/Flux/UHjNa/src/tracker/array.jl:30 [inlined]
 [5] param(::Array{Float64,2}) at /home/michael/.julia/packages/Flux/UHjNa/src/tracker/Tracker.jl:105
 [6] fluxderivtest(::Int64, ::Int64) at ./REPL[4]:2 (repeats 2 times)
 [7] ##core#372() at /home/michael/.julia/packages/BenchmarkTools/dtwnm/src/execution.jl:293
 [8] ##sample#373(::BenchmarkTools.Parameters) at /home/michael/.julia/packages/BenchmarkTools/dtwnm/src/execution.jl:301
 [9] sample at /home/michael/.julia/packages/BenchmarkTools/dtwnm/src/execution.jl:316 [inlined]
 [10] #_lineartrial#20(::Int64, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::BenchmarkTools.Benchmark{Symbol("##benchmark#371")}, ::BenchmarkTools.Parameters) at /home/michael/.julia/packages/BenchmarkTools/dtwnm/src/execution.jl:71
 [11] _lineartrial(::BenchmarkTools.Benchmark{Symbol("##benchmark#371")}, ::BenchmarkTools.Parameters) at /home/michael/.julia/packages/BenchmarkTools/dtwnm/src/execution.jl:63
 [12] #invokelatest#1 at ./essentials.jl:686 [inlined]
 [13] invokelatest at ./essentials.jl:685 [inlined]
 [14] #lineartrial#17 at /home/michael/.julia/packages/BenchmarkTools/dtwnm/src/execution.jl:33 [inlined]
 [15] lineartrial at /home/michael/.julia/packages/BenchmarkTools/dtwnm/src/execution.jl:33 [inlined]
 [16] #tune!#23(::Bool, ::String, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::BenchmarkTools.Benchmark{Symbol("##benchmark#371")}, ::BenchmarkTools.Parameters) at /home/michael/.julia/packages/BenchmarkTools/dtwnm/src/execution.jl:135
 [17] tune! at /home/michael/.julia/packages/BenchmarkTools/dtwnm/src/execution.jl:134 [inlined] (repeats 2 times)
 [18] top-level scope at /home/michael/.julia/packages/BenchmarkTools/dtwnm/src/execution.jl:388

Versioninfo:

Julia Version 1.0.0
Commit 5d4eaca (2018-08-08 20:58 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-6650U CPU @ 2.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

I'm running Ubuntu 18.04 on a Surface pro 4 with 16GB of RAM.

Also asked a question regarding this on discourse: (https://discourse.julialang.org/t/how-do-i-release-flux-tracker-allocated-memory/14663)

As I understand the Garbage collection should take care of this but in my case it doesn't unless I'm doing something I shouldn't be doing of course.

@oscardssmith
Copy link
Member

@chflood should we add this to the GC benchmark repo?

@ViralBShah
Copy link
Member

We no longer have Tracker in Flux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GC Garbage collector
Projects
None yet
Development

No branches or pull requests

3 participants