iced icon indicating copy to clipboard operation
iced copied to clipboard

Running example on WSL: Error: GraphicsAdapterNotFound

Open Ploppz opened this issue 2 years ago • 31 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Is this issue related to iced?

  • [X] My hardware is compatible and my graphics drivers are up-to-date.

What happened?

When running the clock example in WSL with WSLg installed (graphics support for WSL), the example exits with Error: GraphicsAdapterNotFound. Note that the xclockcommand runs fine in the same terminal. I found that in the wgpu repo, cd wgpu ; cargo run --example cube works fine also. So it seems to be an iced issue.

What is the expected behavior?

It should work without error

Version

master

Operative System

Windows

Do you have any log output?

No response

Ploppz avatar Feb 06 '22 11:02 Ploppz

When running the clock example in WSL with WSLg installed (graphics support for WSL), the example exits with Error: GraphicsAdapterNotFound.

What about the other examples?

Could you try setting the antialiasing flag to false here?

https://github.com/iced-rs/iced/blob/c15701581e52ae838f8e7153ae7e639dd86b1ef6/examples/clock/src/main.rs#L9

hecrj avatar Feb 06 '22 18:02 hecrj

Tried a few other examples like geometry, pick_list - it's the same.

With antialiasing: false it's the same.

Ploppz avatar Feb 06 '22 19:02 Ploppz

Thanks for trying it out.

Could you maybe try setting the environment variable WGPU_BACKEND to vulkan, dx12, dx11, and gl before running an example? Let me know if any of these values help!

hecrj avatar Feb 07 '22 09:02 hecrj

All the options gave the same error except vulkan:

thread 'main' panicked at 'Error in Surface::get_preferred_format: no suitable format found', /home/ploppz/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:214:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Same story with antialiasing true and false.

Ploppz avatar Feb 11 '22 22:02 Ploppz

is this WSLv1 or WSLv2 and do you have CPU virtualization enabled?

genusistimelord avatar Feb 12 '22 00:02 genusistimelord

v2. CPU virtualization is enabled.

Ploppz avatar Feb 12 '22 09:02 Ploppz

Could you provide a backtrace?

I really think the issue here is either environment dependent or wgpu, since we are not doing anything special during initialization.

Did you try the wgpu examples in the 0.12 branch?

hecrj avatar Feb 12 '22 10:02 hecrj

Apparently WSL2 doesn't have good Graphics support yet. Microsoft themself tell you to use Mesa to render things with WSL. They had talked about DX and Vulkan support in 2020 but from what I understand not much has been done about it yet.

So try to use Mesa and see if that works for you. Also there is more about this issue here: https://github.com/gfx-rs/wgpu/issues/1443

genusistimelord avatar Feb 13 '22 00:02 genusistimelord

Could you provide a backtrace?

I can't seem to figure out how to do it - RUST_BACKTRACE=full does not work.

Did you try the wgpu examples in the 0.12 branch?

Works equally fine

So try to use Mesa and see if that works for you. Also there is more about this issue here: https://github.com/gfx-rs/wgpu/issues/1443

Ah it turns out that I have already installed VcXsrv so it seems that I am already using Mesa (?), and I don't have the same issue as linked.

Ploppz avatar Feb 13 '22 15:02 Ploppz

yeah then it is possible your driver doesn't support all the needed features on WSL2. You could try getting the DirectX driver for WSL2 and see if that works OR get the openGL driver for it.

genusistimelord avatar Feb 13 '22 18:02 genusistimelord

same issue under ubuntu Linux ubuntu 5.4.0-99-generic #112~18.04.1-Ubuntu SMP Thu Feb 3 14:09:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

cargo run --features "iced/glow iced/glow_canvas" --package game_of_life Finished dev [unoptimized + debuginfo] target(s) in 0.18s Running target/debug/game_of_life Error: GraphicsAdapterNotFound

cargo run --package game_of_life Finished dev [unoptimized + debuginfo] target(s) in 0.31s Running target/debug/game_of_life [ERROR wgpu_hal::gles::egl] EGL 'eglCreateContext' code 0x3005: eglCreateContext Error: GraphicsAdapterNotFound

I USE VIRTUAL MACHINE(VMWARE) TO RUN UBUNTU , I use internal display card and CPU is 11th Gen Intel(R) Core(TM) i5-1135G7

skydig avatar Feb 19 '22 12:02 skydig

It would be nice to know if this will run directly on your windows OS or not and not inside of a VM. As this could help determine if your GPU is getting passed onto the VM and WSL. I will look into this more hopefully it is just something else. though from the error messages it seems the VM was indeed not getting your Graphics Driver.

genusistimelord avatar Feb 20 '22 05:02 genusistimelord

yeah then it is possible your driver doesn't support all the needed features on WSL2. You could try getting the DirectX driver for WSL2 and see if that works OR get the openGL driver for it.

Reading a guide that says

Assuming you have the right GPU driver installed on the Windows host, /dev/dxg is automatically exposed and available to any WSL distro installed without having to install any additional packages.

Indeed in my WSL, the device /dev/dxg exists.

Furthermore, seeing how wgpu examples work but not iced: Is there thus a feature that Iced uses that wgpu does not? As far as I have seen so far it doesn't really seem like I should have to install more drivers since wgpu works.

Ploppz avatar Feb 20 '22 09:02 Ploppz

yes it is possible the Driver going to your WSL does not support a specific Feature. Though this is why i want you to attempt to run an iced example on your windows Directly to see if maybe your GPU itself doesn't have the feature and it not being WSL fault to begin with. If it does not work on your main windows at all then we have a major feature issue. If it does work and just not on WSL then it means the DX/OpenGL/Vulkan driver does not yet support a specific feature.

The only things i am seeing that could be a issue might be.

https://github.com/iced-rs/iced/blob/adce9e04213803bd775538efddf6e7908d1c605e/wgpu/src/window/compositor.rs#L35 this can cause certain drivers to not get chosen if they don't meet the power plan. generally High power all the way unless on laptops or mobile devices. As this is used to choose the correct GPU Low power means the GPU is a on the processor type. High power is PCIe GPU's. If this is set to low power and you have a PCIe GPU it wont select it. Personally i Think WGPU needs to add one more power option called Adaptable which starts with high power and then checks low power if no high exist.

https://github.com/iced-rs/iced/blob/master/wgpu/src/settings.rs#L76

that could cause issues maybe should use the built in one or let WGPU decide this itself.

https://github.com/iced-rs/iced/blob/master/wgpu/src/settings.rs#L67

Rather than all maybe need to set this as Primary with on fail go to Secondary. But secondary is not fully supported on all systems etc <DX11 and Opengl>. Primary covers the rest and should be able to let WGPU decide which one it can support.

https://github.com/iced-rs/iced/blob/master/wgpu/src/window/compositor.rs#L64

they are not enabling any special features so other then maybe WSL not supporting the default Stuff or one of the above making it not find the GPU adapter is the issue. I think it might be low vs high power settings causing this issue. could try enabling or disabling anti aliases to see. to see if that solves the GPU adapter not found issue. If not then it could be their Selection method not working correctly.

genusistimelord avatar Feb 21 '22 03:02 genusistimelord

@Ploppz Could you retry with the latest master? I believe the patch in #1278 (which I just applied) may fix this issue as well.

hecrj avatar Mar 07 '22 15:03 hecrj

yeah I forgot the default limits are not set for older devices and sometimes wont also work well for web too. Since the texture max dimensions etc matter a lot of older hardware. It would be nice to be able to add a discovery function that could see what the current devices limits are and then choose between regular and downgraded defaults.

genusistimelord avatar Mar 07 '22 16:03 genusistimelord

I pull latest code, issue still exists for some example, cargo run --features "iced/glow iced/glow_canvas" --package solar_system Finished dev [unoptimized + debuginfo] target(s) in 0.27s Running target/debug/solar_system Error: GraphicsAdapterNotFound

skydig avatar Mar 08 '22 13:03 skydig

are you trying to run this in a VM or WSL? Actually Better yet please tell me what your GPU is so i can go check its capabilities. @skydig @Ploppz

Also WSL does not have all the required features needed for this. And most VM's have issues passing GPU access to the VM from the host system.

genusistimelord avatar Mar 08 '22 14:03 genusistimelord

@genusistimelord I USE VIRTUAL MACHINE(VMWARE) TO RUN UBUNTU , I use internal display card(Iris Xe Graphics) and CPU is 11th Gen Intel(R) Core(TM) i5-1135G7 how to fetch more GPU information under ubuntu for you? please tell me the command.

additional information are: example game_of_life is ok example tour is ko example qr_code is ko example svg is ko

skydig avatar Mar 08 '22 14:03 skydig

thank you, so you are attempting to run GPU apps in Ubuntu thru a VM. Well not really sure how well that is going to work for things that need direct GPU access as normally that right is reserved for the Host machine. Could you try to run these Examples on the main Host machine and not on the VM?

You can try the command lspci and see if you can find your GPU mentioned in there.

@skydig https://www.intel.com/content/www/us/en/support/articles/000005520/graphics.html

you can try running the command they give there to find it too.

@skydig

also try disabling Anti-aliasing for the solar example as you are also using a low powered GPU https://github.com/iced-rs/iced/blob/master/examples/solar_system/src/main.rs#L19 Disabling it should allow it to search for low powered Devices. This issue is due to Anti-aliasing requiring high powered device which it shouldn't. it is found here as to what it does when enabled or disabled.

https://github.com/iced-rs/iced/blob/adce9e04213803bd775538efddf6e7908d1c605e/wgpu/src/window/compositor.rs#L38

genusistimelord avatar Mar 08 '22 14:03 genusistimelord

lspci -k|grep -EA3 'VGA|3D|DISPLAY' 00:0f.0 VGA compatible controller: VMware SVGA II Adapter Subsystem: VMware SVGA II Adapter Kernel driver in use: vmwgfx Kernel modules: vmwgfx 00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)

sudo lshw -c video [sudo] password for alcatel: *-display
description: VGA compatible controller product: SVGA II Adapter vendor: VMware physical id: f bus info: pci@0000:00:0f.0 version: 00 width: 32 bits clock: 33MHz capabilities: vga_controller bus_master cap_list rom configuration: driver=vmwgfx latency=64 resources: irq:16 ioport:1070(size=16) memory:e8000000-efffffff memory:fe000000-fe7fffff memory:c0000-dffff

You are right, after disable anti-aliasing, solar_system can be started.

skydig avatar Mar 09 '22 00:03 skydig

@genusistimelord I think the reason to fail to run example 'tour' is different?

cargo run --features "iced/glow iced/glow_canvas" --package tour Compiling tour v0.1.0 (/home/alcatel/iced/examples/tour) error[E0277]: the trait bound iced_glow::backend::Backend: iced_graphics::backend::Image is not satisfied --> examples/tour/src/main.rs:742:9 | 739 | Container::new( | -------------- required by a bound introduced by this call ... 742 | / if cfg!(target_arch = "wasm32") { 743 | | Image::new("tour/images/ferris.png") 744 | | } else { 745 | | Image::new(format!( ... | 750 | | .height(Length::Units(height)) 751 | | .content_fit(content_fit), | |_________________________________^ the trait iced_graphics::backend::Image is not implemented for iced_glow::backend::Backend |

skydig avatar Mar 09 '22 00:03 skydig

lspci -k|grep -EA3 'VGA|3D|DISPLAY' 00:0f.0 VGA compatible controller: VMware SVGA II Adapter Subsystem: VMware SVGA II Adapter Kernel driver in use: vmwgfx Kernel modules: vmwgfx 00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)

sudo lshw -c video [sudo] password for alcatel: *-display description: VGA compatible controller product: SVGA II Adapter vendor: VMware physical id: f bus info: pci@0000:00:0f.0 version: 00 width: 32 bits clock: 33MHz capabilities: vga_controller bus_master cap_list rom configuration: driver=vmwgfx latency=64 resources: irq:16 ioport:1070(size=16) memory:e8000000-efffffff memory:fe000000-fe7fffff memory:c0000-dffff

You are right, after disable anti-aliasing, solar_system can be started.

yeah this tells me that the VM does not see your GPU at all.

Also the trait issue is another issue altogether. @hecrj

genusistimelord avatar Mar 09 '22 03:03 genusistimelord

@skydig Can you try running my branch PR to see if this solves some of your issues as well automatically?

https://github.com/genusistimelord/iced/tree/WGPU_Power_Limits

genusistimelord avatar Mar 09 '22 14:03 genusistimelord

@hecrj With this in Cargo.toml

iced = { git = "https://github.com/hecrj/iced.git"}
iced_native = {git = "https://github.com/hecrj/iced.git"}
iced_graphics = {git = "https://github.com/hecrj/iced.git"}
iced_wgpu = {git = "https://github.com/hecrj/iced.git"}

got a ton of errors, this is some of them: https://bpa.st/QU6Q I also did cargo update

Ploppz avatar Mar 09 '22 18:03 Ploppz

do you have resolver = "2" in your cargo.toml underneath package? Also try to avoid using Master atm till he gets the pure widgets done. However in this moment i see he asked you to try it so it might just be a resolver issue. also give cargo clean a try as sometimes cargo update does not always work correctly for some things.

genusistimelord avatar Mar 09 '22 18:03 genusistimelord

@genusistimelord I clone https://github.com/genusistimelord/iced.git result is same as before cargo run --features "iced/glow iced/glow_canvas" --package solar_system Finished dev [unoptimized + debuginfo] target(s) in 1.17s Running target/debug/solar_system Error: GraphicsAdapterNotFound

skydig avatar Mar 10 '22 13:03 skydig

can you do a lldb walk thru and start it at https://github.com/genusistimelord/iced/blob/ac3e477bb34fb804cdacc1b02023a6315b156e43/wgpu/src/window/compositor.rs#L35 and see what part it is failing on exactly?

genusistimelord avatar Mar 10 '22 14:03 genusistimelord

Oh oops, I forgot that I was just supposed to try to run the example anyway. But thanks your suggestion indeed worked. Anyway, when running the clock example on commit a53fa91e, I still get the same error :( Btw my GPU is XFX Radeon RX 6700 XT, @genusistimelord

Ploppz avatar Mar 10 '22 20:03 Ploppz

@Ploppz I sent you a email to your gmail. Also yeah id like to see if you have discord or telegram or something so i can directly help you so we can diagnose the issue faster that way it can get fixed.

genusistimelord avatar Mar 10 '22 21:03 genusistimelord