I originally wrote the program without passing to GPU inside loss
but already had the same error, this is simply one of the things I tried during debugging, I should’ve been more clear. Here is the new stacktrace (after upgrading to the master branch of Flux), which is identical (checked) both with & without passing to gpu in loss
:
ERROR: LoadError: TaskFailedException:
scalar getindex is disallowed
Stacktrace:
[1] error(::String) at .\error.jl:33
[2] assertscalar(::String) at C:\Users\CCL\.julia\packages\GPUArrays\OXvxB\src\host\indexing.jl:41
[3] _getindex at C:\Users\CCL\.julia\packages\GPUArrays\OXvxB\src\host\indexing.jl:96 [inlined]
[4] getindex at .\abstractarray.jl:981 [inlined]
[5] im2col!(::CuArray{Float32,2,CuArray{Float32,3,Nothing}}, ::CuArray{Float32,4,CuArray{Float32,5,CuArray{Float32,4,Nothing}}}, ::DenseConvDims{3,(3, 3, 1),3,32,(1, 1, 1),(1, 1, 1, 1, 0, 0),(1, 1, 1),false}) at C:\Users\CCL\.julia\packages\NNlib\FAI3o\src\impl\conv_im2col.jl:231
[6] macro expansion at C:\Users\CCL\.julia\packages\NNlib\FAI3o\src\impl\conv_im2col.jl:53 [inlined]
[7] (::NNlib.var"#343#threadsfor_fun#160"{CuArray{Float32,3,Nothing},Float32,Float32,CuArray{Float32,5,CuArray{Float32,4,Nothing}},CuArray{Float32,5,CuArray{Float32,4,Nothing}},Array{Float32,5},DenseConvDims{3,(3, 3, 1),3,32,(1, 1, 1),(1, 1, 1, 1, 0, 0),(1, 1, 1),false},Int64,Int64,Int64,UnitRange{Int64}})(::Bool) at .\threadingconstructs.jl:61
[8] (::NNlib.var"#343#threadsfor_fun#160"{CuArray{Float32,3,Nothing},Float32,Float32,CuArray{Float32,5,CuArray{Float32,4,Nothing}},CuArray{Float32,5,CuArray{Float32,4,Nothing}},Array{Float32,5},DenseConvDims{3,(3, 3, 1),3,32,(1, 1, 1),(1, 1, 1, 1, 0, 0),(1, 1, 1),false},Int64,Int64,Int64,UnitRange{Int64}})() at .\threadingconstructs.jl:28
Stacktrace:
[1] wait(::Task) at .\task.jl:251
[2] macro expansion at .\threadingconstructs.jl:69 [inlined]
[3] #conv_im2col!#159(::CuArray{Float32,3,Nothing}, ::Float32, ::Float32, ::typeof(NNlib.conv_im2col!), ::CuArray{Float32,5,CuArray{Float32,4,Nothing}}, ::CuArray{Float32,5,CuArray{Float32,4,Nothing}}, ::Array{Float32,5}, ::DenseConvDims{3,(3, 3, 1),3,32,(1, 1, 1),(1, 1, 1, 1, 0, 0),(1, 1, 1),false}) at C:\Users\CCL\.julia\packages\NNlib\FAI3o\src\impl\conv_im2col.jl:49
[4] conv_im2col! at C:\Users\CCL\.julia\packages\NNlib\FAI3o\src\impl\conv_im2col.jl:30 [inlined]
[5] #conv!#41 at C:\Users\CCL\.julia\packages\NNlib\FAI3o\src\conv.jl:53 [inlined]
[6] conv!(::CuArray{Float32,5,CuArray{Float32,4,Nothing}}, ::CuArray{Float32,5,CuArray{Float32,4,Nothing}}, ::Array{Float32,5}, ::DenseConvDims{3,(3, 3, 1),3,32,(1, 1, 1),(1, 1, 1, 1, 0, 0),(1, 1, 1),false}) at C:\Users\CCL\.julia\packages\NNlib\FAI3o\src\conv.jl:53
[7] #conv!#48(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(conv!), ::CuArray{Float32,4,Nothing}, ::CuArray{Float32,4,Nothing}, ::Array{Float32,4}, ::DenseConvDims{2,(3, 3),3,32,(1, 1),(1, 1, 1, 1),(1, 1),false}) at C:\Users\CCL\.julia\packages\NNlib\FAI3o\src\conv.jl:70
[8] conv! at C:\Users\CCL\.julia\packages\NNlib\FAI3o\src\conv.jl:70 [inlined]
[9] #conv#89(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(NNlib.conv), ::CuArray{Float32,4,Nothing}, ::Array{Float32,4}, ::DenseConvDims{2,(3, 3),3,32,(1, 1),(1, 1, 1, 1),(1, 1),false}) at C:\Users\CCL\.julia\packages\NNlib\FAI3o\src\conv.jl:116
[10] conv(::CuArray{Float32,4,Nothing}, ::Array{Float32,4}, ::DenseConvDims{2,(3, 3),3,32,(1, 1),(1, 1, 1, 1),(1, 1),false}) at C:\Users\CCL\.julia\packages\NNlib\FAI3o\src\conv.jl:114
[11] #adjoint#1833 at C:\Users\CCL\.julia\packages\Zygote\YeCEW\src\lib\nnlib.jl:26 [inlined]
[12] adjoint at .\none:0 [inlined]
[13] _pullback at C:\Users\CCL\.julia\packages\ZygoteRules\6nssF\src\adjoint.jl:47 [inlined]
[14] Conv at C:\Users\CCL\.julia\packages\Flux\8xjH2\src\layers\conv.jl:137 [inlined]
[15] _pullback(::Zygote.Context, ::Conv{2,4,typeof(identity),Array{Float32,4},Array{Float32,1}}, ::CuArray{Float32,4,Nothing}) at C:\Users\CCL\.julia\packages\Zygote\YeCEW\src\compiler\interface2.jl:0
[16] applychain at C:\Users\CCL\.julia\packages\Flux\8xjH2\src\layers\basic.jl:36 [inlined]
[17] _pullback(::Zygote.Context, ::typeof(Flux.applychain), ::Tuple{Conv{2,4,typeof(identity),Array{Float32,4},Array{Float32,1}},BatchNorm{typeof(relu),Array{Float32,1},Array{Float32,1},Float32},Conv{2,4,typeof(identity),Array{Float32,4},Array{Float32,1}},BatchNorm{typeof(relu),Array{Float32,1},Array{Float32,1},Float32}}, ::CuArray{Float32,4,Nothing}) at C:\Users\CCL\.julia\packages\Zygote\YeCEW\src\compiler\interface2.jl:0
[18] Chain at C:\Users\CCL\.julia\packages\Flux\8xjH2\src\layers\basic.jl:38 [inlined]
[19] _pullback(::Zygote.Context, ::Chain{Tuple{Conv{2,4,typeof(identity),Array{Float32,4},Array{Float32,1}},BatchNorm{typeof(relu),Array{Float32,1},Array{Float32,1},Float32},Conv{2,4,typeof(identity),Array{Float32,4},Array{Float32,1}},BatchNorm{typeof(relu),Array{Float32,1},Array{Float32,1},Float32}}}, ::CuArray{Float32,4,Nothing}) at C:\Users\CCL\.julia\packages\Zygote\YeCEW\src\compiler\interface2.jl:0
[20] fcn at C:\Users\CCL\fcn\fcn_flux2.jl:41 [inlined]
[21] _pullback(::Zygote.Context, ::fcn, ::CuArray{Float32,4,Nothing}) at C:\Users\CCL\.julia\packages\Zygote\YeCEW\src\compiler\interface2.jl:0
[22] loss at C:\Users\CCL\fcn\main_flux2.jl:47 [inlined]
[23] _pullback(::Zygote.Context, ::typeof(loss), ::CuArray{Float32,4,Nothing}, ::CuArray{Float32,4,Nothing}) at C:\Users\CCL\.julia\packages\Zygote\YeCEW\src\compiler\interface2.jl:0
[24] adjoint at C:\Users\CCL\.julia\packages\Zygote\YeCEW\src\lib\lib.jl:168 [inlined]
[25] _pullback at C:\Users\CCL\.julia\packages\ZygoteRules\6nssF\src\adjoint.jl:47 [inlined]
[26] #17 at C:\Users\CCL\.julia\packages\Flux\8xjH2\src\optimise\train.jl:89 [inlined]
[27] _pullback(::Zygote.Context, ::Flux.Optimise.var"#17#25"{typeof(loss),Tuple{CuArray{Float32,4,Nothing},CuArray{Float32,4,Nothing}}}) at C:\Users\CCL\.julia\packages\Zygote\YeCEW\src\compiler\interface2.jl:0
[28] pullback(::Function, ::Zygote.Params) at C:\Users\CCL\.julia\packages\Zygote\YeCEW\src\compiler\interface.jl:174
[29] gradient(::Function, ::Zygote.Params) at C:\Users\CCL\.julia\packages\Zygote\YeCEW\src\compiler\interface.jl:54
[30] macro expansion at C:\Users\CCL\.julia\packages\Flux\8xjH2\src\optimise\train.jl:88 [inlined]
[31] macro expansion at C:\Users\CCL\.julia\packages\Juno\f8hj2\src\progress.jl:134 [inlined]
[32] #train!#12(::Flux.Optimise.var"#18#26", ::typeof(Flux.Optimise.train!), ::typeof(loss), ::Zygote.Params, ::Array{Tuple{CuArray{Float32,4,Nothing},CuArray{Float32,4,Nothing}},1}, ::ADAM) at C:\Users\CCL\.julia\packages\Flux\8xjH2\src\optimise\train.jl:81
[33] train!(::Function, ::Zygote.Params, ::Array{Tuple{CuArray{Float32,4,Nothing},CuArray{Float32,4,Nothing}},1}, ::ADAM) at C:\Users\CCL\.julia\packages\Flux\8xjH2\src\optimise\train.jl:79
[34] top-level scope at C:\Users\CCL\fcn\main_flux2.jl:84
[35] include at .\boot.jl:328 [inlined]
[36] include_relative(::Module, ::String) at .\loading.jl:1105
[37] include(::Module, ::String) at .\Base.jl:31
[38] exec_options(::Base.JLOptions) at .\client.jl:287
[39] _start() at .\client.jl:460
in expression starting at C:\Users\CCL\fcn\main_flux2.jl:74