Wgpu adapter request/enumeration freezes

Hello, I am fairly new to Rust and I wanted to experiment with getting windowing and graphics to work.

I wanted to run the "hello" example from the wgpu repository but it does not work on my machine. When I run it, it prints out "Available adapters:" and then freezes. It is doing something, obviously, since its CPU usage stays at 22% on task manager, but nothing is happening and when I press Ctrl+C to abort the program it takes a second before it does so, which might be a bit strange. I would have expected this to at least print out information about my integrated and discrete graphics cards.

I am running this on Windows 11. This is the code I used, adapted from the relevant file in the wgpu repository:

/// This example shows how to describe the adapter in use.
async fn run() {
    let adapter = {
        let instance = wgpu::Instance::default();

        {
            println!("Available adapters:");
            for a in instance.enumerate_adapters(wgpu::Backends::all()) {
                println!("    {:?}", a.get_info())
            }
        }

        instance
            .request_adapter(&wgpu::RequestAdapterOptions::default())
            .await
            .unwrap()
    };

    println!("Selected adapter: {:?}", adapter.get_info())
}

pub fn main() {
    pollster::block_on(run());
}

Cargo.toml (probably relevant):

[package]
name = "wgpu-examples"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
pollster = "0.3.0"
wgpu = "0.20.1"

Weird!

What if you set Backend specifically? At least PRIMARY should work, but if it still happens with just DX12 something is really wrong.

The only thing after that I could think to check is to update drivers? But that seems implausible.

Two things come to mind: First, use the wgpu-info tool to list all of the adapters on the system (it prints info and exits, no graphics are drawn at all). If this also freezes, then you have some environmental issue to solve on your own. The output will tell you which backends and adapters you have available for further troubleshooting (as suggested by @simonbuchan above.)

Second, make sure all of your GPU drivers are up-to-date. You mention your system has both an integrated and discrete GPU. You need the latest drivers for both. GPU drivers are notoriously problematic, and having the most recent versions gives you the best chance of avoiding driver bugs that can cause these kinds of unusual behaviors.

2 Likes

Sorry for the delay, I had decided I was going to make what I was going to make 3 days ago in C...

Anyway, I tried your suggestion, and fortunately I've gotten some information on this issue. It looks like the freeze comes from enumerating Vulkan adapters. But I do know I have a properly working Vulkan adapter, because I am at least able to run Godot. There are also a few peculiarities in the output though, and I'm not sure if these are wgpu issues or issues on my system. For the DX12 backend, the integrated GPU "AMD Radeon(TM) Vega 8 Graphics" is listed twice, and for the GL backend, my discrete GPU "NVIDIA GeForce GTX 1050" is missing. I expected it to show up because I have ran Java Minecraft on it before (pretty sure it uses only OpenGL), though it could have just been using some sort of compatibility layer I suppose.

and by the way, wgpu-info also freezes.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.