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

Flux.stack causes StackOverflowError on macOS ARM #2060

Closed
gabrevaya opened this issue Sep 7, 2022 · 1 comment
Closed

Flux.stack causes StackOverflowError on macOS ARM #2060

gabrevaya opened this issue Sep 7, 2022 · 1 comment

Comments

@gabrevaya
Copy link

Stacking vectors of length > 1352 causes a StackOverflowError:

julia> a = [[1] for i in 1:1352];
julia> Flux.stack(a, 2); # works
julia> a = [[1] for i in 1:1353];
julia> Flux.stack(a, 2);
ERROR: StackOverflowError:
Stacktrace:
 [1] __cat_offset!(::Matrix{Int64}, ::Tuple{Int64, Int64}, ::Tuple{Bool, Bool}, ::Tuple{Int64, Int64}, ::Matrix{Int64}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ Base ./abstractarray.jl:1746
 [2] __cat_offset!(::Matrix{Int64}, ::Tuple{Int64, Int64}, ::Tuple{Bool, Bool}, ::Tuple{Int64, Int64}, ::Matrix{Int64}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}}) (repeats 1351 times)
   @ Base ./abstractarray.jl:1749
 [3] __cat(::Matrix{Int64}, ::Tuple{Int64, Int64}, ::Tuple{Bool, Bool}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ Base ./abstractarray.jl:1744
 [4] _cat_t(::Int64, ::Type{Int64}, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ Base ./abstractarray.jl:1737
 [5] _cat(::Int64, ::Matrix{Int64}, ::Vararg{Matrix{Int64}})
   @ LinearAlgebra /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/LinearAlgebra/src/special.jl:424
 [6] cat(::Matrix{Int64}, ::Vararg{Matrix{Int64}}; dims::Int64)
   @ Base ./abstractarray.jl:1916
 [7] stack(xs::Vector{Vector{Int64}}; dims::Int64)
   @ MLUtils ~/.julia/packages/MLUtils/OojOS/src/utils.jl:101
 [8] stack(x::Vector{Vector{Int64}}, dims::Int64)
   @ MLUtils ./deprecated.jl:72

Moreover, if the length is sufficiently large, there is no Stacktrace included:

julia> a = [[1] for i in 1:2000];
julia> Flux.stack(a, 2);
ERROR: StackOverflowError:
(Flux_stack) pkg> st
Status `~/Documents/issues/Flux_stack/Project.toml`
  [587475ba] Flux v0.13.5
julia> versioninfo()
Julia Version 1.8.0
Commit 5544a0fab76 (2022-08-17 13:38 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: 8 × Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 1 on 6 virtual cores
@ToucheSir
Copy link
Member

ToucheSir commented Sep 7, 2022

stack lives in https://github.com/JuliaML/MLUtils.jl/, but unfortunately I can't transfer the issue cross-org so you'll have to re-open it there (or comment on JuliaML/MLUtils.jl#119). As for a solution that works now, you could try using Base.stack (which shouldn't cause stack overflows) through Compat.jl >= 4.2.

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

No branches or pull requests

2 participants