Giter Club home page Giter Club logo

nv-switch's Introduction

nv-switch

Small program for switching the drivers of the second GPU, in a VFIO setup, between nvidia and vfio .

This is convenient for keeping the GPU usable (and power-managed) when not running a guest.

The program works but I've discontinued, as, after many years of VFIO, I've moved back to a dual boot solution (VFIO always need hacks, in one way or another).

nv-switch's People

Contributors

64kramsystem avatar

Stargazers

 avatar

Watchers

 avatar  avatar

nv-switch's Issues

Make configurable (include config generator)

This should have two part:

  • the configuration loading, which always happen (remove constants)
  • a configuration creator, to run when the system runs with regular (non vfio) drivers, that creates the configuration file bases on the current driver
    • check if possible to find out the default driver for a device, which avoids the necessity to run with regular drivers
      • this would make possible to only specify the main device, and discover the others via IOMMU group

Add `install` command

It should create and enable the Systemd unit.

  • Check if 10 seconds are really necessary; probably 5 are more than enough (find minimum, and compute a comfortable amount)

Figure out the guest gpu device from /dev/dri/by-path

The guest gpu device can be figured out, so that it avoids having to pass two arguments.

This doesn't actually have any pointer to the device immediately under /dev, but a (exact) heuristic can be used for that (see below).

Notes:

$ ls -l /dev/dri/by-path
lrwxrwxrwx 1 root root  8 Aug 30 18:06 pci-0000:04:00.0-card -> ../card0
lrwxrwxrwx 1 root root 13 Aug 30 18:06 pci-0000:04:00.0-render -> ../renderD128
lrwxrwxrwx 1 root root  8 Aug 30 18:06 pci-0000:2d:00.0-card -> ../card1
lrwxrwxrwx 1 root root 13 Aug 30 18:06 pci-0000:2d:00.0-render -> ../renderD129

$ sudo lsof /dev/dri/card0
$ sudo lsof /dev/dri/renderD128
COMMAND   PID    USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
Xorg     3444    root   22u   CHR 226,128      0t0  348 /dev/dri/renderD128
Xorg     3444    root   37u   CHR 226,128      0t0  348 /dev/dri/renderD128
code    14353 saverio   23u   CHR 226,128      0t0  348 /dev/dri/renderD128
code    14361 saverio   23u   CHR 226,128      0t0  348 /dev/dri/renderD128

$ sudo lsof /dev/nvidia0
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
Xorg    3444 root  mem    CHR  195,0           648 /dev/nvidia0
Xorg    3444 root   17u   CHR  195,0      0t0  648 /dev/nvidia0
Xorg    3444 root   18u   CHR  195,0      0t0  648 /dev/nvidia0
Xorg    3444 root   19u   CHR  195,0      0t0  648 /dev/nvidia0
Xorg    3444 root   24u   CHR  195,0      0t0  648 /dev/nvidia0
Xorg    3444 root   25u   CHR  195,0      0t0  648 /dev/nvidia0
Xorg    3444 root   28u   CHR  195,0      0t0  648 /dev/nvidia0
Xorg    3444 root   29u   CHR  195,0      0t0  648 /dev/nvidia0
Xorg    3444 root   30u   CHR  195,0      0t0  648 /dev/nvidia0
Xorg    3444 root   34u   CHR  195,0      0t0  648 /dev/nvidia0
Xorg    3444 root   35u   CHR  195,0      0t0  648 /dev/nvidia0
$ sudo lsof /dev/dri/card1
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
Xorg    3444 root  mem    CHR  226,1           503 /dev/dri/card1
Xorg    3444 root   14u   CHR  226,1      0t0  503 /dev/dri/card1
Xorg    3444 root   15u   CHR  226,1      0t0  503 /dev/dri/card1
$ sudo lsof /dev/dri/renderD129

Heuristic: If the card is '/dev/dri/card1' and '/dev/nvidia1' exists, then it's it; in any other case, it's '/dev/nvidia0'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.