$ if command -v nvidia-smi &> /dev/null; then
echo "NVIDIA GPU detected:"
nvidia-smi
else
echo "No NVIDIA GPU found or nvidia-smi not installed."
fi
NVIDIA GPU detected:
Mon Jun 24 16:50:40 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.129.03 Driver Version: 535.129.03 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 Tesla T4 On | 00000000:06:00.0 Off | 0 |
| N/A 40C P8 15W / 70W | 2MiB / 15360MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| No running processes found |
+---------------------------------------------------------------------------------------+
$ if [ -d "/proc/driver/nvidia" ]; then
echo "NVIDIA GPU information from /proc:"
cat /proc/driver/nvidia/gpus/*/information
fi
NVIDIA GPU information from /proc:
Model: Unknown
IRQ: 22
GPU UUID: GPU-ef4a8793-5059-e52c-ecf3-9871aed7e09d
Video BIOS: 90.04.38.00.03
Bus Type: PCIe
DMA Size: 47 bits
DMA Mask: 0x7fffffffffff
Bus Location: 0000:06:00.0
Device Minor: 0
GPU Firmware: 535.129.03
GPU Excluded: No