Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU: detect GPU index #1267

Merged
merged 1 commit into from
Sep 19, 2024
Merged

GPU: detect GPU index #1267

merged 1 commit into from
Sep 19, 2024

Conversation

aiwantaozi
Copy link
Contributor

Hi, we have forked your project and made some modifications as gpustack needed. We noticed that your project already supports most of the features we require. We would love to switch back to using the upstream fastfetch, so that we can contribute directly to the project with any future issues or improvements.

In cases where a machine has multiple discrete GPUs from the same vendor and brand, the GPU names are often identical. GPU vendors provide a GPU index to help users quickly identify each GPU like below. Would it be possible for fastfetch to support retrieving this vendor-provided GPU index during detection, allowing users to easily match the detected GPUs with their respective indices?

image

Output of Json for this PR
(used configc.json to simplify the output)

[
  {
    "type": "OS",
    "result": {
      "buildID": "",
      "codename": "",
      "id": "Windows 11",
      "idLike": "Windows",
      "name": "Windows",
      "prettyName": "Windows",
      "variant": "Pro",
      "variantID": "",
      "version": "11",
      "versionID": ""
    }
  },
  {
    "type": "Kernel",
    "result": {
      "architecture": "x86_64",
      "name": "WIN32_NT",
      "release": "10.0.22631.4037",
      "version": "22621.1.amd64fre.ni_release.220506-1250",
      "displayVersion": "23H2",
      "pageSize": 4096
    }
  },
  {
    "type": "GPU",
    "result": [
      {
        "index": 1,
        "coreCount": 10240,
        "coreUsage": 0.0,
        "memory": {
          "dedicated": {
            "total": 16826499072,
            "used": 64249856
          },
          "shared": {
            "total": 34204884992,
            "used": null
          }
        },
        "driver": "31.0.15.5178",
        "name": "NVIDIA GeForce RTX 4080 SUPER",
        "temperature": 32.0,
        "type": "Discrete",
        "vendor": "NVIDIA",
        "platformApi": "Direct3D 12.2",
        "frequency": 3105,
        "deviceId": 73365
      },
      {
        "index": 0,
        "coreCount": 10240,
        "coreUsage": 0.0,
        "memory": {
          "dedicated": {
            "total": 16826499072,
            "used": 0
          },
          "shared": {
            "total": 34204884992,
            "used": null
          }
        },
        "driver": "31.0.15.5178",
        "name": "NVIDIA GeForce RTX 4080 SUPER",
        "temperature": 34.0,
        "type": "Discrete",
        "vendor": "NVIDIA",
        "platformApi": "Direct3D 12.2",
        "frequency": 3105,
        "deviceId": 68246
      },
      {
        "index": null,
        "coreCount": 32,
        "coreUsage": null,
        "memory": {
          "dedicated": {
            "total": 134217728,
            "used": null
          },
          "shared": {
            "total": 34204884992,
            "used": null
          }
        },
        "driver": "31.0.101.5537",
        "name": "Intel(R) UHD Graphics 770",
        "temperature": null,
        "type": "Integrated",
        "vendor": "Intel",
        "platformApi": "Direct3D 12.1",
        "frequency": 1550,
        "deviceId": 72580
      }
    ]
  }
]

@CarterLi
Copy link
Member

CarterLi commented Sep 18, 2024

You should use deviceId.

  • On *nix, it's a unique, vendor independent PCI device identifier that only changes when you change the PCIe slot of your GPU.
  • On Windows, it's AdapterLuid

@CarterLi
Copy link
Member

Please also don't change src/3rdparty/yyjson/yyjson.h before you make it in the official repo of yyjson.

@aiwantaozi
Copy link
Contributor Author

You should use deviceId.

  • On *nix, it's a unique, vendor independent PCI device identifier that only changes when you change the PCIe slot of your GPU.
  • On Windows, it's AdapterLuid

Thanks for explaining. Many applications use the GPU index to locate the GPU in use. For example, in ray's documentation, you can see that a variety of GPUs use the index to set the GPU visible to the application. If fastfetch can detect the GPU index, it will be very easy to integrate with these applications.

@CarterLi CarterLi merged commit 9332f42 into fastfetch-cli:dev Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants