Skip to content

Commit

Permalink
GPUs != Accelerators
Browse files Browse the repository at this point in the history
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
  • Loading branch information
dims committed Feb 22, 2025
1 parent 1abff2a commit e796610
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 10 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ require (
github.com/ashanbrown/forbidigo v1.6.0 // indirect
github.com/ashanbrown/makezero v1.2.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aws/amazon-ec2-instance-selector/v3 v3.1.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.29 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.33 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aws/amazon-ec2-instance-selector/v2 v2.4.2-0.20231216170552-14d4dfcbaadf h1:1zems5/6/Fs+1dFsjTZ+oSogVHkfGl1VWuttRXYGx+0=
github.com/aws/amazon-ec2-instance-selector/v2 v2.4.2-0.20231216170552-14d4dfcbaadf/go.mod h1:zsxolOKwtNEvoOPScJy5+Bu8F72LZy7pqVJNhP8tqVE=
github.com/aws/amazon-ec2-instance-selector/v3 v3.1.0 h1:NtSErNyyzyMzV3RXD3HGMTYUHD+XcaHbAMQHFaoU5Y4=
github.com/aws/amazon-ec2-instance-selector/v3 v3.1.0/go.mod h1:S8Yga4m3aMYvvCDWE4DA72hywLmvY/yknG45QiW0l/M=
github.com/aws/aws-sdk-go v1.55.6 h1:cSg4pvZ3m8dgYcgqB97MrcdjUmZ1BeMYKUxMMB89IPk=
github.com/aws/aws-sdk-go v1.55.6/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
github.com/aws/aws-sdk-go-v2 v1.36.2 h1:Ub6I4lq/71+tPb/atswvToaLGVMxKZvjYDVOWEExOcU=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var _ = Describe("(Integration) [Instance Selector test]", func() {
}, "--instance-selector-vcpus=8",
"--instance-selector-memory=32",
"--instance-selector-gpus=0",
"--instance-selector-accelerators=0",
),
Entry("with vCPUs and memory", nil,
"--instance-selector-vcpus=8",
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,9 @@ type InstanceSelector struct {
// GPUs specifies the number of GPUs.
// It can be set to 0 to select non-GPU instance types.
GPUs *int `json:"gpus,omitempty"`
// Accelerators specifies the number of Accelerators.
// It can be set to 0 to select non-Accelerator instance types.
Accelerators *int `json:"accelerators,omitempty"`
// CPU Architecture of the EC2 instance type.
// Valid variants are:
// `"x86_64"`
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ var (
GPUDriversWarning = func(amiFamily string) string {
return fmt.Sprintf("%s does not ship with NVIDIA GPU drivers installed, hence won't support running GPU-accelerated workloads out of the box", amiFamily)
}

AcceleratorDriversWarning = func(amiFamily string) string {
return fmt.Sprintf("%s does not ship with Inferentia Accelerators drivers installed, hence won't support running inference-accelerated workloads out of the box", amiFamily)
}
)

var (
Expand Down Expand Up @@ -736,6 +740,10 @@ func validateNodeGroupBase(np NodePool, path string, controlPlaneOnOutposts bool
(ng.InstanceSelector.GPUs == nil || *ng.InstanceSelector.GPUs != 0) {
logger.Warning("instance selector may/will select GPU instance types, " + GPUDriversWarning(ng.AMIFamily))
}
if ng.InstanceSelector != nil && !ng.InstanceSelector.IsZero() &&
(ng.InstanceSelector.Accelerators == nil || *ng.InstanceSelector.Accelerators != 0) {
logger.Warning("instance selector may/will select Accelerator instance types, " + AcceleratorDriversWarning(ng.AMIFamily))
}
}

if ng.AMIFamily != NodeImageFamilyAmazonLinux2 &&
Expand Down
3 changes: 3 additions & 0 deletions pkg/ctl/cmdutils/configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ func normalizeBaseNodeGroup(np api.NodePool, cmd *cobra.Command) {
if !flags.Changed("instance-selector-gpus") {
ng.InstanceSelector.GPUs = nil
}
if !flags.Changed("instance-selector-accelerators") {
ng.InstanceSelector.Accelerators = nil
}
if !flags.Changed("enable-ssm") {
ng.SSH.EnableSSM = nil
}
Expand Down
1 change: 1 addition & 0 deletions pkg/ctl/cmdutils/nodegroup_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func AddInstanceSelectorOptions(flagSetGroup *NamedFlagSetGroup, ng *api.NodeGro
fs.StringVar(&ng.InstanceSelector.Memory, "instance-selector-memory", "", "4 or 4GiB")
fs.StringVar(&ng.InstanceSelector.CPUArchitecture, "instance-selector-cpu-architecture", "", "x86_64, or arm64")
ng.InstanceSelector.GPUs = fs.Int("instance-selector-gpus", 0, "an integer value")
ng.InstanceSelector.Accelerators = fs.Int("instance-selector-accelerators", 0, "an integer value")
})
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/create/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
kubeclient "k8s.io/client-go/kubernetes"
clientcmdlatest "k8s.io/client-go/tools/clientcmd/api/latest"

"github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector"
"github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector"
"github.com/weaveworks/eksctl/pkg/accessentry"
accessentryactions "github.com/weaveworks/eksctl/pkg/actions/accessentry"
"github.com/weaveworks/eksctl/pkg/actions/addon"
Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/create/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"io"

"github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector"
"github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector"

"github.com/kris-nova/logger"
"github.com/pkg/errors"
Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/get/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"time"

"github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector"
"github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector"
"github.com/kris-nova/logger"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/scale/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package scale
import (
"context"

"github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector"
"github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/update/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package update
import (
"context"

"github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector"
"github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector"

"github.com/lithammer/dedent"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/upgrade/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"time"

"github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector"
"github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand Down
2 changes: 1 addition & 1 deletion pkg/eks/fakes/fake_instance_selector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions pkg/eks/nodegroup_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"reflect"
"strings"

"github.com/aws/amazon-ec2-instance-selector/v2/pkg/bytequantity"
"github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector"
"github.com/aws/amazon-ec2-instance-selector/v3/pkg/bytequantity"
"github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/kris-nova/logger"
"github.com/pkg/errors"
Expand Down Expand Up @@ -202,6 +202,12 @@ func (n *NodeGroupService) expandInstanceSelector(ins *api.InstanceSelector, azs
if ins.GPUs != nil {
filters.GpusRange = makeRange(*ins.GPUs)
}
if ins.Accelerators != nil {
filters.InferenceAcceleratorsRange = &selector.IntRangeFilter{
LowerBound: *ins.Accelerators,
UpperBound: *ins.Accelerators,
}
}
cpuArch := ins.CPUArchitecture
if cpuArch == "" {
cpuArch = defaultCPUArch
Expand Down
2 changes: 1 addition & 1 deletion userdocs/src/usage/instance-selector.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ $ eksctl create cluster -f instance-selector-cluster.yaml

The following instance selector CLI options are supported by `eksctl create cluster` and `eksctl create nodegroup`:

`--instance-selector-vcpus`, `--instance-selector-memory`, `--instance-selector-gpus` and `instance-selector-cpu-architecture`
`--instance-selector-vcpus`, `--instance-selector-memory`, `--instance-selector-gpus`, `--instance-selector-accelerators` and `instance-selector-cpu-architecture`

???+ note
By default, GPU instance types are not filtered out. If you wish to do so (e.g. for cost effectiveness, when your applications don't particularly benefit from GPU-accelerated workloads), please explicitly set `gpus: 0` (via config file) or `--instance-selector-gpus=0` (via CLI flag).
Expand Down

0 comments on commit e796610

Please sign in to comment.