Skip to content

Commit

Permalink
fix: hardcode resouce request of gpus to 1 if utilize a existing ray …
Browse files Browse the repository at this point in the history
…cluster

Signed-off-by: bjwswang <[email protected]>
  • Loading branch information
bjwswang committed Mar 27, 2024
1 parent 0b9848c commit 1d3498f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion deploy/charts/arcadia/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: arcadia
description: A Helm chart(Also a KubeBB Component) for KubeAGI Arcadia
type: application
version: 0.3.24
version: 0.3.25
appVersion: "0.2.1"

keywords:
Expand Down
10 changes: 5 additions & 5 deletions deploy/charts/arcadia/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ data:
- id: 4
name: "效率"
nameEn: "Efficiency"
- id: 4
- id: 5
name: "人物扮演"
nameEn: "Character Play"
- id: 5
- id: 6
name: "游戏"
nameEn: "Game"
- id: 6
- id: 7
name: "生活"
nameEn: "Life"
- id: 7
- id: 8
name: "情感"
nameEn: "Emotion"
- id: 8
- id: 9
name: "动漫"
nameEn: "Anime"
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (rayCluster RayCluster) GetPythonVersion() string {
return rayCluster.PythonVersion
}

// DefaultRayCluster which can be used for vllm worker as local ray cluster
// DefaultRayCluster which can be used for vllm worker as local ray cluster which can only utilize single node gpus
func DefaultRayCluster() RayCluster {
return RayCluster{
Name: "default",
Expand Down
14 changes: 11 additions & 3 deletions pkg/worker/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"strconv"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -196,8 +197,12 @@ func (runner *RunnerFastchatVLLM) Build(ctx context.Context, model *arcadiav1alp
additionalEnvs := []corev1.EnvVar{}

// configure ray cluster
resources := runner.w.Spec.Resources
gpus := runner.NumberOfGPUs()
// default ray cluster which can only utilize gpus on single nodes
rayCluster := config.DefaultRayCluster()
for _, envItem := range runner.w.Spec.AdditionalEnvs {
// using existing ray cluster
if envItem.Name == "RAY_CLUSTER_INDEX" {
externalRayClusterIndex, _ := strconv.Atoi(envItem.Value)
rayClusters, err := config.GetRayClusters(ctx, runner.c)
Expand All @@ -208,6 +213,8 @@ func (runner *RunnerFastchatVLLM) Build(ctx context.Context, model *arcadiav1alp
return nil, fmt.Errorf("no ray clusters configured")
}
rayCluster = rayClusters[externalRayClusterIndex]
// Hardcoded directly requested gpu to 1 if using existing ray cluster
resources.Limits[ResourceNvidiaGPU] = resource.MustParse("1")
}

// set gpu memory utilization
Expand All @@ -224,6 +231,8 @@ func (runner *RunnerFastchatVLLM) Build(ctx context.Context, model *arcadiav1alp
extraAgrs = envItem.Value
}
}
klog.V(5).Infof("run worker with raycluster:\n %s", rayCluster.String())

// set ray configurations into additional environments
additionalEnvs = append(additionalEnvs,
corev1.EnvVar{
Expand All @@ -237,8 +246,7 @@ func (runner *RunnerFastchatVLLM) Build(ctx context.Context, model *arcadiav1alp
Value: rayCluster.GetPythonVersion(),
})
// Set gpu number to the number of GPUs in the worker's resource
additionalEnvs = append(additionalEnvs, corev1.EnvVar{Name: "NUMBER_GPUS", Value: runner.NumberOfGPUs()})
klog.V(5).Infof("run worker with raycluster:\n %s", rayCluster.String())
additionalEnvs = append(additionalEnvs, corev1.EnvVar{Name: "NUMBER_GPUS", Value: gpus})

modelFileDir := fmt.Sprintf("%s/%s", defaultModelMountPath, model.Name)
// --enforce-eager to disable cupy
Expand Down Expand Up @@ -287,7 +295,7 @@ func (runner *RunnerFastchatVLLM) Build(ctx context.Context, model *arcadiav1alp
// mount volume to /dev/shm to avoid Bus error
{Name: "models", MountPath: defaultShmMountPath},
},
Resources: runner.w.Spec.Resources,
Resources: resources,
}
container.Env = append(container.Env, additionalEnvs...)
return container, nil
Expand Down

0 comments on commit 1d3498f

Please sign in to comment.