brain.js icon indicating copy to clipboard operation
brain.js copied to clipboard

brain.js without gpu.js?

Open TSel1209 opened this issue 1 year ago • 6 comments

Hello, I'm trying to use brain.js on a Raspberry Pi Pico (using Kaluma). The only issue is that it won't work without gpu.js. And the Raspberry Pi Pico doesn't have a GPU, as it's a microcontroller. Is there a way to make brain.js run without the gpu.js module?

TSel1209 avatar Oct 28 '22 17:10 TSel1209

my effort was to make it so that you didnt need GPU. js if you only had brain.js. if this is the case, I need to adjust something.

robertleeplummerjr avatar Oct 29 '22 01:10 robertleeplummerjr

I should probably add that I'm not using the NPM package. I actually downloaded the file from the website that's mainly used in web browsers, because I was unable to get the NPM package onto the board.

TSel1209 avatar Oct 29 '22 12:10 TSel1209

Thanks for the tip @kdevcse! Your changes fixed the following problem for me, on Arch:

npm ERR! code 7
npm ERR! path /home/crow/Repos/eliza/node_modules/gl
npm ERR! command failed
npm ERR! command sh -c -- prebuild-install || node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 2.7.18 found at "/usr/bin/python2.7"
npm ERR! gyp ERR! UNCAUGHT EXCEPTION 
npm ERR! gyp ERR! stack TypeError: Cannot assign to read only property 'cflags' of object '#<Object>'
npm ERR! gyp ERR! stack     at createConfigFile (/home/crow/Repos/eliza/node_modules/node-gyp/lib/configure.js:117:21)
npm ERR! gyp ERR! stack     at /home/crow/Repos/eliza/node_modules/node-gyp/lib/configure.js:84:9
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:189:23)
npm ERR! gyp ERR! System Linux 6.0.7-arch1-1
npm ERR! gyp ERR! command "/usr/bin/node" "/home/crow/Repos/eliza/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/crow/Repos/eliza/node_modules/gl
npm ERR! gyp ERR! node -v v19.0.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! Node-gyp failed to build your package.
npm ERR! gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.

You might consider opening a PR in this repo (instead of your own), because I'm not sure if the maintainers saw the original one. This seems like a decent solution to a problem that plagued me, across multiple environments.

Vectorrent avatar Nov 13 '22 12:11 Vectorrent

Thanks for the tip @kdevcse! Your changes fixed the following problem for me, on Arch:

npm ERR! code 7
npm ERR! path /home/crow/Repos/eliza/node_modules/gl
npm ERR! command failed
npm ERR! command sh -c -- prebuild-install || node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 2.7.18 found at "/usr/bin/python2.7"
npm ERR! gyp ERR! UNCAUGHT EXCEPTION 
npm ERR! gyp ERR! stack TypeError: Cannot assign to read only property 'cflags' of object '#<Object>'
npm ERR! gyp ERR! stack     at createConfigFile (/home/crow/Repos/eliza/node_modules/node-gyp/lib/configure.js:117:21)
npm ERR! gyp ERR! stack     at /home/crow/Repos/eliza/node_modules/node-gyp/lib/configure.js:84:9
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:189:23)
npm ERR! gyp ERR! System Linux 6.0.7-arch1-1
npm ERR! gyp ERR! command "/usr/bin/node" "/home/crow/Repos/eliza/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/crow/Repos/eliza/node_modules/gl
npm ERR! gyp ERR! node -v v19.0.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! Node-gyp failed to build your package.
npm ERR! gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.

You might consider opening a PR in this repo (instead of your own), because I'm not sure if the maintainers saw the original one. This seems like a decent solution to a problem that plagued me, across multiple environments.

Done!

kdevcse avatar Nov 14 '22 08:11 kdevcse

What worked for me was yarn add gpu.js (I guess you could use npm install gpu.js too)

tomek7667 avatar Feb 16 '23 15:02 tomek7667

my effort was to make it so that you didnt need GPU. js if you only had brain.js. if this is the case, I need to adjust something.

That's not how it works currently. If you don't install gpu.js then brain.js won't work, even on something that isn't GPU accelerated like recurrent.LSTM().

elvis-pereira avatar Feb 16 '23 21:02 elvis-pereira