BrainJS / BrainJS/brain.js

trainasync run on single thread

Open
#800 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
14.9k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

## _What_ is wrong?

I test the trainasync and as far I check, it only run on single thread

## _Where_ does it happen?
`net.trainAsync`

## Version information

### Nodejs:
`v16.14.2`

### Brain.js:
`2.0.0-beta.15`

I check in resourse monitor the # of thread that node run when i train the net in a single thread or async with 12 thread. Both start running on 16 threads and then go down to 12, sometimes grew to 13. What I'm doing wrong?

```
//Generate NN
const net = new brain.NeuralNetwork({
hiddenLayers: hiddenLayers
activation: 'sigmoid'

});

console.log(`${hiddenLayers} Error: ${errorThresh} Range Ticks (15m): ${range_ticks}`)

net.trainAsync(trainingData, {
parallel: {
threads: 12,
partitionSize: 3200,
},
errorThresh: errorThresh,
log: true,
logPeriod: 10,
iterations: 30000,
// learningRate: 0.001
}).then((res) => {
console.log(res)
let save_data = {
brain: net.toJSON()
}
}).catch((err) => { console.log('Error', err) })
```

Also I try to run on GPU and CPU and GPU never get any work done.

Note: Resource monitor says that node its only consuming 8% of the CPU

![image](https://user-images.githubusercontent.com/70331/171091674-7c9796f2-c8d9-457a-ba21-a060818ac483.png)

CPU: Intel(R) Core(TM) i7-7800X CPU @ 3.50GHz 3.50 GHz
GPU: 1080 TI

Contributor guide

Open the contributing guide

Research direction

Start at the `net.trainAsync` entry point and reproduce the reported behavior with Node.js v16.14.2, `parallel.threads: 12`, and `partitionSize: 3200`. Compare CPU and GPU execution while checking the supplied training configuration; done means the intended parallel or GPU work is either functioning as documented or the limitation is clearly identified and covered by a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
machine-learning, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.