# Control your GPU on Linux
# 1. NVIDIA
## 1. Install drivers
## 2. Configuration
### 2.1 Generate config File: /etc/X11/xorg.conf
```bash
sudo nvidia-xconfig
```
## 2.2 Installation [GWE](https://gitlab.com/leinardi/gwe)
```bash
sudo apt install python3-pip python3-dev python3-cairo-dev build-essential cmake gcc meson ninja-build libgirepository1.0-dev gir1.2-appindicator3-0.1 libdazzle-1.0-dev gnome-shell-extension-appindicator appstream-util libxml2-utils
```
Build from source
```bash
mkdir Projects
cd Projects
git clone --recurse-submodules -j4 https://gitlab.com/leinardi/gwe.git
cd gwe
git checkout master
sudo -H pip3 install python3-cairo-dev PyGObject
sudo -H pip3 install -r requirements.txt
meson . build --prefix /usr
ninja -v -C build
sudo ninja -v -C build install
```
### 3. Change configuration file
```bash
sudo gedit /etc/X11/xorg.conf
```

Structure:
```bash
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BusID "PCI:1:0:0"
BoardName "NAME OF YOUR CARD"
Option "Coolbits" "8" # bits FERMI+
EndSection
```
Change to(Example of my case):
```bash
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BusID "PCI:1:0:0"
BoardName "NVIDIA RTX 6000 Ada Generation"
Option "Coolbits" "8"
EndSection
```
#### Coolbits it's the most important parameter.
```bash
The Coolbits value is the sum of its component bits in the binary numeral system. The component bits are:
1 (bit 0) - Enables overclocking of older (pre-Fermi) cores on the Clock Frequencies page in nvidia-settings.
2 (bit 1) - When this bit is set, the driver will "attempt to initialize SLI when using GPUs with different amounts of video memory".
4 (bit 2) - Enables manual configuration of GPU fan speed on the Thermal Monitor page in nvidia-settings.
8 (bit 3) - Enables overclocking on the PowerMizer page in nvidia-settings. Available since version 337.12 for the Fermi architecture and newer.[4]
16 (bit 4) - Enables overvoltage using nvidia-settings CLI options. Available since version 346.16 for the Fermi architecture and newer.[5]
To enable multiple features, add the Coolbits values together. For example, to enable overclocking and overvoltage of Fermi cores, set Option "Coolbits" "24".
```

### 4. If you want by CLI
Structure PowerLimit: nvidia-smi -i CARD_NUMBER -PL (W power limit)
```
sudo nvidia-smi -i 0 -pl 250
```
Structure GPU & Memory offset:
```bash
nvidia-settings -a [gpu:0]/GPUGraphicsClockOffset[3]=50
nvidia-settings -a [gpu:0]/GPUMemoryTransferRateOffset[3]=500
```
# 2. AMD
```bash
sudo add-apt-repository ppa:ernstp/mesarc
sudo apt-get update
sudo apt install corectrl
```

# LACT
https://github.com/ilya-zlobintsev/LACT
```bash
sudo systemctl enable --now lactd
```
```bash
sudo dpkg -i *.deb
```
# Monitoring GPU
```bash
sudo apt-get install nvtop
pip3 install nvitop # ONLY NVIDIA
```
```bash
git clone --recursive https://github.com/aristocratos/btop.git
cd btop
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH="/opt/rocm" -DCMAKE_INSTALL_PREFIX="/usr/local" -DBUILD_SHARED_LIBS=ON -DBTOP_GPU=true
make -j$(nproc)
sudo make install
```
## AMD
```bash
wget https://github.com/Umio-Yasuno/amdgpu_top/releases/download/v0.11.3/amdgpu-top_0.11.3-1_amd64.deb
sudo dpkg -i amdgpu-top_0.11.3-1_amd64.deb
```