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

DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau. #6269

Open
laycookie opened this issue Sep 14, 2024 · 2 comments
Open

DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau. #6269

laycookie opened this issue Sep 14, 2024 · 2 comments
Labels
external: driver-bug A driver is causing the bug, though we may still want to work around it platform: wayland Issues with integration with linux/wayland

Comments

@laycookie
Copy link

Description
Creating an adapter from an instance causes DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau. warning in the console.

Repro steps
I have a gtx 1080, and I'm running this on Hyprland under NixOS.

fn main() {
    let instance = wgpu::Instance::default();
    let adapter = instance
        .request_adapter(&wgpu::RequestAdapterOptions::default())
        .await
        .unwrap();
}

Platform
NixOS 24.05.20240827.36bae45 (Uakari) x86_64

@Wumpf
Copy link
Member

Wumpf commented Sep 14, 2024

That seems to be an issue specifically about your system. Do you also get this with other applications using Vulkan and does this cause any other issues down the line.

I'm not familiar with NixOS at all, but googling that error I find various threads and issues on other projects where people discuss this problem. According to this you can either ignore the warning or silence it by setting an env var logseq/logseq#11396 (comment) (which I figure will force it to pick the right driver files from the start). Does this help?

I doubt that there's anything wgpu can do to mitigate this, but if there is I'm all ears!

@Wumpf Wumpf added external: driver-bug A driver is causing the bug, though we may still want to work around it platform: wayland Issues with integration with linux/wayland labels Sep 14, 2024
@laycookie
Copy link
Author

Thanks for linking logseq/logseq#11396 (comment) I have seen, and tried it before, but it didn't work. Decided to test it out again, and apparently I had start up the app the second time for the warning to disappear for what ever reason.

This warning does occur in some other apps notable one is steam, which also refuses to open when the warning occurs. However in some other apps that use Vulkan this error does not appear so I felt like this was an enough reason to at least just open this issue on this topic.

Unlike steam, wgpu applications does work, however I observed it to have an abnormal memory consumption. When the warning is present btop reports that the application consumes a little over 100Mb of RAM, mean while without the warning, it consumes only around 68Mb. For reference on windows this code consumed 71.5 mb.

The code used for testing:

use wgpu::Backends;
use winit::{
    application::ApplicationHandler,
    event::WindowEvent,
    event_loop::{ActiveEventLoop, EventLoop},
    window::{Window, WindowId},
};

struct App<'a> {
    instance: wgpu::Instance,
    adapter: wgpu::Adapter,
    device: wgpu::Device,
    queue: wgpu::Queue,
    surface: Option<wgpu::Surface<'a>>,
}

impl<'a> ApplicationHandler for App<'a> {
    fn resumed(&mut self, event_loop: &ActiveEventLoop) {
        let window = event_loop
            .create_window(Window::default_attributes())
            .unwrap();

        let surface = self.instance.create_surface(window).unwrap();
        let config = surface.get_default_config(&self.adapter, 500, 500).unwrap();
        surface.configure(&self.device, &config);

        self.surface = Some(surface);
    }

    fn window_event(&mut self, event_loop: &ActiveEventLoop, id: WindowId, event: WindowEvent) {
        match event {
            WindowEvent::CloseRequested => {
                println!("The close button was pressed; stopping");
                event_loop.exit();
            }
            WindowEvent::RedrawRequested => {
                if let Some(s) = &self.surface {
                    let frame = s.get_current_texture().unwrap();
                    let view = frame
                        .texture
                        .create_view(&wgpu::TextureViewDescriptor::default());
                    let mut encoder = self
                        .device
                        .create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });

                    {
                        let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
                            label: None,
                            color_attachments: &[Some(wgpu::RenderPassColorAttachment {
                                view: &view,
                                resolve_target: None,
                                ops: wgpu::Operations {
                                    load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
                                    store: wgpu::StoreOp::Store,
                                },
                            })],
                            depth_stencil_attachment: None,
                            timestamp_writes: None,
                            occlusion_query_set: None,
                        });
                        // rpass.draw(0..3, 0..1);
                    }

                    println!("{:#?}", frame.texture.format());

                    self.queue.submit(Some(encoder.finish()));
                    frame.present();
                }
                println!("redraw");
                // self.window.as_ref().unwrap().request_redraw();
            }
            _ => (),
        }
    }
}

#[tokio::main]
async fn main() {
    let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
        backends: Backends::VULKAN,
        ..wgpu::InstanceDescriptor::default()
    });
    let adapter = instance
        .request_adapter(&wgpu::RequestAdapterOptions::default())
        .await
        .unwrap();
    println!("{:#?}", adapter.get_info());

    let (device, queue) = adapter
        .request_device(
            &wgpu::DeviceDescriptor {
                label: None,
                required_features: wgpu::Features::empty(),
                // Make sure we use the texture resolution limits from the adapter, so we can support images the size of the swapchain.
                required_limits: wgpu::Limits::downlevel_webgl2_defaults()
                    .using_resolution(adapter.limits()),
                memory_hints: wgpu::MemoryHints::MemoryUsage,
            },
            None,
        )
        .await
        .expect("Failed to create device");
    // Create an event loop
    let event_loop = EventLoop::new().unwrap();
    // Create a window
    let mut app = App {
        instance,
        adapter,
        device,
        queue,
        surface: None,
    };
    event_loop.run_app(&mut app).unwrap();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external: driver-bug A driver is causing the bug, though we may still want to work around it platform: wayland Issues with integration with linux/wayland
Projects
Status: Todo
Development

No branches or pull requests

2 participants