Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion pkg/lib/aws/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ import (
s "github.com/cortexlabs/cortex/pkg/lib/strings"
)

var _digitsRegex = regexp.MustCompile(`[0-9]+`)
var (
_digitsRegex = regexp.MustCompile(`[0-9]+`)
_gpuInstanceFamilies = strset.New("g", "p")
)

type ParsedInstanceType struct {
Family string
Expand Down Expand Up @@ -117,6 +120,23 @@ func IsARMInstance(instanceType string) (bool, error) {
return false, nil
}

func IsAMDGPUInstance(instanceType string) (bool, error) {
parsedType, err := ParseInstanceType(instanceType)
if err != nil {
return false, err
}

if !_gpuInstanceFamilies.Has(parsedType.Family) {
return false, nil
}

if parsedType.Capabilities.Has("a") {
return true, nil
}

return false, nil
}

func (c *Client) SpotInstancePrice(instanceType string) (float64, error) {
result, err := c.EC2().DescribeSpotPriceHistory(&ec2.DescribeSpotPriceHistoryInput{
InstanceTypes: []*string{aws.String(instanceType)},
Expand Down
8 changes: 8 additions & 0 deletions pkg/types/clusterconfig/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,14 @@ func validateInstanceType(instanceType string) (string, error) {
return "", ErrorARMInstancesNotSupported(instanceType)
}

isAMDGPU, err := aws.IsAMDGPUInstance(instanceType)
if err != nil {
return "", err
}
if isAMDGPU {
return "", ErrorAMDGPUInstancesNotSupported(instanceType)
}

if err := checkCNISupport(instanceType); err != nil {
return "", err
}
Expand Down
10 changes: 9 additions & 1 deletion pkg/types/clusterconfig/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
ErrSpotPriceGreaterThanMaxPrice = "clusterconfig.spot_price_greater_than_max_price"
ErrInstanceTypeNotSupportedByCortex = "clusterconfig.instance_type_not_supported_by_cortex"
ErrARMInstancesNotSupported = "clusterconfig.arm_instances_not_supported"
ErrAMDGPUInstancesNotSupported = "clusterconfig.amd_gpu_instances_not_supported"
ErrAtLeastOneInstanceDistribution = "clusterconfig.at_least_one_instance_distribution"
ErrNoCompatibleSpotInstanceFound = "clusterconfig.no_compatible_spot_instance_found"
ErrConfiguredWhenSpotIsNotEnabled = "clusterconfig.configured_when_spot_is_not_enabled"
Expand Down Expand Up @@ -203,7 +204,14 @@ func ErrorInstanceTypeNotSupportedByCortex(instanceType string) error {
func ErrorARMInstancesNotSupported(instanceType string) error {
return errors.WithStack(&errors.Error{
Kind: ErrARMInstancesNotSupported,
Message: fmt.Sprintf("ARM-based instances (including %s) are not supported", instanceType),
Message: fmt.Sprintf("ARM-based instances (including %s) are not supported by cortex", instanceType),
})
}

func ErrorAMDGPUInstancesNotSupported(instanceType string) error {
return errors.WithStack(&errors.Error{
Kind: ErrAMDGPUInstancesNotSupported,
Message: fmt.Sprintf("AMD GPU instances (including %s) are not supported by cortex", instanceType),
})
}

Expand Down