Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Recurrent class will not function without a GPU #901

Open
Vectorrent opened this issue Jun 29, 2023 · 1 comment
Open

The Recurrent class will not function without a GPU #901

Vectorrent opened this issue Jun 29, 2023 · 1 comment
Labels

Comments

@Vectorrent
Copy link

Vectorrent commented Jun 29, 2023

A GIF or MEME to give some spice of the internet

What is wrong?

I am trying to use the new Recurrent class from inside of a Docker container, which does not have access to a GPU driver. This is the error I receive, when trying to train:

one-test-1  | /one/node_modules/gpu.js/src/gpu.js:185
one-test-1  |         throw new Error(`A requested mode of "${this.mode}" and is not supported`);
one-test-1  |               ^
one-test-1  | 
one-test-1  | Error: A requested mode of "gpu" and is not supported
one-test-1  |     at GPU.chooseKernel (/one/node_modules/gpu.js/src/gpu.js:185:15)
one-test-1  |     at new GPU (/one/node_modules/gpu.js/src/gpu.js:124:10)
one-test-1  |     at makeKernel (/one/node_modules/brain.js/dist/index.js:254:24)
one-test-1  |     at Input.setupKernels (/one/node_modules/brain.js/dist/index.js:2466:33)
one-test-1  |     at Recurrent.initializeLayers (/one/node_modules/brain.js/dist/index.js:3869:19)
one-test-1  |     at Recurrent.initialize (/one/node_modules/brain.js/dist/index.js:5996:14)
one-test-1  |     at Recurrent.verifyIsInitialized (/one/node_modules/brain.js/dist/index.js:3987:18)
one-test-1  |     at Recurrent._prepTraining (/one/node_modules/brain.js/dist/index.js:6075:14)
one-test-1  |     at Recurrent.train (/one/node_modules/brain.js/dist/index.js:6042:56)
one-test-1  |     at file:///one/src/custom.js:33:5
one-test-1  | 
one-test-1  | Node.js v20.3.1
one-test-1  | 
one-test-1 exited with code 0

Where does it happen?

Inside the node:20-alpine Docker image.

How do we replicate the issue?

Try to execute the following code from Node.js, within an environment that has no GPU driver:

import { Recurrent, layer, utilities } from 'brain.js'
const { add, input, multiply, output, random, rnnCell, lstmCell } = layer

const net = new Recurrent({
  inputLayer: () => input({ height: 1 }),
  hiddenLayers: [
    (inputLayer, recurrentInput) =>
      lstmCell({ height: 10 }, inputLayer, recurrentInput),
  ],
  outputLayer: (inputLayer) => output({ height: 1 }, inputLayer),
})

const xor = [
  [[0.001], [0.001], [0.001]],
  [[0.001], [1], [1]],
  [[1], [0.001], [1]],
  [[1], [1], [0.001]],
]


net.train(xor, {
    errorThresh: 0.03,
    iterations: 5000,
    log: (details) => console.log(details),
    logPeriod: 1
})

console.log(net.run([0, 1]))

(I don't think this code actually works as-is, because I can't get it running in the browser, either.)

Expected behavior (i.e. solution)

Brain.js should select 'cpu' mode, and proceed with training. Or, it should throw an error which states that 'cpu' mode is unsupported. It should never request 'gpu' mode in an environment without a GPU.

Version information

Nodejs:

20.3.0

Brain.js:

beta 23

How important is this (1-5)?

3

@Vectorrent Vectorrent added the bug label Jun 29, 2023
@cclauss
Copy link
Contributor

cclauss commented Jul 24, 2023

Oh... Does this explain some of the nine failing tests in #905 ?!? If so, would it be possible to mark our jest tests as expected-to-fail-if there is no GPU or even if the environment variable $CI is defined?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants