Skip to content

Commit

Permalink
added GPUDevice to all sims
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Jan 13, 2025
1 parent 52bfbf8 commit 5c0ad6f
Show file tree
Hide file tree
Showing 35 changed files with 84 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/emer/axon/v2
go 1.22

require (
cogentcore.org/core v0.3.8-0.20250107202432-e0c4c10448e1
cogentcore.org/core v0.3.8-0.20250113105110-b73be80edead
cogentcore.org/lab v0.0.0-20250109203708-c742f9552551
github.com/anthonynsimon/bild v0.13.0
github.com/cogentcore/yaegi v0.0.0-20240724064145-e32a03faad56
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cogentcore.org/core v0.3.8-0.20250107202432-e0c4c10448e1 h1:rLT0EDrIQKABTyChQNTgh7qfUizUCYVywhJTAAvueU4=
cogentcore.org/core v0.3.8-0.20250107202432-e0c4c10448e1/go.mod h1:Ipnb14B+l0qLzjvcvCIhnDucV9H9RyuqS4knZz5kB8A=
cogentcore.org/core v0.3.8-0.20250113105110-b73be80edead h1:aBcVq6+4XbhphORwy1oyZUGbTSkKMkzyxKnM5Oo/O1c=
cogentcore.org/core v0.3.8-0.20250113105110-b73be80edead/go.mod h1:Ipnb14B+l0qLzjvcvCIhnDucV9H9RyuqS4knZz5kB8A=
cogentcore.org/lab v0.0.0-20250109203708-c742f9552551 h1:aHaTWuqrsVKnwrcPACwAGy8v0KN5bCxgDqcwfzjtsmA=
cogentcore.org/lab v0.0.0-20250109203708-c742f9552551/go.mod h1:cFjKEyMK/eCST7x6sGCGjC12iY+/vcgZime7ASFnM/k=
github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4 h1:6lx9xzJAhdjq0LvVfbITeC3IH9Fzvo1aBahyPu2FuG8=
Expand Down
1 change: 1 addition & 0 deletions sims/bgdorsal/bg-dorsal.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/bgdorsal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ type RunConfig struct {
// GPU uses the GPU for computation.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
2 changes: 2 additions & 0 deletions sims/bgventral/bg-ventral.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"cogentcore.org/core/cli"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -135,6 +136,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/bgventral/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ type RunConfig struct {
// GPU uses the GPU for computation; only for testing in this model -- not faster.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
2 changes: 2 additions & 0 deletions sims/choose/choose.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"cogentcore.org/core/cli"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -138,6 +139,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/choose/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ type RunConfig struct {
// GPU uses the GPU for computation: not faster in this case.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
3 changes: 3 additions & 0 deletions sims/deepfsa/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ type RunConfig struct {
// small models if NData ~16.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
2 changes: 2 additions & 0 deletions sims/deepfsa/deep-fsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"cogentcore.org/core/cli"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -133,6 +134,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/deepmove/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ type RunConfig struct { //types:add
// small models if NData ~16.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
2 changes: 2 additions & 0 deletions sims/deepmove/deep-move.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"cogentcore.org/core/cli"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/math32/vecint"
Expand Down Expand Up @@ -136,6 +137,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/deepmusic/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ type RunConfig struct { //types:add
// small models if NData ~16.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
2 changes: 2 additions & 0 deletions sims/deepmusic/deep-music.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"cogentcore.org/core/cli"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -138,6 +139,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/hip/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ type RunConfig struct {
// small models if NData ~16.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
2 changes: 2 additions & 0 deletions sims/hip/hip.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"cogentcore.org/core/cli"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -133,6 +134,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/inhib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ type RunConfig struct {
// GPU uses the GPU for computation, largely for testing purposes here.
GPU bool `default:"false"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// Trials is the total number of trials of different random patterns to generate.
Trials int `default:"10"`

Expand Down
2 changes: 2 additions & 0 deletions sims/inhib/inhib.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"cogentcore.org/core/cli"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -134,6 +135,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/mpi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type RunConfig struct {
// small models if NData ~16.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
2 changes: 2 additions & 0 deletions sims/mpi/mpi.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"cogentcore.org/core/cli"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -144,6 +145,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
5 changes: 4 additions & 1 deletion sims/objrec/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ type RunConfig struct {
// small models if NData ~16.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down Expand Up @@ -102,7 +105,7 @@ type RunConfig struct {
PlusCycles int `default:"50"`

// CaBinCycles is the number of cycles per CaBin: how fine-grained the synaptic Ca is.
CaBinCycles int `default:"25"`
CaBinCycles int `default:"25"` // no diff for 25 vs. 10

// NZero is how many perfect, zero-error epochs before stopping a Run.
NZero int `default:"2"`
Expand Down
2 changes: 2 additions & 0 deletions sims/objrec/objrec.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"cogentcore.org/core/cli"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -139,6 +140,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
2 changes: 1 addition & 1 deletion sims/objrec/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ var PathParams = axon.PathSheets{
pt.Learn.DWt.SubMean = 1 // 1 -- faster if 0 until 20 epc -- prevents sig amount of late deterioration
pt.SWts.Adapt.LRate = 0.0001 // 0.005 == .1 == .01
pt.SWts.Init.SPct = 1 // 1 >= lower (trace-v11)
pt.Learn.DWt.CaPScale = 0.95 // trace: 0.95 resists late hogging
pt.Learn.DWt.CaPScale = 0.95 // 0.95 essential vs. 1.0
// pt.Learn.DWt.Trace.SetBool(false) // no trace is faster!
}},
{Sel: ".BackPath", Doc: "top-down back-pathways MUST have lower relative weight scale, otherwise network hallucinates -- smaller as network gets bigger",
Expand Down
3 changes: 3 additions & 0 deletions sims/pfcmaint/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ type RunConfig struct {
// GPU uses the GPU for computation; only for testing in this model -- not faster.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
2 changes: 2 additions & 0 deletions sims/pfcmaint/pfcmaint.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"cogentcore.org/core/base/reflectx"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -124,6 +125,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/pvlv/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ type RunConfig struct {
// GPU uses the GPU for computation: not faster in this case.
GPU bool `default:"false"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NThreads is the number of parallel threads for CPU computation;
// 0 = use default.
NThreads int `default:"0"`
Expand Down
2 changes: 2 additions & 0 deletions sims/pvlv/pvlv.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"cogentcore.org/core/cli"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -132,6 +133,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/ra25/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ type RunConfig struct {
// small models if NData ~16.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
2 changes: 2 additions & 0 deletions sims/ra25/ra25.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
// gpu.DebugAdapter = true
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/ra25x/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type RunConfig struct {
// small models if NData ~16.
GPU bool `default:"true"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
2 changes: 2 additions & 0 deletions sims/ra25x/ra25x.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"cogentcore.org/core/cli"
"cogentcore.org/core/core"
"cogentcore.org/core/enums"
"cogentcore.org/core/gpu"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -144,6 +145,7 @@ func (ss *Sim) Run() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
if ss.Config.Run.GPU {
gpu.SelectAdapter = ss.Config.Run.GPUDevice
axon.GPUInit()
axon.UseGPU = true
}
Expand Down
3 changes: 3 additions & 0 deletions sims/rl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ type RunConfig struct {
// GPU uses the GPU for computation; only for testing in this model -- not faster.
GPU bool `default:"false"`

// GPUDevice selects the gpu device to use.
GPUDevice int

// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
Expand Down
Loading

0 comments on commit 5c0ad6f

Please sign in to comment.