Skip to content

Instantly share code, notes, and snippets.

@amitjamadagni
Created October 19, 2022 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitjamadagni/17748ef758550c7f8c686e9701e4e817 to your computer and use it in GitHub Desktop.
Save amitjamadagni/17748ef758550c7f8c686e9701e4e817 to your computer and use it in GitHub Desktop.
[ Info: CUDA is on
[ Info: Epoch 1
ERROR: LoadError: 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.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] assertscalar(op::String)
@ GPUArraysCore /user/jlib/packages/GPUArraysCore/rSIl2/src/GPUArraysCore.jl:78
[3] getindex(::CuArray{Int64, 5, CUDA.Mem.DeviceBuffer}, ::Int64, ::Int64, ::Int64, ::Int64, ::Vararg{Int64, N} where N)
@ GPUArrays /user/jlib/packages/GPUArrays/gok9K/src/host/indexing.jl:9
[4] conv_direct!(y::CuArray{Float32, 5, CUDA.Mem.DeviceBuffer}, x::CuArray{Int64, 5, CUDA.Mem.DeviceBuffer}, w::CuArray{Float32, 5, CUDA.Mem.DeviceBuffer}, cdims::DenseConvDims{3, 3, 3, 6, 3}, ::Val{(3, 3, 1)}, ::Val{1}, ::Val{(1, 1, 1, 1, 0, 0)}, ::Val{(1, 1, 1)}, ::Val{(1, 1, 1)}, fk::Val{false}; alpha::Float32, beta::Bool)
@ NNlib /user/jlib/packages/NNlib/0QnJJ/src/impl/conv_direct.jl:104
[5] conv_direct!(y::CuArray{Float32, 5, CUDA.Mem.DeviceBuffer}, x::CuArray{Int64, 5, CUDA.Mem.DeviceBuffer}, w::CuArray{Float32, 5, CUDA.Mem.DeviceBuffer}, cdims::DenseConvDims{3, 3, 3, 6, 3}; alpha::Float32, beta::Bool)
@ NNlib /user/jlib/packages/NNlib/0QnJJ/src/impl/conv_direct.jl:50
[6] conv_direct!
@ /user/jlib/packages/NNlib/0QnJJ/src/impl/conv_direct.jl:50 [inlined]
[7] #conv!#288
@ /user/jlib/packages/NNlib/0QnJJ/src/conv.jl:288 [inlined]
[8] conv!
@ /user/jlib/packages/NNlib/0QnJJ/src/conv.jl:284 [inlined]
[9] #conv!#221
@ /user/jlib/packages/NNlib/0QnJJ/src/conv.jl:145 [inlined]
[10] conv!
@ /user/jlib/packages/NNlib/0QnJJ/src/conv.jl:145 [inlined]
[11] conv(x::CuArray{Int64, 4, CUDA.Mem.DeviceBuffer}, w::CuArray{Float32, 4, CUDA.Mem.DeviceBuffer}, cdims::DenseConvDims{2, 2, 2, 4, 2}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ NNlib /user/jlib/packages/NNlib/0QnJJ/src/conv.jl:88
[12] conv
@ /user/jlib/packages/NNlib/0QnJJ/src/conv.jl:86 [inlined]
[13] #rrule#312
@ /user/jlib/packages/NNlib/0QnJJ/src/conv.jl:313 [inlined]
[14] rrule
@ /user/jlib/packages/NNlib/0QnJJ/src/conv.jl:304 [inlined]
[15] rrule
@ /user/jlib/packages/ChainRulesCore/GUvJT/src/rules.jl:134 [inlined]
[16] chain_rrule
@ /user/jlib/packages/Zygote/IoW2g/src/compiler/chainrules.jl:217 [inlined]
[17] macro expansion
@ /user/jlib/packages/Zygote/IoW2g/src/compiler/interface2.jl:0 [inlined]
[18] _pullback
@ /user/jlib/packages/Zygote/IoW2g/src/compiler/interface2.jl:9 [inlined]
[19] _pullback
@ /user/jlib/packages/Flux/EXOFx/src/layers/conv.jl:200 [inlined]
[20] _pullback(ctx::Zygote.Context, f::Conv{2, 2, typeof(relu), CuArray{Float32, 4, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}, args::CuArray{Int64, 4, CUDA.Mem.DeviceBuffer})
@ Zygote /user/jlib/packages/Zygote/IoW2g/src/compiler/interface2.jl:0
[21] macro expansion
@ /user/jlib/packages/Flux/EXOFx/src/layers/basic.jl:53 [inlined]
[22] _pullback
@ /user/jlib/packages/Flux/EXOFx/src/layers/basic.jl:53 [inlined]
[23] _pullback(::Zygote.Context, ::typeof(Flux._applychain), ::Tuple{Conv{2, 2, typeof(relu), CuArray{Float32, 4, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}, MaxPool{2, 4}, typeof(flatten), Dense{typeof(relu), CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}, Dense{typeof(identity), CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}}, ::CuArray{Int64, 4, CUDA.Mem.DeviceBuffer})
@ Zygote /user/jlib/packages/Zygote/IoW2g/src/compiler/interface2.jl:0
[24] _pullback
@ /user/jlib/packages/Flux/EXOFx/src/layers/basic.jl:51 [inlined]
[25] _pullback(ctx::Zygote.Context, f::Chain{Tuple{Conv{2, 2, typeof(relu), CuArray{Float32, 4, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}, MaxPool{2, 4}, typeof(flatten), Dense{typeof(relu), CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}, Dense{typeof(identity), CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}}}, args::CuArray{Int64, 4, CUDA.Mem.DeviceBuffer})
@ Zygote /user/jlib/packages/Zygote/IoW2g/src/compiler/interface2.jl:0
[26] _pullback
@ /user/ml_pt/N_100/ml_algo/nn_train_test_2.jl:125 [inlined]
[27] _pullback(::Zygote.Context, ::var"#loss#8", ::CuArray{Int64, 4, CUDA.Mem.DeviceBuffer}, ::Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1, CUDA.Mem.DeviceBuffer}})
@ Zygote /user/jlib/packages/Zygote/IoW2g/src/compiler/interface2.jl:0
[28] _apply
@ ./boot.jl:804 [inlined]
[29] adjoint
@ /user/jlib/packages/Zygote/IoW2g/src/lib/lib.jl:204 [inlined]
[30] _pullback
@ /user/jlib/packages/ZygoteRules/AIbCs/src/adjoint.jl:65 [inlined]
[31] _pullback
@ /user/jlib/packages/Flux/EXOFx/src/optimise/train.jl:120 [inlined]
[32] _pullback(::Zygote.Context, ::Flux.Optimise.var"#37#40"{var"#loss#8", Tuple{CuArray{Int64, 4, CUDA.Mem.DeviceBuffer}, Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1, CUDA.Mem.DeviceBuffer}}}})
@ Zygote /user/jlib/packages/Zygote/IoW2g/src/compiler/interface2.jl:0
[33] pullback(f::Function, ps::Zygote.Params{Zygote.Buffer{Any, Vector{Any}}})
@ Zygote /user/jlib/packages/Zygote/IoW2g/src/compiler/interface.jl:352
[34] gradient(f::Function, args::Zygote.Params{Zygote.Buffer{Any, Vector{Any}}})
@ Zygote /user/jlib/packages/Zygote/IoW2g/src/compiler/interface.jl:75
[35] macro expansion
@ /user/jlib/packages/Flux/EXOFx/src/optimise/train.jl:119 [inlined]
[36] macro expansion
@ /user/jlib/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl:328 [inlined]
[37] train!(loss::Function, ps::Zygote.Params{Zygote.Buffer{Any, Vector{Any}}}, data::Vector{Tuple{CuArray{Int64, 4, CUDA.Mem.DeviceBuffer}, Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1, CUDA.Mem.DeviceBuffer}}}}, opt::Adam; cb::var"#7#9")
@ Flux.Optimise /user/jlib/packages/Flux/EXOFx/src/optimise/train.jl:117
[38] macro expansion
@ /user/jlib/packages/Flux/EXOFx/src/optimise/train.jl:155 [inlined]
[39] macro expansion
@ /user/jlib/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl:470 [inlined]
[40] train(; kws::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Main /user/ml_pt/N_100/ml_algo/nn_train_test_2.jl:131
[41] train()
@ Main /user/ml_pt/N_100/ml_algo/nn_train_test_2.jl:115
[42] top-level scope
@ /user/ml_pt/N_100/ml_algo/nn_train_test_2.jl:150
in expression starting at /user/ml_pt/N_100/ml_algo/nn_train_test_2.jl:150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment