File tree Expand file tree Collapse file tree 4 files changed +36
-7
lines changed Expand file tree Collapse file tree 4 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ func (i *Image) Read(ctx context.Context) error {
34
34
image := i .Identifier
35
35
images := map [string ]string {
36
36
"ubuntu" : "ubuntu@099720109477:x86_64:*ubuntu/images/hvm-ssd/ubuntu-focal-20.04*" ,
37
+ "nvidia" : "ubuntu@679593333241:x86_64:NVIDIA Deep Learning AMI v21.02.2-*" ,
37
38
}
38
39
if val , ok := images [image ]; ok {
39
40
image = val
Original file line number Diff line number Diff line change @@ -82,12 +82,13 @@ func (v *VirtualMachineScaleSet) Create(ctx context.Context) error {
82
82
image := v .Attributes .Environment .Image
83
83
images := map [string ]string {
84
84
"ubuntu" : "ubuntu@Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest" ,
85
+ "nvidia" : "ubuntu@nvidia:ngc_base_image_version_b:gen2_21-11-0:latest#plan" ,
85
86
}
86
87
if val , ok := images [image ]; ok {
87
88
image = val
88
89
}
89
90
90
- imageParts := regexp .MustCompile (`^([^@]+)@([^:]+):([^:]+):([^:]+):([^:]+)$` ).FindStringSubmatch (image )
91
+ imageParts := regexp .MustCompile (`^([^@]+)@([^:]+):([^:]+):([^:]+):([^:]+)(:?(#plan)?) $` ).FindStringSubmatch (image )
91
92
if imageParts == nil {
92
93
return errors .New ("invalid machine image format: use publisher:offer:sku:version" )
93
94
}
@@ -97,6 +98,7 @@ func (v *VirtualMachineScaleSet) Create(ctx context.Context) error {
97
98
offer := imageParts [3 ]
98
99
sku := imageParts [4 ]
99
100
version := imageParts [5 ]
101
+ plan := imageParts [6 ]
100
102
101
103
size := v .Attributes .Size .Machine
102
104
sizes := map [string ]string {
@@ -185,6 +187,14 @@ func (v *VirtualMachineScaleSet) Create(ctx context.Context) error {
185
187
},
186
188
}
187
189
190
+ if plan == "#plan" {
191
+ settings .Plan = & compute.Plan {
192
+ Publisher : to .StringPtr (publisher ),
193
+ Product : to .StringPtr (offer ),
194
+ Name : to .StringPtr (sku ),
195
+ }
196
+ }
197
+
188
198
spot := v .Attributes .Spot
189
199
if spot >= 0 {
190
200
if spot == 0 {
Original file line number Diff line number Diff line change @@ -32,25 +32,35 @@ func (i *Image) Read(ctx context.Context) error {
32
32
image := i .Identifier
33
33
images := map [string ]string {
34
34
"ubuntu" : "ubuntu@ubuntu-os-cloud/ubuntu-2004-lts" ,
35
+ "nvidia" : "ubuntu@nvidia-ngc-public/nvidia-gpu-cloud-image-20211105" ,
35
36
}
36
37
if val , ok := images [image ]; ok {
37
38
image = val
38
39
}
39
40
40
41
match := regexp .MustCompile (`^([^@]+)@([^/]+)/([^/]+)$` ).FindStringSubmatch (image )
41
42
if match == nil {
42
- return common . NotFoundError
43
+ return errors . New ( "wrong image name" )
43
44
}
44
45
45
46
i .Attributes .SSHUser = match [1 ]
46
47
project := match [2 ]
47
- family := match [3 ]
48
+ imageOrFamily := match [3 ]
48
49
49
- resource , err := i .Client .Services .Compute .Images .GetFromFamily (project , family ).Do ()
50
+ resource , err := i .Client .Services .Compute .Images .Get (project , imageOrFamily ).Do ()
50
51
if err != nil {
51
52
var e * googleapi.Error
52
53
if errors .As (err , & e ) && e .Code == 404 {
53
- return common .NotFoundError
54
+ resource , err := i .Client .Services .Compute .Images .GetFromFamily (project , imageOrFamily ).Do ()
55
+ if err != nil {
56
+ var e * googleapi.Error
57
+ if errors .As (err , & e ) && e .Code == 404 {
58
+ return common .NotFoundError
59
+ }
60
+ return err
61
+ }
62
+ i .Resource = resource
63
+ return nil
54
64
}
55
65
return err
56
66
}
Original file line number Diff line number Diff line change @@ -68,11 +68,19 @@ func (j *Job) Create(ctx context.Context) error {
68
68
"l+v100" : "32-256000+nvidia-tesla-v100*4" ,
69
69
"xl+v100" : "64-512000+nvidia-tesla-v100*8" ,
70
70
}
71
-
72
71
if val , ok := sizes [size ]; ok {
73
72
size = val
74
73
}
75
74
75
+ image := j .Attributes .Task .Environment .Image
76
+ images := map [string ]string {
77
+ "ubuntu" : "ubuntu" ,
78
+ "nvidia" : "nvidia/cuda" ,
79
+ }
80
+ if val , ok := images [image ]; ok {
81
+ image = val
82
+ }
83
+
76
84
match := regexp .MustCompile (`^(\d+)-(\d+)(?:\+([^*]+)\*([1-9]\d*))?$` ).FindStringSubmatch (size )
77
85
if match == nil {
78
86
return common .NotFoundError
@@ -206,7 +214,7 @@ func (j *Job) Create(ctx context.Context) error {
206
214
Containers : []kubernetes_core.Container {
207
215
{
208
216
Name : j .Identifier ,
209
- Image : j . Attributes . Task . Environment . Image ,
217
+ Image : image ,
210
218
Resources : kubernetes_core.ResourceRequirements {
211
219
Limits : jobLimits ,
212
220
Requests : kubernetes_core.ResourceList {
You can’t perform that action at this time.
0 commit comments