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

onnxruntime-web/webgpu not found in next js #22200

Closed
naufalahnaf17 opened this issue Sep 24, 2024 · 1 comment
Closed

onnxruntime-web/webgpu not found in next js #22200

naufalahnaf17 opened this issue Sep 24, 2024 · 1 comment
Labels
ep:WebGPU ort-web webgpu provider platform:web issues related to ONNX Runtime web; typically submitted using template

Comments

@naufalahnaf17
Copy link

Describe the issue

image

I am trying to use onnxruntime-web/webgpu in Next.js, but for some reason, the module cannot be found.

I have fine-tuned a ResNet-50 model for classification, and I want to use onnxruntime-web/webgpu for faster processing, but the module is not found.

Am I missing something here? maybe I'm not very familiar with web development but I've followed all the instructions listed in the documentation

To reproduce

  • create next js with latest version

npx create-next-app@latest

  • install onnxruntime-web

npm install onnxruntime-web

import onnxruntime-web/webgpu

import * as ort from 'onnxruntime-web/webgpu';

Error Screenshot

image

Urgency

No response

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.19.2

Execution Provider

'webgpu' (WebGPU)

@naufalahnaf17 naufalahnaf17 added the platform:web issues related to ONNX Runtime web; typically submitted using template label Sep 24, 2024
@github-actions github-actions bot added the ep:WebGPU ort-web webgpu provider label Sep 24, 2024
@naufalahnaf17
Copy link
Author

For anyone experiencing a similar problem, you can do this

'use client'

export default function Page() {
    const createInferenceSession =  async () => {
        if (typeof window !== 'undefined') {
            if (typeof window !== "undefined") {
                const onnx = (await import("onnxruntime-web/webgl")).default;
                // Create Inference Session Here                
            }
        }
    }

    return (
        <div>
            <button onClick={createInferenceSession}>Click</button>
        </div>
    );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ep:WebGPU ort-web webgpu provider platform:web issues related to ONNX Runtime web; typically submitted using template
Projects
None yet
Development

No branches or pull requests

1 participant