web-llm
web-llm copied to clipboard
Initialize GPU device: WebGPU - Intel(R) UHD Graphics 630
I have successfully run on my macOS, but the GPU is using Intel, which is too slow. My macOS is equipped with an 8G AMD graphics card, how can I switch to this graphics card?
Hello @ZhouXiaolin
I think I find how to choose the right card but I cannot try it locally because when I'm using https://github.com/mlc-ai/web-llm/issues/19#issuecomment-1510426287 it refuses to initialize properly my GPU but it works on the demo webpage.
Based on the TVMJS method
/**
* DetectGPU device in the environment.
*/
export async function detectGPUDevice(): Promise<GPUDevice | undefined | null> {
if (typeof navigator !== "undefined" && navigator.gpu !== undefined) {
const adapter = await navigator.gpu.requestAdapter();
return await adapter?.requestDevice();
} else {
return undefined;
}
}
It will return the first GPU but if you define high-performance parameter it changes.
a = await navigator.gpu.requestAdapter()
GPUAdapter?{features: GPUSupportedFeatures, limits: GPUSupportedLimits, isFallbackAdapter: false}
await a.requestAdapterInfo()
GPUAdapterInfo?{vendor: 'intel', architecture: 'gen-7', device: '0x0152', description: 'Intel(R) HD Graphics 2500 (IVB GT1)', driver: 'Intel open-source Mesa driver: Mesa 22.2.5'}
a = await navigator.gpu.requestAdapter({"powerPreference":"high-performance"})
GPUAdapter?{features: GPUSupportedFeatures, limits: GPUSupportedLimits, isFallbackAdapter: false}
await a.requestAdapterInfo()
GPUAdapterInfo?{vendor: 'nvidia', architecture: 'pascal', device: '0x1c03', description: 'NVIDIA GeForce GTX 1060 6GB', driver: 'NVIDIA: 525.105.17 525.105.17.0'}
@kadogo thank you for great discovery, do you mind send a PR to the tvm unity branch https://github.com/apache/tvm/tree/unity adding {"powerPreference":"high-performance"}.
Thanks @kadogo you are my savior, such a good finding !
Hello @tqchen
I got it working so I will do the PR a bit later in the evening. I will add more info in #19 how it is working now for me.
Hello @tqchen
Little double post because I'm uncertain if you will notice if I edit my previous answer. The MR is done at https://github.com/apache/tvm/pull/14650 (I did it the wrong way first sorry)
I hope it's correctly done.
Cheers
Thank you!