[v0.21] Print GPU list even when no valid GPU is detected, to improve user understanding
This commit is contained in:
@@ -75,7 +75,8 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
if(get_num_gpus_available(list) == 0) {
|
||||
printErr("No GPU was detected, or the detected GPU is not supported by gpufetch");
|
||||
printErr("No GPU was detected! Available GPUs are:");
|
||||
print_gpus_list_pci();
|
||||
printf("Please, make sure that the appropiate backend is enabled:\n");
|
||||
print_enabled_backends();
|
||||
printf("Visit https://github.com/Dr-Noob/gpufetch#2-backends for more information\n");
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
#include "global.hpp"
|
||||
#include "pci.hpp"
|
||||
#include "../cuda/pci.hpp"
|
||||
#include "../intel/pci.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstddef>
|
||||
|
||||
// TODO: Move AMD PCI id when possible
|
||||
#define PCI_VENDOR_ID_AMD 0x1002
|
||||
#define CLASS_VGA_CONTROLLER 0x0300
|
||||
|
||||
bool pciutils_is_vendor_id_present(struct pci_dev *devices, int id) {
|
||||
@@ -71,3 +77,24 @@ struct pci_dev *get_pci_devices_from_pciutils() {
|
||||
|
||||
return pacc->devices;
|
||||
}
|
||||
|
||||
void print_gpus_list_pci() {
|
||||
int i=0;
|
||||
struct pci_dev *devices = get_pci_devices_from_pciutils();
|
||||
|
||||
for(struct pci_dev *dev=devices; dev != NULL; dev=dev->next) {
|
||||
if(dev->device_class == CLASS_VGA_CONTROLLER) {
|
||||
printf("- GPU %d: ", i);
|
||||
if(dev->vendor_id == PCI_VENDOR_ID_NVIDIA) {
|
||||
printf("NVIDIA ");
|
||||
}
|
||||
else if(dev->vendor_id == PCI_VENDOR_ID_INTEL) {
|
||||
printf("Intel ");
|
||||
}
|
||||
else if(dev->vendor_id == PCI_VENDOR_ID_AMD) {
|
||||
printf("AMD ");
|
||||
}
|
||||
printf("%.4x:%.4x\n", dev->vendor_id, dev->device_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,6 @@ struct pci {
|
||||
|
||||
struct pci* get_pci_from_pciutils(struct pci_dev *devices, int id);
|
||||
struct pci_dev *get_pci_devices_from_pciutils();
|
||||
void print_gpus_list_pci();
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user