Giter Site home page Giter Site logo

xulongwu4 / nvidia-optimus-manager Goto Github PK

View Code? Open in Web Editor NEW
22.0 3.0 8.0 13 KB

A python script to manage the status of NVIDIA graphics card on an Optimus setup for Solus linux

License: MIT License

Python 100.00%
optimus nvidia nvidia-graphics-card solus driver intel

nvidia-optimus-manager's Introduction

Introduction

This repository has a set of tools to manage the status of the NVIDIA graphics card on an Optimus™ setup. It now supports Solus with Budgie desktop.

Three profiles are implemented in the nvidia-optimus-manager script:

  • intel: The Intel integrated GPU is used for display rendering and the dGPU is suspended by runtime power management. Running the nvidia-smi command gives
$ nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
  • hybrid: The Intel iGPU is used for display rendering while the dGPU is still on and its driver is loaded for other tasks (e.g., deep learning, etc.). In this configuration, the nvidia-smi command produces the following output:
$ nvidia-smi
Sun Dec  2 16:22:40 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 410.78       Driver Version: 410.78       CUDA Version: 10.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 106...  On   | 00000000:01:00.0 Off |                  N/A |
| N/A   43C    P0    23W /  N/A |      0MiB /  6078MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
  • nvidia: The dGPU will be used as the sole source of rendering. Running the nvidia-smi command produces
$ nvidia-smi
Sun Dec  2 16:25:42 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 410.78       Driver Version: 410.78       CUDA Version: 10.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 106...  On   | 00000000:01:00.0 Off |                  N/A |
| N/A   48C    P0    23W /  N/A |    207MiB /  6078MiB |      6%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      8485      G   /usr/lib64/xorg-server/Xorg                  137MiB |
|    0      8726      G   budgie-wm                                     44MiB |
|    0      8995      G   ...-token=F8BB065232F55048CF73ECAC02D5EDA6     5MiB |
|    0      9092      G   ...-token=AEC61D9914CB773E37DFD8EFFFFEB6DB     7MiB |
|    0      9126      G   ...-token=215073FE33E4C44F4B99DE67F9B5AA88     9MiB |
+-----------------------------------------------------------------------------+

Things to do before installation

  • Install the NVIDIA proprietary graphics driver
  • Blacklist the nouveau driver:

If you installed the NVIDIA proprietary driver from the Solus repo, this is automatically taken care of.

$ sudo mkdir -p /etc/modprobe.d
$ echo "blacklist nouveau" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
  • Install pciutils by sudo eopkg it pciutils

Reboot to let these changes take effect.

Installation

  • 99-nvidia.conf: copy to /etc/lightdm/lightdm.conf.d/99-nvidia.conf
  • nvidia-optimus-autoconfig.service: copy to /etc/systemd/system/nvidia-optimus-autoconfig.service
  • nvidia-optimus-manager: copy to /usr/bin/nvidia-optimus-manager

Then enable the service file at boot:

sudo systemctl daemon-reload
sudo systemctl enable nvidia-optimus-autoconfig

Dependencies

  • Linux-driver-management
  • NVIDIA proprietary graphics driver
  • pciutils: for the lspci command to find the pci bus id for the NVIDIA graphics card.

Usage

Three subcommands can be used with the nvidia-optimus-manager script:

  • Check the current configuration of the dGPU with the status subcommand:
$ nvidia-optimus-manager status
Current profile: intel
OpenGL vendor: Intel
Discrete graphics card power status: suspended
  • Switch profile with the configure subcommand (requires root previleges):
$ nvidia-optimus-manager configure intel
Info: selecting the intel profile

If the graphic card for the display rendering is changed during the switch of profile (e.g. intel -> nvidia, or nvidia -> hybrid), the user needs to log out before the switch can take effect:

$ nvidia-optimus-manager configure nvidia
Info: selecting the nvidia profile
Log out to take effect

Otherwise the switch happens immediately.

  • autoconfigure subcommand: Automatically configure the dGPU based on the presence of relevant configuration files (blacklist-nvidia.conf, 00-ldm.conf). This command is used in the systemd service file (nvidia-optimus-autoconfig.service) and the lightdm configuration file (99-nvidia.conf)

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.