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 7f8cf97 commit fbf1d5f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/image_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:

jobs:
image:
if: github.repository == 'kubeagi/arcadia'
if: github.repository == 'bjwswang/arcadia'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
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.23
version: 0.3.24
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 @@ -29,6 +29,7 @@ import (

arcadiav1alpha1 "github.com/kubeagi/arcadia/api/base/v1alpha1"
"github.com/kubeagi/arcadia/pkg/config"
"k8s.io/apimachinery/pkg/api/resource"

Check failure on line 32 in pkg/worker/runner.go

View workflow job for this annotation

GitHub Actions / Lint Go code

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kubeagi/arcadia) -s blank -s dot --custom-order (gci)
)

const (
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 fbf1d5f

Please sign in to comment.