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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU Device Error: Uncaught (in promise) TypeError: lib$1.exports.detectGPUDevice is not a function #319

Open
devluixos opened this issue Feb 28, 2024 · 5 comments

Comments

@devluixos
Copy link

devluixos commented Feb 28, 2024

Hey WebLLM Team! 馃専

I've been diving into integrating WebLLM within an Obsidian plugin and stumbled upon a little hiccup. Running on Windows 11 with an Intel processor (which should have integrated graphics), I encountered the following error when trying to get my chat module up and running:
TypeError: lib$1.exports.detectGPUDevice is not a function

This pops up during the ChatModule's reload method execution. Here's a quick peek at the code causing the problem:

import * as webllm from "@mlc-ai/web-llm";

const chat = new webllm.ChatModule();

export async function generateResponse(prompt: string): Promise<string> {
  const myAppConfig: webllm.AppConfig = {
    model_list: [
      {
        "model_url": "https://huggingface.co/mlc-ai/Llama-2-7b-chat-hf-q4f32_1-MLC/resolve/main/",
        "local_id": "Llama-2-7b-chat-hf-q4f32_1",
        "model_lib_url": "https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-7b-chat-hf/Llama-2-7b-chat-hf-q4f32_1-ctx4k_cs1k-webgpu.wasm",
      },
    ]
  }

  const selectedModel = "Llama-2-7b-chat-hf-q4f32_1"
  await chat.reload(selectedModel, undefined, myAppConfig);

  const reply = await chat.generate(prompt);
  return reply;
}

Since the plugin runs inside Obsidian, I'm curious if the environment might be affecting WebGPU support or if there's something else at play. Any tips, tricks, or insights you could share would be super appreciated!

Thanks in advance!

@DavidGOrtega
Copy link
Contributor

This has happened to me also with electron and react 18 (hidden webpack 5). Same electron was able to run it with parcel.
To my mind this is more an issue with the bundler.

@DavidGOrtega
Copy link
Contributor

@Luix-dev if you share more details I might be able to figure out a bit.

@devluixos
Copy link
Author

@Luix-dev if you share more details I might be able to figure out a bit.

Thank you! What information do you require?
Here are some things:

  • @mlc-ai/web-llm": "^0.2.23
  • @tsconfig/svelte": "^5.0.2
  • @types/node": "^16.11.6
  • @typescript-eslint/eslint-plugin": "5.29.0
  • @typescript-eslint/parser": "5.29.0
  • esbuild": "^0.20.0
  • typescript": "4.7.4

If the project itself would be a bigger help, here's the git link:
https://github.com/Luix-dev/TextSight

If you want to try it in obsidian you'll have to clone the folder into the plugins folder.
Otherwise, I can provide further information if you tell me what would be important

Thanks in advance!

@devluixos
Copy link
Author

I haven't found any solutions to this problem.
It's the environment, inside obsidian, that causes it, especially those related to hardware access like GPU detection. (Or at least I think it is)

@DavidGOrtega
Copy link
Contributor

@devluixos I have managed to identify whats wrong with obsidian but I do not have yet the solution (almost). the issue is that obsidian is electron and probably has the feature contextIsolation to false for some reason that I have yet to identify it does not like it. I know it because I have also an electron app using web-llm and this has happened to me. I will come back

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

No branches or pull requests

2 participants