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

CUDA and Adam errors #1074

Closed
roflmaostc opened this issue Jan 29, 2024 · 3 comments
Closed

CUDA and Adam errors #1074

roflmaostc opened this issue Jan 29, 2024 · 3 comments
Milestone

Comments

@roflmaostc
Copy link

roflmaostc commented Jan 29, 2024

Did you test on CUDA devices too?
My quick tests resulted in errors

Scalar indexing is disallowed.

Invocation of getindex resulted in scalar indexing of a GPU array.

This is typically caused by calling an iterating implementation of a method.

Such implementations *do not* execute on the GPU, but very slowly on the CPU,

and therefore are only permitted from the REPL for prototyping purposes.

If you did intend to index this array, annotate the caller with @allowscalar.

    error(::String)@error.jl:35
    assertscalar(::String)@GPUArraysCore.jl:103
    getindex(::CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}, ::Int64)@indexing.jl:48
    initial_state(::Optim.Adam{Float64, Optim.Flat}, ::Optim.Options{Float64, Nothing}, ::NLSolversBase.OnceDifferentiable{Float32, CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}, CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}}, ::CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer})@adam.jl:48
    optimize(::NLSolversBase.OnceDifferentiable{Float32, CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}, CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}}, ::CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}, ::Optim.Adam{Float64, Optim.Flat}, ::Optim.Options{Float64, Nothing}, ::Optim.AdamState{CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}, Float32, CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}, CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}, Vector{Float32}, Int64})@optimize.jl:36[inlined]
    var"#optimize#91"(::Bool, ::Symbol, ::typeof(Optim.optimize), ::NLSolversBase.InplaceObjective{Nothing, SwissVAMyKnife.var"#fg!#19"{SwissVAMyKnife.var"#L_VAM#18"{SwissVAMyKnife.var"#fwd2#12"{SwissVAMyKnife.var"#AS_abs2#11"{WaveOpticsPropagation.AngularSpectrum3{CUDA.CuArray{ComplexF32, 3, CUDA.Mem.DeviceBuffer}, Float32, CUDA.CUFFT.cCuFFTPlan{ComplexF32, -1, true, 3}}, Int64}, StepRangeLen{Float32, Float64, Float64, Int64}}, CUDA.CuArray{Bool, 3, CUDA.Mem.DeviceBuffer}, CUDA.CuArray{Bool, 3, CUDA.Mem.DeviceBuffer}, Tuple{Float32, Float32}, SwissVAMyKnife.var"#loss_f3#16"{typeof(abs2), CUDA.CuArray{Bool, 2, CUDA.Mem.DeviceBuffer}}}}, Nothing, Nothing, Nothing}, ::CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}, ::Optim.Adam{Float64, Optim.Flat}, ::Optim.Options{Float64, Nothing})@interface.jl:143
    optimize(::NLSolversBase.InplaceObjective{Nothing, SwissVAMyKnife.var"#fg!#19"{SwissVAMyKnife.var"#L_VAM#18"{SwissVAMyKnife.var"#fwd2#12"{SwissVAMyKnife.var"#AS_abs2#11"{WaveOpticsPropagation.AngularSpectrum3{CUDA.CuArray{ComplexF32, 3, CUDA.Mem.DeviceBuffer}, Float32, CUDA.CUFFT.cCuFFTPlan{ComplexF32, -1, true, 3}}, Int64}, StepRangeLen{Float32, Float64, Float64, Int64}}, CUDA.CuArray{Bool, 3, CUDA.Mem.DeviceBuffer}, CUDA.CuArray{Bool, 3, CUDA.Mem.DeviceBuffer}, Tuple{Float32, Float32}, SwissVAMyKnife.var"#loss_f3#16"{typeof(abs2), CUDA.CuArray{Bool, 2, CUDA.Mem.DeviceBuffer}}}}, Nothing, Nothing, Nothing}, ::CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}, ::Optim.Adam{Float64, Optim.Flat}, ::Optim.Options{Float64, Nothing})@interface.jl:139
    optimize_patterns(::CUDA.CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}, ::SwissVAMyKnife.WaveOptics{CUDA.CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, Float32, StepRangeLen{Float32, Float64, Float64, Int64}, Nothing}, ::SwissVAMyKnife.GradientBased{Optim.Adam{Float64, Optim.Flat}, Int64, typeof(abs2), Symbol, Float32})@optimization.jl:110
    macro expansion@[Local: 35](http://localhost:1234/edit?id=6ff68db6-be92-11ee-0059-63ce1cf34809#)[inlined]
    macro expansion@[Local: 621](http://localhost:1234/edit?id=6ff68db6-be92-11ee-0059-63ce1cf34809#)[inlined]
    top-level scope@[Local: 1](http://localhost:1234/edit?id=6ff68db6-be92-11ee-0059-63ce1cf34809#)[inlined]
@pkofod
Copy link
Member

pkofod commented Jan 29, 2024

No I did not. I suppose it's this

u = fill(zero(m[1]^2), length(m))

and I suppose maybe zeros(m) should suffice?

@pkofod
Copy link
Member

pkofod commented Jan 29, 2024

Maybe try this? #1075

@pkofod pkofod modified the milestones: 1.8.x, 1.9.x Jan 29, 2024
@pkofod
Copy link
Member

pkofod commented Jan 30, 2024

Fixed in #1075

@pkofod pkofod closed this as completed Jan 30, 2024
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