intel-device-plugins-for-ku.../cmd/gpu_nfdhook/main.go
Ukri Niemimuukko 5b5180ae00 gpu_nfdhook memory amount reading from sysfs
This adds reading of the GPU memory amount from the sysfs. As a
fallback the environment variable GPU_MEMORY_OVERRIDE remains.

Another environment variable GPU_MEMORY_RESERVED can be used to
reserve a dedicated byte amount outside of kubernetes usage.

Signed-off-by: Ukri Niemimuukko <ukri.niemimuukko@intel.com>
2020-10-26 09:45:43 +02:00

41 lines
1.1 KiB
Go

// Copyright 2020 Intel Corporation. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"os"
"k8s.io/klog"
)
const (
sysfsDirectory = "/host-sys"
devfsDirectory = "/host-dev"
sysfsDRMDirectory = sysfsDirectory + "/class/drm"
devfsDRIDirectory = devfsDirectory + "/dri"
debugfsDRIDirectory = sysfsDirectory + "/kernel/debug/dri"
)
func main() {
l := newLabeler(sysfsDRMDirectory, devfsDRIDirectory, debugfsDRIDirectory)
err := l.createLabels()
if err != nil {
klog.Errorf("%+v", err)
os.Exit(1)
}
l.printLabels()
}