-
Notifications
You must be signed in to change notification settings - Fork 59
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
Support for allocating GPUs in Passthrough-Mode #183
base: main
Are you sure you want to change the base?
Changes from all commits
d64afb1
2559d02
f92e72f
229cc20
2bda933
5ce0763
f152735
69cff40
aa3c2bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2024, NVIDIA 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 v1alpha1 | ||
|
||
import "fmt" | ||
|
||
// GpuDriver encodes the gpu driver as a string. | ||
type GpuDriver string | ||
|
||
const ( | ||
NvidiaDriver GpuDriver = "nvidia" | ||
VfioPciDriver GpuDriver = "vfio-pci" | ||
) | ||
|
||
// GpuDriverConfig holds the set of parameters for configuring a GPU with a driver. | ||
type GpuDriverConfig struct { | ||
Driver GpuDriver `json:"driver"` | ||
} | ||
|
||
// DefaultGpuDriverConfig provides the default configuration of a GPU with a driver. | ||
func DefaultGpuDriverConfig() *GpuDriverConfig { | ||
return &GpuDriverConfig{ | ||
Driver: NvidiaDriver, | ||
} | ||
} | ||
|
||
// Normalize updates a GpuDriverConfig config with implied default values based on other settings. | ||
func (c *GpuDriverConfig) Normalize() error { | ||
if c.Driver == "" { | ||
c.Driver = NvidiaDriver | ||
} | ||
return nil | ||
} | ||
|
||
// Validate ensures that GpuDriverConfig has a valid set of values. | ||
func (c *GpuDriverConfig) Validate() error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My question should probably have been: "Should we add an explict |
||
switch c.Driver { | ||
case NvidiaDriver: | ||
fallthrough | ||
case VfioPciDriver: | ||
break | ||
default: | ||
return fmt.Errorf("invalid driver '%s' specified in gpu driver configuration", c.Driver) | ||
} | ||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there another name for this driver that isn't
nvidia
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. The driver is simply called
nvidia