To test if I could simulate spiking neural networks with GPU I modified the population-test.jl file (now called population-gpu-test.jl)
To make the example a bit less trivial I made the neuron population 100 by creating a square neuron weight matrix as such:
I also tried to make the neuron activity a bit more balanced by distributing the inputs so only 1/3 of inputs are strong.
instead.
See the stack trace below.
include("population-test.jl")
[ Info: Precompiling SpikingNN [a2976702-bddd-11e9-29f3-e11e525b718e]
┌ Warning: Package SpikingNN does not have Distributed in its dependencies:
│ - If you have SpikingNN checked out for development and have
│ added Distributed as a dependency but haven't updated your primary
│ environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with SpikingNN
└ Loading Distributed into SpikingNN from project dependency, future warnings for SpikingNN are suppressed.
hit GPU
┌ Warning: Performing scalar operations on GPU arrays: This is very slow, consider disallowing these operations with `allowscalar(false)`
└ @ GPUArrays ~/.julia/packages/GPUArrays/Z5nPF/src/host/indexing.jl:64
ERROR: LoadError: GPU compilation of kernel broadcast_kernel(CUDA.CuKernelContext, CuDeviceArray{Float32,1,1}, Base.Broadcast.Broadcasted{Nothing,Tuple{Base.OneTo{Int64}},typeof(+),Tuple{Base.Broadcast.Extruded{CuDeviceArray{Float32,1,1},Tuple{Bool},Tuple{Int64}},Base.Broadcast.Extruded{Array{Real,1},Tuple{Bool},Tuple{Int64}}}}, Int64) failed
KernelError: passing and using non-bitstype argument
Argument 4 to your kernel function is of type Base.Broadcast.Broadcasted{Nothing,Tuple{Base.OneTo{Int64}},typeof(+),Tuple{Base.Broadcast.Extruded{CuDeviceArray{Float32,1,1},Tuple{Bool},Tuple{Int64}},Base.Broadcast.Extruded{Array{Real,1},Tuple{Bool},Tuple{Int64}}}}, which is not isbits:
.args is of type Tuple{Base.Broadcast.Extruded{CuDeviceArray{Float32,1,1},Tuple{Bool},Tuple{Int64}},Base.Broadcast.Extruded{Array{Real,1},Tuple{Bool},Tuple{Int64}}} which is not isbits.
.2 is of type Base.Broadcast.Extruded{Array{Real,1},Tuple{Bool},Tuple{Int64}} which is not isbits.
.x is of type Array{Real,1} which is not isbits.
Stacktrace:
[1] check_invocation(::GPUCompiler.CompilerJob, ::LLVM.Function) at /home/rudolph/.julia/packages/GPUCompiler/uTpNx/src/validation.jl:68
[2] macro expansion at /home/rudolph/.julia/packages/GPUCompiler/uTpNx/src/driver.jl:238 [inlined]
[3] macro expansion at /home/rudolph/.julia/packages/TimerOutputs/ZmKD7/src/TimerOutput.jl:206 [inlined]
[4] codegen(::Symbol, ::GPUCompiler.CompilerJob; libraries::Bool, deferred_codegen::Bool, optimize::Bool, strip::Bool, validate::Bool, only_entry::Bool) at /home/rudolph/.julia/packages/GPUCompiler/uTpNx/src/driver.jl:237
[5] compile(::Symbol, ::GPUCompiler.CompilerJob; libraries::Bool, deferred_codegen::Bool, optimize::Bool, strip::Bool, validate::Bool, only_entry::Bool) at /home/rudolph/.julia/packages/GPUCompiler/uTpNx/src/driver.jl:39
[6] compile at /home/rudolph/.julia/packages/GPUCompiler/uTpNx/src/driver.jl:35 [inlined]
[7] cufunction_compile(::GPUCompiler.FunctionSpec; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/rudolph/.julia/packages/CUDA/mbPFj/src/compiler/execution.jl:302
[8] cufunction_compile(::GPUCompiler.FunctionSpec) at /home/rudolph/.julia/packages/CUDA/mbPFj/src/compiler/execution.jl:297
[9] check_cache(::Dict{UInt64,Any}, ::Any, ::Any, ::GPUCompiler.FunctionSpec{GPUArrays.var"#broadcast_kernel#16",Tuple{CUDA.CuKernelContext,CuDeviceArray{Float32,1,1},Base.Broadcast.Broadcasted{Nothing,Tuple{Base.OneTo{Int64}},typeof(+),Tuple{Base.Broadcast.Extruded{CuDeviceArray{Float32,1,1},Tuple{Bool},Tuple{Int64}},Base.Broadcast.Extruded{Array{Real,1},Tuple{Bool},Tuple{Int64}}}},Int64}}, ::UInt64; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/rudolph/.julia/packages/GPUCompiler/uTpNx/src/cache.jl:40
[10] broadcast_kernel at /home/rudolph/.julia/packages/GPUArrays/Z5nPF/src/host/broadcast.jl:57 [inlined]
[11] cached_compilation at /home/rudolph/.julia/packages/GPUCompiler/uTpNx/src/cache.jl:65 [inlined]
[12] cufunction(::GPUArrays.var"#broadcast_kernel#16", ::Type{Tuple{CUDA.CuKernelContext,CuDeviceArray{Float32,1,1},Base.Broadcast.Broadcasted{Nothing,Tuple{Base.OneTo{Int64}},typeof(+),Tuple{Base.Broadcast.Extruded{CuDeviceArray{Float32,1,1},Tuple{Bool},Tuple{Int64}},Base.Broadcast.Extruded{Array{Real,1},Tuple{Bool},Tuple{Int64}}}},Int64}}; name::Nothing, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/rudolph/.julia/packages/CUDA/mbPFj/src/compiler/execution.jl:289
[13] cufunction at /home/rudolph/.julia/packages/CUDA/mbPFj/src/compiler/execution.jl:286 [inlined]
[14] macro expansion at /home/rudolph/.julia/packages/CUDA/mbPFj/src/compiler/execution.jl:100 [inlined]
[15] #launch_heuristic#857 at /home/rudolph/.julia/packages/CUDA/mbPFj/src/gpuarrays.jl:17 [inlined]
[16] launch_heuristic at /home/rudolph/.julia/packages/CUDA/mbPFj/src/gpuarrays.jl:17 [inlined]
[17] copyto! at /home/rudolph/.julia/packages/GPUArrays/Z5nPF/src/host/broadcast.jl:63 [inlined]
[18] copyto! at ./broadcast.jl:886 [inlined]
[19] materialize! at ./broadcast.jl:848 [inlined]
[20] materialize! at ./broadcast.jl:845 [inlined]
[21] excite!(::StructArrays.StructArray{LIF{Float32,Int64},1,NamedTuple{(:voltage, :current, :lastt, :τm, :vreset, :R),Tuple{CuArray{Float32,1},CuArray{Float32,1},CuArray{Int64,1},CuArray{Float32,1},CuArray{Float32,1},CuArray{Float32,1}}},Int64}, ::Array{Real,1}) at /home/rudolph/git/SpikingNN.jl/src/models/lif.jl:55
[22] excite!(::StructArrays.StructArray{Soma{LIF{Float32,Int64},SpikingNN.Threshold.Ideal{Float64}},1,NamedTuple{(:body, :threshold),Tuple{StructArrays.StructArray{LIF{Float32,Int64},1,NamedTuple{(:voltage, :current, :lastt, :τm, :vreset, :R),Tuple{CuArray{Float32,1},CuArray{Float32,1},CuArray{Int64,1},CuArray{Float32,1},CuArray{Float32,1},CuArray{Float32,1}}},Int64},StructArrays.StructArray{SpikingNN.Threshold.Ideal{Float64},1,NamedTuple{(:vth,),Tuple{CuArray{Float64,1}}},Int64}}},Int64}, ::Array{Real,1}) at /home/rudolph/git/SpikingNN.jl/src/neuron.jl:27
[23] evaluate!(::Population{Soma{LIF{Float32,Int64},SpikingNN.Threshold.Ideal{Float64}},StructArrays.StructArray{Soma{LIF{Float32,Int64},SpikingNN.Threshold.Ideal{Float64}},1,NamedTuple{(:body, :threshold),Tuple{StructArrays.StructArray{LIF{Float32,Int64},1,NamedTuple{(:voltage, :current, :lastt, :τm, :vreset, :R),Tuple{CuArray{Float32,1},CuArray{Float32,1},CuArray{Int64,1},CuArray{Float32,1},CuArray{Float32,1},CuArray{Float32,1}}},Int64},StructArrays.StructArray{SpikingNN.Threshold.Ideal{Float64},1,NamedTuple{(:vth,),Tuple{CuArray{Float64,1}}},Int64}}},Int64},CuArray{Float64,2},StructArrays.StructArray{SpikingNN.Synapse.Alpha{Int64,Float32},2,NamedTuple{(:lastspike, :q, :τ),Tuple{CuArray{Float32,2},CuArray{Float32,2},CuArray{Float32,2}}},Int64},George}, ::Int64; dt::Float64, dense::Bool, inputs::Array{Any,1}) at /home/rudolph/git/SpikingNN.jl/src/population.jl:92
[24] simulate!(::Population{Soma{LIF{Float32,Int64},SpikingNN.Threshold.Ideal{Float64}},StructArrays.StructArray{Soma{LIF{Float32,Int64},SpikingNN.Threshold.Ideal{Float64}},1,NamedTuple{(:body, :threshold),Tuple{StructArrays.StructArray{LIF{Float32,Int64},1,NamedTuple{(:voltage, :current, :lastt, :τm, :vreset, :R),Tuple{CuArray{Float32,1},CuArray{Float32,1},CuArray{Int64,1},CuArray{Float32,1},CuArray{Float32,1},CuArray{Float32,1}}},Int64},StructArrays.StructArray{SpikingNN.Threshold.Ideal{Float64},1,NamedTuple{(:vth,),Tuple{CuArray{Float64,1}}},Int64}}},Int64},CuArray{Float64,2},StructArrays.StructArray{SpikingNN.Synapse.Alpha{Int64,Float32},2,NamedTuple{(:lastspike, :q, :τ),Tuple{CuArray{Float32,2},CuArray{Float32,2},CuArray{Float32,2}}},Int64},George}, ::Int64; dt::Float64, cb::var"#12#13", dense::Bool, inputs::Array{Any,1}) at /home/rudolph/git/SpikingNN.jl/src/population.jl:167
[25] top-level scope at /home/rudolph/git/SpikingNN.jl/examples/population-test.jl:75
[26] include(::String) at ./client.jl:457
[27] top-level scope at REPL[1]:1
in expression starting at /home/rudolph/git/SpikingNN.jl/examples/population-test.jl:75
Hi there,
To test if I could simulate spiking neural networks with GPU I modified the population-test.jl file (now called population-gpu-test.jl)
To make the example a bit less trivial I made the neuron population 100 by creating a square neuron weight matrix as such:
https://github.com/russelljjarvis/SpikingNN.jl/blob/master/examples/population-gpu-test.jl#L12
I also tried to make the neuron activity a bit more balanced by distributing the inputs so only 1/3 of inputs are strong.
https://github.com/russelljjarvis/SpikingNN.jl/blob/master/examples/population-gpu-test.jl#L35-L37
All of these modifications work if I use:
on line 16 but they break if I use
instead.
See the stack trace below.