Skip to content

Commit

Permalink
fix(bidengine): parse GPU interface
Browse files Browse the repository at this point in the history
- Update parseGPU function to handle 'interface' attribute for GPUs

fixes akash-network/support#216
  • Loading branch information
andy108369 committed Apr 24, 2024
1 parent c96d15b commit 6a6e706
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bidengine/pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,9 @@ type storageElement struct {
}

type gpuVendorAttributes struct {
Model string `json:"model"`
RAM *string `json:"ram,omitempty"`
Model string `json:"model"`
RAM *string `json:"ram,omitempty"`
GPUInterface *string `json:"interface,omitempty"`
}

type gpuAttributes struct {
Expand Down
17 changes: 17 additions & 0 deletions bidengine/shellscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,33 @@ func parseGPU(resource *atypes.GPU) gpuElement {
vendor := tokens[1]
model := tokens[3]
var ram *string
var gpuInterface *string

// vendor/nvidia/model/a100/ram/80Gi
if len(tokens) == 6 && tokens[4] == "ram" {
ram = new(string)
*ram = tokens[5]
}

// vendor/nvidia/model/a100/interface/pcie
if len(tokens) == 6 && tokens[4] == "interface" {
gpuInterface = new(string)
*gpuInterface = tokens[5]
}

// When both ram & interface tokens are set:
// vendor/nvidia/model/t4/ram/16Gi/interface/pcie
if len(tokens) == 8 && tokens[4] == "ram" && tokens[6] == "interface" {
ram = new(string)
gpuInterface = new(string)
*ram = tokens[5]
*gpuInterface = tokens[7]
}

res.Attributes.Vendor[vendor] = gpuVendorAttributes{
Model: model,
RAM: ram,
GPUInterface: gpuInterface,
}
default:
}
Expand Down

0 comments on commit 6a6e706

Please sign in to comment.