wgpu: Cannot access dedicated graphics with wgpu from a docker container.
Description:
Calling request_adapter
within a docker container always returns None
, even though nvidia-smi
works correctly within the container. This issue only appears in machines with dedicated discrete GPUs (e.g. desktop with discrete GTX 1070) and not with integrated graphics cards (e.g. GTX 1050 in a laptop).
Repro steps:
Setup docker container with access to discrete GPU and call request_adapter
from somewhere within.
Expected vs observed behavior:
An adapter should be returned by request_adapter
instead of None
.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 29 (10 by maintainers)
Looks like this was resolved so I don’t think there’s anything left to do here from the wgpu side. As mentioned, Docker needs to use a compatible GPU adapter or CPU adapter as a fallback. Closing this for now
I think you’re right, just realized it’s actually not using the dedicated GPU right now.
When requesting an adapter like so:
We are getting the CPU adapter:
So I think this is probably not a wgpu issue, and just an issue with docker accessing the gpu.
@kvark I had not realised how old our version was. We are using 0.6.0 where 0.11.1 is available. I’m just porting our code and will report back here.
Yeah, this looks like a broken Vulkan setup. It was able to create an instance but not do anything useful with it.
Great that you figured it out! Seems to be a separate issue from the subject though? Anyway, we are detecting and returning a proper error when the feature isn’t enabled, and feature requirements are documented right on unclipped_depth.
You are absolutely right @kvark , I wasn’t comparing the same branch, but I get the same result on the
v0.12
branch.So maybe you are comparing hello-compute from wgpu master versus your program on wgpu-0.12? Could you try running hello-compute from https://github.com/gfx-rs/wgpu/tree/v0.12 instead?
I don’t think wgpu requires the X server at any level. Obviously, if you are creating
wgpu::Surface
, it needs to be presented somewhere. Try running thehello-compute
example without the X server, it should be unaffected.However we’ve realized that the issue is tied to docker Xserver access, since running
xhost +local:docker
on the host machine solves our problems and vulkaninfo, vkcube and wgpu-info work correctly in that case.