diff --git a/vm_images/linux/bootstrap.sh b/vm_images/linux-amd64/bootstrap.sh similarity index 100% rename from vm_images/linux/bootstrap.sh rename to vm_images/linux-amd64/bootstrap.sh diff --git a/vm_images/linux/install_drivers.sh b/vm_images/linux-amd64/install_drivers.sh similarity index 100% rename from vm_images/linux/install_drivers.sh rename to vm_images/linux-amd64/install_drivers.sh diff --git a/vm_images/linux/linux.pkr.hcl b/vm_images/linux-amd64/linux-amd64.pkr.hcl similarity index 85% rename from vm_images/linux/linux.pkr.hcl rename to vm_images/linux-amd64/linux-amd64.pkr.hcl index c699089..45389ed 100644 --- a/vm_images/linux/linux.pkr.hcl +++ b/vm_images/linux-amd64/linux-amd64.pkr.hcl @@ -9,13 +9,13 @@ packer { locals { ami_name_prefix = "xgboost-ci" - image_name = "RunsOn worker with Ubuntu 24.04 + CUDA driver" + image_name = "RunsOn worker with Ubuntu 24.04 AMD64 + CUDA driver" region = "us-west-2" timestamp = regex_replace(timestamp(), "[- TZ:]", "") volume_size = 40 } -data "amazon-ami" "aws-ubuntu-x64" { +data "amazon-ami" "aws-ubuntu-amd64" { filters = { name = "ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*" root-device-type = "ebs" @@ -25,9 +25,9 @@ data "amazon-ami" "aws-ubuntu-x64" { owners = ["amazon"] } -source "amazon-ebs" "runs-on-linux" { - source_ami = "${data.amazon-ami.aws-ubuntu-x64.id}" - ami_name = "${local.ami_name_prefix}-runs-on-linux-${local.timestamp}" +source "amazon-ebs" "runs-on-linux-amd64" { + source_ami = "${data.amazon-ami.aws-ubuntu-amd64.id}" + ami_name = "${local.ami_name_prefix}-runs-on-linux-amd64-${local.timestamp}" ami_description = "${local.image_name}" ami_regions = ["${local.region}"] ami_virtualization_type = "hvm" @@ -60,7 +60,7 @@ source "amazon-ebs" "runs-on-linux" { } build { - sources = ["source.amazon-ebs.runs-on-linux"] + sources = ["source.amazon-ebs.runs-on-linux-amd64"] provisioner "shell" { script = "install_drivers.sh" diff --git a/vm_images/linux/setup_ssh.sh b/vm_images/linux-amd64/setup_ssh.sh similarity index 100% rename from vm_images/linux/setup_ssh.sh rename to vm_images/linux-amd64/setup_ssh.sh diff --git a/vm_images/linux-arm64/bootstrap.sh b/vm_images/linux-arm64/bootstrap.sh new file mode 100644 index 0000000..061dce4 --- /dev/null +++ b/vm_images/linux-arm64/bootstrap.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -euo pipefail + +## Install basic tools +echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections +sudo apt-get update +sudo apt-get install -y cmake git build-essential wget ca-certificates curl unzip + +## Install Python3 +sudo apt-get update +sudo apt-get install -y python3 python3-pip python3-venv +sudo pip3 install --break-system-packages 'pip>=23' 'wheel>=0.42' pydistcheck + +## Install Docker +# Add Docker's official GPG key: +sudo install -m 0755 -d /etc/apt/keyrings +sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc +sudo chmod a+r /etc/apt/keyrings/docker.asc +# Add the repository to Apt sources: +echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +sudo apt-get update +sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin +# Allow users to use Docker without sudo +sudo usermod -aG docker ubuntu + +# Start Docker daemon +sudo systemctl is-active --quiet docker.service || sudo systemctl start docker.service +sudo systemctl is-enabled --quiet docker.service || sudo systemctl enable docker.service +sleep 10 # Docker daemon takes time to come up after installing +sudo docker info +sudo systemctl stop docker + +## Install AWS CLI v2 +wget -nv https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip -O awscliv2.zip +unzip -q awscliv2.zip +sudo ./aws/install +rm -rf ./aws/ ./awscliv2.zip + +## Install jq and yq +sudo apt update && sudo apt install jq +mkdir yq/ +pushd yq/ +wget -nv https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_arm64.tar.gz -O - | \ + tar xz && sudo mv ./yq_linux_arm64 /usr/bin/yq +popd +rm -rf yq/ diff --git a/vm_images/linux-arm64/linux-arm64.pkr.hcl b/vm_images/linux-arm64/linux-arm64.pkr.hcl new file mode 100644 index 0000000..dc4ec6f --- /dev/null +++ b/vm_images/linux-arm64/linux-arm64.pkr.hcl @@ -0,0 +1,68 @@ +packer { + required_plugins { + amazon = { + source = "github.com/hashicorp/amazon" + version = "~> 1" + } + } +} + +locals { + ami_name_prefix = "xgboost-ci" + image_name = "RunsOn worker with Ubuntu 24.04 ARM64" + region = "us-west-2" + timestamp = regex_replace(timestamp(), "[- TZ:]", "") + volume_size = 40 +} + +data "amazon-ami" "aws-ubuntu-arm64" { + filters = { + name = "ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server-*" + root-device-type = "ebs" + virtualization-type = "hvm" + } + most_recent = true + owners = ["amazon"] +} + +source "amazon-ebs" "runs-on-linux-arm64" { + source_ami = "${data.amazon-ami.aws-ubuntu-arm64.id}" + ami_name = "${local.ami_name_prefix}-runs-on-linux-arm64-${local.timestamp}" + ami_description = "${local.image_name}" + ami_regions = ["${local.region}"] + ami_virtualization_type = "hvm" + associate_public_ip_address = true + communicator = "ssh" + instance_type = "c6g.4xlarge" + region = "${local.region}" + ssh_timeout = "10m" + ssh_username = "ubuntu" + ssh_file_transfer_method = "sftp" + user_data_file = "setup_ssh.sh" + launch_block_device_mappings { + device_name = "/dev/sda1" + volume_size = "${local.volume_size}" + volume_type = "gp3" + delete_on_termination = true + } + aws_polling { # Wait up to 1 hour until the AMI is ready + delay_seconds = 15 + max_attempts = 240 + } + snapshot_tags = { + Name = "${local.image_name}" + BuildTime = "${local.timestamp}" + } + tags = { + Name = "${local.image_name}" + BuildTime = "${local.timestamp}" + } +} + +build { + sources = ["source.amazon-ebs.runs-on-linux-arm64"] + + provisioner "shell" { + script = "bootstrap.sh" + } +} diff --git a/vm_images/linux-arm64/setup_ssh.sh b/vm_images/linux-arm64/setup_ssh.sh new file mode 100644 index 0000000..501b4da --- /dev/null +++ b/vm_images/linux-arm64/setup_ssh.sh @@ -0,0 +1,2 @@ +#!/bin/bash +systemctl start ssh