GPU support both slow and wrong - almost hangs computer, node and chrome
See original GitHub issueWhat is wrong?
Not sure what to expect from GPU support. Weird training results.
Where does it happen?
Running Windows 7, Node v12.13.1, Chrome 80.0.3987.132, brain.js several versions - downloaded brain-browser.js from github, cloned repo development branch, master branch, 2.0.0-alpha.2 Geforce GTX Titan X with 441.12
How do we replicate the issue?
In browser
<html>
<head>
<script src="../brain.js/dist/brain-browser.js"></script>
<script>
const net = new brain.NeuralNetworkGPU();
const xorTrainingData = [
{input: [0, 0], output: [0]},
{input: [0, 1], output: [1]},
{input: [1, 0], output: [1]},
{input: [1, 1], output: [0]}
];
const opts = {
log: true,
logPeriod: 100,
iterations: 300
}
console.log(net.train(xorTrainingData, opts));
console.log(net.run([0,0]), Math.round( net.run([0,0]) ));
console.log(net.run([0,1]), Math.round( net.run([0,1]) ));
console.log(net.run([1,0]), Math.round( net.run([1,0]) ));
console.log(net.run([1,1]), Math.round( net.run([1,1]) ));
</script>
</head>
<body></body>
</html>
This pretty much hangs chrome for me, the tab becomes unresponsive and I have to pause javascript execution to have any chance to close the tab without force shutting down chrome. Increasing iterations or changing hidden layers or experimenting with other parameters have basically no effect.
//all four outputs
0.5000461935997009
0.5000461935997009
0.5000461935997009
0.5000461935997009
In node
const brain = require('brain.js');
const start = new Date()
console.log(brain)
const net = new brain.NeuralNetworkGPU({ hiddenLayers: [10] });
const xorTrainingData = [
{input: [0, 0], output: [0]},
{input: [0, 1], output: [1]},
{input: [1, 0], output: [1]},
{input: [1, 1], output: [0]}];
console.log(net.train(xorTrainingData, {
log: true,
logPeriod: 100,
iterations: 20000
}));
console.log( net.run([0,0]), Math.round( net.run([0,0]) ));
console.log( net.run([0,1]), Math.round( net.run([0,1]) ));
console.log( net.run([1,0]), Math.round( net.run([1,0]) ));
console.log( net.run([1,1]), Math.round( net.run([1,1]) ));
const after = new Date()
console.log((after.getTime() - start.getTime()) / 1000)
With GPU
iterations: 4100, training error: 0.006740194745361805
iterations: 4200, training error: 0.005839236546307802
iterations: 4300, training error: 0.005128919146955013
iterations: 4400, training error: 0.004557380452752113
{ error: 0.004557380452752113, iterations: 4400 }
Float32Array [ 0.09155591577291489 ] 0
Float32Array [ 0.09155591577291489 ] 0 <------------- slow AND wrong
Float32Array [ 0.09155591577291489 ] 0
Float32Array [ 0.09155591577291489 ] 0
7.165 (seconds)
Without GPU - (new brain.NeuralNetwork) on row 7
iterations: 4200, training error: 0.006874370443914483
iterations: 4300, training error: 0.006211034862270221
iterations: 4400, training error: 0.005647163558867768
iterations: 4500, training error: 0.005163651528723463
{ error: 0.004997787408525928, iterations: 4538 }
Float32Array [ 0.052155524492263794 ] 0
Float32Array [ 0.9345424175262451 ] 1
Float32Array [ 0.9339274764060974 ] 1
Float32Array [ 0.09189336001873016 ] 0
0.055 (seconds)
How important is this (1-5)?
4
Expected behavior (i.e. solution).
Faster training time in both Node and Browser environment with same training results.
Other Comments
Loving brain.js ❤️ - I’m solving a Rubiks Cube using it for fun, very interesting!
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Chrome Freezing and making system Unresponsive?
The stream will almost stop/freeze and then chrome locks up. Are there any known issues at the moment? Chrome Version: 80.0.3987.100 - to ......
Read more >GPU process crashes with high chance if you switch quickly ...
I found a fix/workaround for the crashes, by setting chrome://flags "Choose ANGLE graphics backend" to either D3D9 or OpenGL, and I couldnt make...
Read more >VSCode freezes when switching from Chrome to it #28709
Here is a checklist to find out more about the freeze/slow/crash ... it reproduces when running with GPU disabled ( code --disable-gpu )...
Read more >How to Fix It When Chrome Keeps Freezing - Lifewire
Many things can cause Google Chrome to keep freezing or crashing when ... Hardware acceleration uses the computer's GPU (video card) for ...
Read more >Chrome Not Using My GPU! - Google Groups
Chrome is using a lot of my PC's CPU and RAM and it's making my PC freeze and lag and it's not using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Will be published soon.Confirmed! Problem still exists in
2.0.Beta.1
@goferito cc
Found the issue, at least for the active branch I’m working on, which is
rnn-cleanup
. I’ll have it released in the next day or two.