Skip to content

Commit 28e2028

Browse files
committed
use MiB instead of MB for gpu-memory
Signed-off-by: Natasha Romm <nromm@nvidia.com>
1 parent 4501db4 commit 28e2028

File tree

9 files changed

+40
-40
lines changed

9 files changed

+40
-40
lines changed

docs/gpu-feature-discovery/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ For a similar list of labels generated or used by the device plugin, see [here](
216216
| nvidia.com/gpu.count | Integer | Number of GPUs | 2 |
217217
| nvidia.com/gpu.family | String | Architecture family of the GPU | turing |
218218
| nvidia.com/gpu.machine | String | Machine type. If in a public cloud provider, value may be set to the instance type. | DGX-1 |
219-
| nvidia.com/gpu.memory | Integer | Memory of the GPU in megabytes (MB) | 15360 |
219+
| nvidia.com/gpu.memory | Integer | Memory of the GPU in mebibytes (MiB) | 15360 |
220220
| nvidia.com/gpu.product | String | Model of the GPU. May be modified by the device plugin if a sharing strategy is employed depending on the config. | Tesla-T4 |
221221
| nvidia.com/gpu.replicas | String | Number of GPU replicas available. Will be equal to the number of physical GPUs unless some sharing strategy is employed in which case the GPU count will be multiplied by replicas. | 4 |
222222
| nvidia.com/gpu.mode | String | Mode of the GPU. Can be either "compute" or "display". Details of the GPU modes can be found [here](https://docs.nvidia.com/grid/13.0/grid-gpumodeswitch-user-guide/index.html#compute-and-graphics-mode) | compute |

internal/lm/resource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func NewGPUResourceLabeler(config *spec.Config, device resource.Device, count in
4444
return nil, fmt.Errorf("failed to get device model: %v", err)
4545
}
4646

47-
totalMemoryMB, err := device.GetTotalMemoryMB()
47+
totalMemoryMiB, err := device.GetTotalMemoryMiB()
4848
if err != nil {
4949
return nil, fmt.Errorf("failed to get memory info for device: %v", err)
5050
}
@@ -57,8 +57,8 @@ func NewGPUResourceLabeler(config *spec.Config, device resource.Device, count in
5757
}
5858

5959
memoryLabeler := (Labeler)(&empty{})
60-
if totalMemoryMB != 0 {
61-
memoryLabeler = resourceLabeler.single("memory", totalMemoryMB)
60+
if totalMemoryMiB != 0 {
61+
memoryLabeler = resourceLabeler.single("memory", totalMemoryMiB)
6262
}
6363

6464
labelers := Merge(

internal/resource/cuda-device.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ func (d *cudaDevice) GetDeviceHandleFromMigDeviceHandle() (Device, error) {
5858
return nil, fmt.Errorf("GetDeviceHandleFromMigDeviceHandle is unsupported for CUDA devices")
5959
}
6060

61-
// GetTotalMemoryMB returns the total memory for a device
62-
func (d *cudaDevice) GetTotalMemoryMB() (uint64, error) {
61+
// GetTotalMemoryMiB returns the total memory for a device in mebibytes (2^20 bytes)
62+
func (d *cudaDevice) GetTotalMemoryMiB() (uint64, error) {
6363
total, r := cuda.Device(*d).TotalMem()
6464
if r != cuda.SUCCESS {
6565
return 0, fmt.Errorf("failed to get memory info for device: %v", r)

internal/resource/device_mock.go

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/resource/nvml-device.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ func (d nvmlDevice) GetName() (string, error) {
8181
return name, nil
8282
}
8383

84-
// GetTotalMemoryMB returns the total memory on a device in MB
85-
func (d nvmlDevice) GetTotalMemoryMB() (uint64, error) {
84+
// GetTotalMemoryMiB returns the total memory on a device in mebibytes (2^20 bytes)
85+
func (d nvmlDevice) GetTotalMemoryMiB() (uint64, error) {
8686
info, ret := d.Device.GetMemoryInfo()
8787
if ret != nvml.SUCCESS {
8888
return 0, ret

internal/resource/nvml-mig-device.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ func (d nvmlMigDevice) GetName() (string, error) {
104104
return resourceName, nil
105105
}
106106

107-
// GetTotalMemoryMB returns the total memory on a device in MB
108-
func (d nvmlMigDevice) GetTotalMemoryMB() (uint64, error) {
107+
// GetTotalMemoryMiB returns the total memory on a device in mebibytes (2^20 bytes)
108+
func (d nvmlMigDevice) GetTotalMemoryMiB() (uint64, error) {
109109
attr, err := d.GetAttributes()
110110
if err != nil {
111111
return 0, err

internal/resource/sysfs-device.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ func (d vfioDevice) GetName() (string, error) {
5151
return d.nvidiaPCIDevice.DeviceName, nil
5252
}
5353

54-
// GetTotalMemoryMB returns the total memory on a device in MB
55-
func (d vfioDevice) GetTotalMemoryMB() (uint64, error) {
54+
// GetTotalMemoryMiB returns the total memory on a device in mebibytes (2^20 bytes)
55+
func (d vfioDevice) GetTotalMemoryMiB() (uint64, error) {
5656
_, val := d.nvidiaPCIDevice.Resources.GetTotalAddressableMemory(true)
5757
return val, nil
5858
}

internal/resource/testing/resource-testing.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ func NewDeviceMock(migEnabled bool) *DeviceMock {
4747
}
4848
return 8, 0, nil
4949
},
50-
GetTotalMemoryMBFunc: func() (uint64, error) { return uint64(300), nil },
51-
IsFabricAttachedFunc: func() (bool, error) { return false, nil },
52-
IsMigEnabledFunc: func() (bool, error) { return migEnabled, nil },
53-
IsMigCapableFunc: func() (bool, error) { return migEnabled, nil },
54-
GetMigDevicesFunc: func() ([]resource.Device, error) { return nil, nil },
55-
GetPCIClassFunc: func() (uint32, error) { return 0, nil },
50+
GetTotalMemoryMiBFunc: func() (uint64, error) { return uint64(300), nil },
51+
IsFabricAttachedFunc: func() (bool, error) { return false, nil },
52+
IsMigEnabledFunc: func() (bool, error) { return migEnabled, nil },
53+
IsMigCapableFunc: func() (bool, error) { return migEnabled, nil },
54+
GetMigDevicesFunc: func() ([]resource.Device, error) { return nil, nil },
55+
GetPCIClassFunc: func() (uint32, error) { return 0, nil },
5656
}}
5757
return &d
5858
}

internal/resource/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type Device interface {
3737
GetMigDevices() ([]Device, error)
3838
GetAttributes() (map[string]interface{}, error)
3939
GetName() (string, error)
40-
GetTotalMemoryMB() (uint64, error)
40+
GetTotalMemoryMiB() (uint64, error)
4141
GetDeviceHandleFromMigDeviceHandle() (Device, error)
4242
GetCudaComputeCapability() (int, int, error)
4343
GetPCIClass() (uint32, error)

0 commit comments

Comments
 (0)