Skip to content

Commit ddcaa62

Browse files
committed
Add GPU drivers and shape to the VM image
Signed-off-by: Koray Oksay <koray.oksay@gmail.com>
1 parent c7c6bdf commit ddcaa62

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

ci/cloudrunners/oci/main.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func run(cmd *cobra.Command, argv []string) error {
8686
}
8787

8888
// Create a new ephemeral machine
89-
machine, err := oci.NewEphemeralMachine(ctx, computeClient, networkClient, core.LaunchInstanceDetails{
89+
launchDetails := core.LaunchInstanceDetails{
9090
AvailabilityDomain: common.String(args.availabilityDomain),
9191
CompartmentId: common.String(args.compartmentId),
9292
Shape: common.String(args.shape),
@@ -95,10 +95,6 @@ func run(cmd *cobra.Command, argv []string) error {
9595
SubnetId: common.String(args.subnetId),
9696
AssignPublicIp: common.Bool(true),
9797
},
98-
ShapeConfig: &core.LaunchInstanceShapeConfigDetails{
99-
MemoryInGBs: common.Float32(args.shapeMemoryInGBs),
100-
Ocpus: common.Float32(args.shapeOcpus),
101-
},
10298
Metadata: map[string]string{
10399
"ssh_authorized_keys": sshKeyPair.PublicKey,
104100
},
@@ -112,7 +108,17 @@ func run(cmd *cobra.Command, argv []string) error {
112108
AreAllPluginsDisabled: common.Bool(false),
113109
IsMonitoringDisabled: common.Bool(false),
114110
},
115-
})
111+
}
112+
113+
if args.shapeMemoryInGBs > 0.0 && args.shapeOcpus > 0.0 {
114+
launchDetails.ShapeConfig = &core.LaunchInstanceShapeConfigDetails{
115+
MemoryInGBs: common.Float32(args.shapeMemoryInGBs),
116+
Ocpus: common.Float32(args.shapeOcpus),
117+
}
118+
}
119+
120+
machine, err := oci.NewEphemeralMachine(ctx, computeClient, networkClient, launchDetails)
121+
116122
if err != nil {
117123
return fmt.Errorf("failed to create machine: %w", err)
118124
}

ci/gha-runner-vm/main.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,24 @@ func run(cmd *cobra.Command, argv []string) error {
310310
return nil
311311
}
312312
log.Printf("Image capabilities updated:\n%s", string(output))
313+
} else {
314+
// Add VM.GPU.A10.1 and VM.GPU.A10.2
315+
addList := []string{
316+
"VM.GPU.A10.1",
317+
"VM.GPU.A10.2",
318+
}
319+
for _, machine := range addList {
320+
command = exec.Command("oci", "raw-request", "--http-method", "PUT", "--target-uri", "https://iaas.us-sanjose-1.oraclecloud.com/20160918/images/"+imageID+"/shapes/"+machine, "--request-body", "{\"ocpuConstraints\":{\"min\":\"1\",\"max\":\"80\"},\"memoryConstraints\":{\"minInGBs\":\"1\",\"maxInGBs\":\"512\"},\"imageId\":\""+imageID+"\",\"shape\":\""+machine+"\"}")
321+
output, err = command.CombinedOutput()
322+
if err != nil {
323+
log.Print(command.String())
324+
log.Printf("OCI command failed. Output:\n%s", string(output))
325+
log.Fatal("could not run command: ", err)
326+
exec.Command("oci", "compute", "image", "delete", "--force", "--image-id", imageID)
327+
return nil
328+
}
329+
log.Printf("%s compatibility added", machine)
330+
}
313331
}
314332

315333
log.Println("New Ubuntu 24.04 image created successfully.")
@@ -662,6 +680,19 @@ build {
662680

663681
// Remove chrome installation, there is no arm build from Google
664682
replacements[`"${path.root}/../scripts/build/install-google-chrome.sh",`] = ``
683+
} else {
684+
replacements[`provisioner "shell" {
685+
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
686+
script = "${path.root}/../scripts/build/list-dpkg.sh"
687+
}`] = `provisioner "shell" {
688+
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
689+
script = "${path.root}/../scripts/build/list-dpkg.sh"
690+
}
691+
692+
provisioner "shell" {
693+
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
694+
inline = ["apt install -y ubuntu-drivers-common", "ubuntu-drivers install nvidia:570-server"]
695+
}`
665696
}
666697

667698
replacements[`"${path.root}/../scripts/build/install-actions-cache.sh",`] = `"${path.root}/../scripts/build/install-actions-cache.sh",

0 commit comments

Comments
 (0)