Skip to content

Commit 23011fc

Browse files
allow uninitialized gpu count (#858)
* allow uninitialized gpu count * update protoc-gen-go
1 parent 085997f commit 23011fc

File tree

6 files changed

+56
-2
lines changed

6 files changed

+56
-2
lines changed

src/pkg/quota/service.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ func (q ServiceQuotas) ValidateQuotas(service *types.ServiceConfig) error {
4141
if device.Driver != "" && device.Driver != "nvidia" {
4242
return errors.New("only nvidia GPU devices are supported") // CodeInvalidArgument
4343
}
44-
if q.Gpus == 0 || uint32(device.Count) > q.Gpus {
44+
var deviceCount uint32
45+
if device.Count == -1 {
46+
deviceCount = 1
47+
} else {
48+
deviceCount = uint32(device.Count)
49+
}
50+
if q.Gpus == 0 || deviceCount > q.Gpus {
4551
return fmt.Errorf("gpu count %v exceeds quota %d", device.Count, q.Gpus) // CodeInvalidArgument
4652
}
4753
}

src/protos/io/defang/v1/fabric.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tests/gpu/compose.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
mistral:
3+
deploy:
4+
resources:
5+
reservations:
6+
devices:
7+
- capabilities: ["gpu"]

src/tests/gpu/compose.yaml.fixup

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[
2+
{
3+
"command": null,
4+
"deploy": {
5+
"replicas": 1,
6+
"resources": {
7+
"reservations": {
8+
"devices": [
9+
{
10+
"capabilities": [
11+
"gpu"
12+
],
13+
"count": -1
14+
}
15+
]
16+
}
17+
},
18+
"placement": {}
19+
},
20+
"entrypoint": null,
21+
"networks": {
22+
"default": null
23+
}
24+
}
25+
]

src/tests/gpu/compose.yaml.golden

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: gpu
2+
services:
3+
mistral:
4+
deploy:
5+
resources:
6+
reservations:
7+
devices:
8+
- capabilities:
9+
- gpu
10+
count: -1
11+
networks:
12+
default: null
13+
networks:
14+
default:
15+
name: gpu_default
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
! service "mistral": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors

0 commit comments

Comments
 (0)