Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running example on WSL: Error: GraphicsAdapterNotFound #1232

Open
2 tasks done
Ploppz opened this issue Feb 6, 2022 · 31 comments
Open
2 tasks done

Running example on WSL: Error: GraphicsAdapterNotFound #1232

Ploppz opened this issue Feb 6, 2022 · 31 comments
Labels

Comments

@Ploppz
Copy link

Ploppz commented Feb 6, 2022

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • 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 Ploppz added the bug Something isn't working label Feb 6, 2022
@hecrj
Copy link
Member

hecrj commented Feb 6, 2022

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?

antialiasing: true,

@hecrj hecrj added rendering wgpu compatibility bug Something isn't working and removed bug Something isn't working labels Feb 6, 2022
@Ploppz
Copy link
Author

Ploppz commented Feb 6, 2022

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

With antialiasing: false it's the same.

@hecrj
Copy link
Member

hecrj commented Feb 7, 2022

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!

@Ploppz
Copy link
Author

Ploppz commented Feb 11, 2022

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.

@genusistimelord
Copy link

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

@Ploppz
Copy link
Author

Ploppz commented Feb 12, 2022

v2.
CPU virtualization is enabled.

@hecrj
Copy link
Member

hecrj commented Feb 12, 2022

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?

@genusistimelord
Copy link

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: gfx-rs/wgpu#1443

@Ploppz
Copy link
Author

Ploppz commented Feb 13, 2022

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: gfx-rs/wgpu#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.

@genusistimelord
Copy link

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.

@skydig
Copy link

skydig commented Feb 19, 2022

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

@genusistimelord
Copy link

genusistimelord commented Feb 20, 2022

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.

@Ploppz
Copy link
Author

Ploppz commented Feb 20, 2022

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.

@genusistimelord
Copy link

genusistimelord commented Feb 21, 2022

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.

let adapter = instance

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 . 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.

@hecrj
Copy link
Member

hecrj commented Mar 7, 2022

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

@genusistimelord
Copy link

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.

@skydig
Copy link

skydig commented Mar 8, 2022

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

@genusistimelord
Copy link

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.

@skydig
Copy link

skydig commented Mar 8, 2022

@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

@genusistimelord
Copy link

genusistimelord commented Mar 8, 2022

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.

wgpu::PowerPreference::LowPower

@skydig
Copy link

skydig commented Mar 9, 2022

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
Copy link

skydig commented Mar 9, 2022

@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
|

@genusistimelord
Copy link

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
Copy link

genusistimelord commented Mar 9, 2022

@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

@Ploppz
Copy link
Author

Ploppz commented Mar 9, 2022

@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

@genusistimelord
Copy link

genusistimelord commented Mar 9, 2022

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.

@skydig
Copy link

skydig commented Mar 10, 2022

@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

@genusistimelord
Copy link

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?

@Ploppz
Copy link
Author

Ploppz commented Mar 10, 2022

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

@genusistimelord
Copy link

@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
Copy link

So yeah After running a few tests with Ploppz I have verified that the issue indeed does stem from WGPU itself and in fact that it does not properly handle Software based wrappers that link back to the main OS for GPU usage. This causes the Limits to not be truthful for the GPU and causes it to not render correctly as well. This is due to it seeing the GPU as an internal or low powered GPU before it see's it as a software based GPU. As in things like WSL it can still See the GPU just cant get Direct Access to the GPU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants