trainasync run on single thread
- 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

CPU: Intel(R) Core(TM) i7-7800X CPU @ 3.50GHz 3.50 GHz
GPU: 1080 TI
Contributor 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