You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the Vulkan backend on my machine, it frequently falls back to using the CPU for inference. This seems to be happening because we're not giving vulkaninfo enough time to complete when trying to detect the GPU.
Currently, we're using TimeSpan.FromSeconds(1) as the timeout for the vulkaninfo --summary command in GetVulkanSummary(). However, on my machine, running this command takes about 1.92 seconds on average. This means that most of the time, the command times out before it can return the necessary information, leading to the GPU not being detected and the fallback to CPU inference.
I did a quick test using a batch script to measure the execution time of vulkaninfo --summary (see code snippets below). This confirmed that the command consistently takes longer than 1 second to complete on my system.
To address this, I simply increased the timeout to 10 seconds (TimeSpan.FromSeconds(10)). This seems to have resolved the issue, as the GPU is now consistently detected and used for inference.
I would appreciate if we got this changed in next release.
Code Snippets:
Current GetVulkanSummary() function:
privatestaticstring?GetVulkanSummary(){// Note: on Linux, this requires `vulkan-tools` to be installed. (`sudo apt install vulkan-tools`)try{// Start a process to read vulkan infoProcessprocess=new(){StartInfo=new(){FileName="vulkaninfo",Arguments="--summary",RedirectStandardOutput=true,RedirectStandardError=true,UseShellExecute=false,CreateNoWindow=true}};var(exitCode, output, error, ok)= process.SafeRun(TimeSpan.FromSeconds(1));// Timeout is 1 second which needs to be increasedif(!ok)returnnull;// Return the outputreturnoutput;}catch{// Return null if we failed to get the Vulkan versionreturnnull;}}
Batch script for measuring vulkaninfo execution time:
Description
When using the Vulkan backend on my machine, it frequently falls back to using the CPU for inference. This seems to be happening because we're not giving
vulkaninfo
enough time to complete when trying to detect the GPU.Currently, we're using
TimeSpan.FromSeconds(1)
as the timeout for thevulkaninfo --summary
command inGetVulkanSummary()
. However, on my machine, running this command takes about 1.92 seconds on average. This means that most of the time, the command times out before it can return the necessary information, leading to the GPU not being detected and the fallback to CPU inference.I did a quick test using a batch script to measure the execution time of
vulkaninfo --summary
(see code snippets below). This confirmed that the command consistently takes longer than 1 second to complete on my system.To address this, I simply increased the timeout to 10 seconds (
TimeSpan.FromSeconds(10)
). This seems to have resolved the issue, as the GPU is now consistently detected and used for inference.I would appreciate if we got this changed in next release.
Code Snippets:
Current
GetVulkanSummary()
function:Batch script for measuring
vulkaninfo
execution time:Example output from the batch script:
Reproduction Steps
Environment & Configuration
Known Workarounds
No response
The text was updated successfully, but these errors were encountered: