NAME
Rex::GPU::Detect - GPU hardware detection via PCI class codes
VERSION
version 0.001
SYNOPSIS
use Rex::GPU::Detect;
my $gpus = detect();
if (@{ $gpus->{nvidia} }) {
for my $gpu (@{ $gpus->{nvidia} }) {
printf "NVIDIA %s (class %s, compute: %s)\n",
$gpu->{name}, $gpu->{pci_class}, $gpu->{compute} ? 'yes' : 'no';
}
}
DESCRIPTION
Rex::GPU::Detect detects GPU hardware on a remote host by parsing lspci -nn output and matching PCI vendor and class codes.
Detection approach
PCI class codes 0300 (VGA compatible controller) and 0302 (3D controller) identify display/GPU hardware. The module filters lspci -nn output for these class codes, then classifies devices by vendor ID:
10de— NVIDIA1002— AMD / ATI
Virtual GPU filtering
Devices with vendor IDs 1af4 (virtio), 1b36 (QEMU), 15ad (VMware), or 80ee (VirtualBox) are detected and silently skipped. No driver installation is needed on virtual machines.
NVIDIA compute classification
NVIDIA GPUs are further classified as compute-capable. Only compute-capable GPUs trigger driver installation in Rex::GPU. The classification rules:
PCI class
0302(3D controller) — always compute/datacenter. Datacenter GPUs such as the A100, H100, and RTX 4000 Ada typically enumerate as class0302.Named product families: RTX, TITAN, Quadro, Tesla, GTX 10xx/16xx series
Non-compute: NVS, GT/GTS low-end, GTX 2xx–9xx legacy, MX-series mobile
Unrecognised NVIDIA GPU models default to compute => 0 and emit a warning. AMD GPU compute is always 0; AMD driver support is not yet implemented.
FUNCTIONS
detect
Detect GPU hardware on the remote host. Ensures pciutils is installed, then parses lspci -nn output filtered to PCI display-class devices (class codes 03xx).
Returns a hashref with nvidia and amd array refs. Each element is a hashref describing one detected GPU:
{
nvidia => [
{
name => "NVIDIA RTX 4000 SFF Ada Generation",
vendor => "nvidia",
pci_class => "0302", # "0300" = VGA controller, "0302" = 3D controller
compute => 1, # 1 if CUDA-capable, 0 otherwise
}
],
amd => [
{
name => "Navi 31 [Radeon RX 7900 XTX]",
vendor => "amd",
pci_class => "0300",
compute => 0, # AMD compute support not yet implemented
}
],
}
If no supported GPU is found, or if a virtual GPU is detected, both arrays are empty ([]).
SEE ALSO
Rex::GPU, Rex::GPU::NVIDIA, https://pci-ids.ucw.cz/ (PCI ID database)
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/rex-gpu/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <getty@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.