Skip to content

[Mobile] How to use GPU acceleration on Android #23194

@lizhiwen19900709

Description

@lizhiwen19900709

Describe the issue

How to use GPU acceleration on Android?The detector model is now too slow to predict!

To reproduce

this.context = context;
env = OrtEnvironment.getEnvironment();

    // 预分配内存
    inputArray = new float[INPUT_SIZE * INPUT_SIZE * 3];
    pixels = new int[INPUT_SIZE * INPUT_SIZE];
    inputBuffer = FloatBuffer.wrap(inputArray);

session = env.createSession(modelPath, sessionOptions);
inputTensor = OnnxTensor.createTensor(env, inputBuffer, new long[]{1, 3, INPUT_SIZE, INPUT_SIZE});
result = session.run(Collections.singletonMap(session.getInputNames().iterator().next(), inputTensor));

Urgency

No response

Platform

Android

OS Version

14

ONNX Runtime Installation

Built from Source

Compiler Version (if 'Built from Source')

No response

Package Name (if 'Released Package')

None

ONNX Runtime Version or Commit ID

1.20.0

ONNX Runtime API

Java/Kotlin

Architecture

X64

Execution Provider

Other / Unknown

Execution Provider Library Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    api:Javaissues related to the Java APIplatform:mobileissues related to ONNX Runtime mobile; typically submitted using templatestaleissues that have not been addressed in a while; categorized by a bot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions