Last active
July 8, 2023 12:12
-
-
Save PrithivirajDamodaran/c7d95560f185fc4a75af6a4496eca258 to your computer and use it in GitHub Desktop.
Get NVIDIA Device Driver details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run the below if you get no file or command lspci | |
# !sudo apt-get install pciutils | |
import subprocess | |
def get_gpu_driver_info(): | |
# Find the GPU's chip name | |
lspci_output = subprocess.check_output(["lspci", "-nn"]).decode() | |
gpu_info_line = next((line for line in lspci_output.split('\n') if '3D controller' in line and 'NVIDIA' in line), None) | |
print(f"GPU Information: {gpu_info_line}") | |
if gpu_info_line: | |
# Extract the PCI slot number from the GPU info line | |
pci_slot = gpu_info_line.split()[0] | |
# Find which driver is in use | |
lspci_k_output = subprocess.check_output(["lspci", "-k", "-s", pci_slot]).decode() | |
print(f"Driver Information: {lspci_k_output}") | |
# List all loaded kernel modules | |
lsmod_output = subprocess.check_output(["lsmod"]).decode() | |
print(f"Loaded Kernel Modules: {lsmod_output}") | |
else: | |
print("No NVIDIA GPU found") | |
get_gpu_driver_info() | |
""" | |
You should see something like this | |
GPU Information: 00:04.0 3D controller [0302]: NVIDIA Corporation Device [10de:20b0] (rev a1) | |
Driver Information: 00:04.0 3D controller: NVIDIA Corporation Device 20b0 (rev a1) | |
Subsystem: NVIDIA Corporation Device 134f | |
Kernel driver in use: nvidia | |
Loaded Kernel Modules: Module Size Used by | |
veth 32768 0 | |
xt_nat 16384 8 | |
nvidia_drm 16384 0 | |
nvidia_uvm 1216512 0 | |
nvidia 56258560 16 nvidia_uvm | |
nls_iso8859_1 16384 0 | |
nls_cp437 20480 0 | |
vfat 24576 0 | |
fat 77824 1 vfat | |
cls_u32 24576 2 | |
sch_htb 32768 1 | |
xt_MASQUERADE 16384 1 | |
xt_addrtype 16384 2 | |
iptable_nat 16384 2 | |
nf_nat 40960 3 xt_nat,iptable_nat,xt_MASQUERADE | |
br_netfilter 24576 0 | |
xt_state 16384 0 | |
aesni_intel 385024 0 | |
crypto_simd 16384 1 aesni_intel | |
cryptd 24576 1 crypto_simd | |
loadpin_trigger 12288 0 | |
fuse 147456 1 | |
configfs 40960 1 | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment