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

Can't import gpu.js #1084

Closed
john--kane opened this issue Aug 16, 2022 · 8 comments
Closed

Can't import gpu.js #1084

john--kane opened this issue Aug 16, 2022 · 8 comments
Labels
bug Something isn't working crash An issue that could cause a crash

Comments

@john--kane
Copy link

Version

0.1.8

Platform

macOS x64

What steps will reproduce the bug?

I'm getting a Seg Fault when I import gpu.js into my script.

I ran:

SegmentationFault at 0x0000000000000000

----- bun meta -----
Bun v0.1.8 macOS x64
RunCommand:
Elapsed: 15ms | User: 13ms | Sys: 8ms
RSS: 14.48MB | Peak: 14.47MB | Commit: 67.11MB | Faults: 0
----- bun meta -----

How often does it reproduce? Is there a required condition?

every time, just steps above to reproduce

What is the expected behavior?

console log output with the calculated value (3)

What do you see instead?

Seg Fault

Additional information

Output from bun runtime:

SegmentationFault at 0x0000000000000000

----- bun meta -----
Bun v0.1.8 macOS x64
RunCommand:
Elapsed: 16ms | User: 14ms | Sys: 7ms
RSS: 14.54MB | Peak: 14.54MB | Commit: 67.11MB | Faults: 0
----- bun meta -----

Ask for #help in https://bun.sh/discord or go to https://bun.sh/issues

@john--kane john--kane added bug Something isn't working needs repro Needs an example to reproduce labels Aug 16, 2022
@innerop
Copy link

innerop commented Aug 16, 2022

Casual observer here...

AFAIK, you need a GPU<->JS layer like Google's ANGLE (to support WebGL on Node)

https://github.com/tensorflow/tfjs/tree/master/tfjs-backend-nodegl (mentions Node-GLES and ANGLE)

Or jump straight to WebGPU where you can use compute shaders

The gpu.js project currently has an empty folder for webgpu api support: https://github.com/gpujs/webgpu

I think bun has to support either WebGL via ANGLE or a WebGPU implementation or else you won't have any GPU support

@john--kane
Copy link
Author

Hi innerop,

Thanks for the insight. Makes sense.

I kind of guessed the js engine under the bunjs hood would have provided that layer.

I ran the gpu.js code on node & demo and worked straight up without explicit angle deps. Is that to imply then that it has some node binding? If the webgl folder is empty, how might I get its bindings in bun?

I tried it on an older version of bun (not a comprehensive test) and it threw an exception around gl Error stacktrace bindings so I'm wondering if it's so low level thing that's not ported yet?

@innerop
Copy link

innerop commented Aug 16, 2022

I assume in Node and Deno if the GPU layer is not available GPU.js will default to CPU usage.

However, I am not knowledgeable enough on what comes with Node out of the box as far as GPU support. My assumption is that such a layer is not built-in and has to be added, somehow.

In Node, the dependency for a WebGL backend is node-gles (which depends on ANGLE) ...

I do not know if Deno supports WebGPU out of the box (maybe it does) and I'm not sure what support for WebGPU exists in Node plugins/packages.

AFAIK, WebGPU provides compute shaders which I believe make GPU.js largely redundant.

Bun's author should know a lot more on the topic of Bun's support for GPU compute.

@john--kane
Copy link
Author

Thanks for that, definitely helpful.

I'll drop a message on discord as well to see if I can get a lead on gl bindings in bun specifically.

@john--kane
Copy link
Author

Is there anyone from the bun team that can help out? Tried discord but no luck. @Jarred-Sumner

@innerop
Copy link

innerop commented Aug 28, 2022

@Jarred-Sumner bumping

it's a really simple question (yes/no/depends): does bun support node.js packages that require GPU accress?

@Electroid
Copy link
Contributor

Attempted to run the following code, it looks like gpu.js also depends on Error.prepareStackTrace (#258)

import { GPU, KernelFunction, IKernelRunShortcut } from 'gpu.js';

const gpu = new GPU({ mode: 'gpu' });
const kernelFunction: KernelFunction = function(anInt: number, anArray: number[], aNestedArray: number[][]) {
  const x = .25 + anInt + anArray[this.thread.x] + aNestedArray[this.thread.x][this.thread.y];
  return x;
};
const kernel: IKernelRunShortcut = gpu.createKernel(kernelFunction)
  .setOutput([1]);
const result = kernel(1, [.25], [[1.5]]);
console.log(result[0]); // 3

@Electroid Electroid removed the needs repro Needs an example to reproduce label Nov 3, 2022
@Electroid Electroid added the crash An issue that could cause a crash label Oct 24, 2023
@Electroid
Copy link
Contributor

Since #258 you can run gpu.js. However, we still need to fix #4959 for you to be able to run bun install gpu.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash An issue that could cause a crash
Projects
None yet
Development

No branches or pull requests

3 participants