Search

Chapter 6. Installing RHEL AI on Azure (Technology preview)

download PDF

For installing and deploying Red Hat Enterprise Linux AI on Azure, you must first convert the RHEL AI image into an Azure image. You can then launch an instance using the Azure image and deploy RHEL AI on an Azure machine.

Important

Installing Red Hat Enterprise Linux AI on Azure as well as using RHEL AI on Azure with AMD accelerators is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

6.1. Converting the RHEL AI image into a Azure image

To create a bootable image on Azure you must configure your Azure account, create an Azure Storage Container, and create an Azure image using the RHEL AI raw image.

Prerequisites

Procedure

  1. Log in to Azure by running the following command:

    $ az login

    Example output of the login

    $ az login
    A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
    [
      {
        "cloudName": "AzureCloud",
        "homeTenantId": "c7b976df-89ce-42ec-b3b2-a6b35fd9c0be",
        "id": "79d7df51-39ec-48b9-a15e-dcf59043c84e",
        "isDefault": true,
        "managedByTenants": [],
        "name": "Team Name",
        "state": "Enabled",
        "tenantId": "0a873aea-428f-47bd-9120-73ce0c5cc1da",
        "user": {
          "name": "user@example.com",
          "type": "user"
        }
      }
    ]

  2. Log in with the azcopy tool using the following commands:

    $ keyctl new_session
    $ azcopy login
  3. You need to set up various Azure configurations and create your Azure Storage Container before creating the Azure image.

    1. Create an environment variable defining the location of your instance with the following command:

      $ az_location=eastus
    2. Create a resource group and save the name in an environment variable named az_resource_group. The following example creates a resource group named Default in the location eastus. (You can omit this step if you want to use an already existing resource group).

      $ az_resource_group=Default
      $ az group create --name ${az_resource_group} --location ${az_location}
    3. Create an Azure storage account and save the name in an environment variable named az_storage_account by running the following commands:

      $ az_storage_account=THE_NAME_OF_YOUR_STORAGE_ACCOUNT
      $ az storage account create \
          --name ${az_storage_account} \
          --resource-group ${az_resource_group} \
          --location ${az_location} \
          --sku Standard_LRS
    4. Create your Azure Storage Container named as the environment variable az_storage_container with the following commands:

      $ az_storage_container=NAME_OF_MY_BUCKET
      $ az storage container create \
          --name ${az_storage_container} \
          --account-name ${az_storage_account} \
          --public-access off
    5. You can get your Subscription ID from the Azure account list by running the following command:

      $ az account list --output table
    6. Create a variable named ` az_subscription_id` with your Subscription ID .

      $ az_subscription_id=46c08fb3-83c5-4b59-8372-bf9caf15a681
    7. Grant azcopy write permission to user into the storage container. This example grants permission to the user user@example.com.

      $ az role assignment create \
          --assignee user@example.com \
          --role "Storage Blob Data Contributor" \
          --scope /subscriptions/${az_subscription_id}/resourceGroups/${az_resource_group}/providers/Microsoft.Storage/storageAccounts/${az_storage_account}/blobServices/default/containers/${az_storage_container}
  4. Red Hat currently does not provide RHEL AI Azure images. You need to create a Azure disk image using RHEL AI bootc image as base.

    1. Create this example Containerfile file, using the appropriate version of RHEL AI in the FROM line.
Note

Ensure you use the proper hardware vendor image in the FROM section of your Containerfile file. Red Hat Enterprise Linux AI currently supports NVIDIA accelorators while AMD accelorators are in technology preview.

+

FROM registry.redhat.io/rhelai1/bootc-nvidia-rhel9:1.2

RUN dnf install -y --nobest \
    cloud-init \
    hyperv-daemons \
    langpacks-en \
    NetworkManager-cloud-setup \
    nvme-cli \
    patch \
    rng-tools \
    uuid \
    WALinuxAgent \
  && systemctl enable waagent \
  && systemctl enable nm-cloud-setup.timer \
  && mkdir -p /etc/systemd/system/NetworkManager.service.wants \
  && ln -s /usr/lib/systemd/system/nm-cloud-setup.service /etc/systemd/system/NetworkManager.service.wants/nm-cloud-setup.service \
  && echo 'ClientAliveInterval 180' >> /etc/ssh/sshd_config \
  && echo -e 'minlen = 6\ndcredit = 0\nucredit = 0\nlcredit = 0\nocredit = 0\nminclass = 3' >> /etc/security/pwquality.conf \
  && sed -i \
     -e '/^ResourceDisk.Format=y/c\ResourceDisk.Format=n' \
     -e '/^resourcedisk.enableswap=y/c\resourcedisk.enableswap=n' \
     -e '/^provisioning.regeneratesshhostkeypair=y/c\provisioning.regeneratesshhostkeypair=n' \
     /etc/waagent.conf \
  && echo -e 'reporting:\n  logging:\n    type: log\n  telemetry:\n    type: hyperv' > /etc/cloud/cloud.cfg.d/10-azure-kvp.cfg \
  && echo -e 'datasource_list: [ Azure ]\ndatasource:\n   Azure:\n      apply_network_config: False' > /etc/cloud/cloud.cfg.d/91-azure_datasource.cfg \
  && echo 'SUBSYSTEM=="net", DRIVERS=="hv_pci", ACTION=="add", ENV{NM_UNMANAGED}="1"' > etc/udev/rules.d/68-azure-sriov-nm-unmanaged.rules \
  && echo -e '[install]\nkargs = ["loglevel=3", "console=tty1", "console=ttyS0,115200n8", "earlyprintk=ttyS0,115200", "net.ifnames=0"]' > /usr/lib/bootc/install/05-cloud-kargs.toml \
  && mkdir -p /usr/lib/systemd/system/nm-cloud-setup.service.d \
  && echo -e '[Service]\nEnvironment="NM_CLOUD_SETUP_AZURE=yes' > /usr/lib/systemd/system/nm-cloud-setup.service.d/10-rh-enable-for-azure.conf \
  && for blacklist in amdgpu floppy intel_cstate nouveau lbm-nouveau skx_edac; do echo "blacklist $blacklist" >> /etc/modprobe.d/blacklist_azure.conf; done
  1. Build the bootc image, in the same directory that holds the Containerfile, by running the following commands:

    $ AZURE_BOOTC_IMAGE=quay.io/yourquayusername/bootc-nvidia-rhel9-azure
    $ podman build --file Containerfile --tag ${AZURE_BOOTC_IMAGE} .
Note

Ensure you are running the podman build command from a RHEL enabled system. If you are not on a RHEL system, building the Containerfile file will fail.

  1. Create a config.toml file that will be used in disk image generation.

    [customizations.kernel]
    name = "azure"
    append = "loglevel=3 console=tty1 console=ttyS0,115200n8 earlyprintk=ttyS0,115200 net.ifnames=0"
  2. Build the disk image using bootc-image-builder by running the following commands:

    $ mkdir -p build/store build/output
    $ podman run --rm -ti --privileged --pull newer \
      -v /var/lib/containers/storage:/var/lib/containers/storage \
      -v ./build/store:/store -v ./build/output:/output \
      -v ./config.toml:/config.toml \
      quay.io/centos-bootc/bootc-image-builder \
        --config /config.toml \
        --chown 0:0 \
        --local \
        --type raw \
        --target-arch x86_64 \
        ${AZURE_BOOTC_IMAGE}
    1. Set the name you want to use as the RHEL AI Azure image.

      $ image_name=rhel-ai-1.2
    2. Convert the RAW image to VHD format by running the following command:

      $ raw_file=<path-to-raw-file>
      $ vhd_file=rhelai.vhd
      $ qemu-img convert -f raw -O vpc -o subformat=fixed,force_size "$raw_file" "$vhd_file"
    3. Upload the VHD file to the Azure Storage Container by running the following command:

      $ az_vhd_url="https://${az_storage_account}.blob.core.windows.net/${az_storage_container}/$(basename ${vhd_file})"
      $ azcopy copy "$vhd_file" "$az_vhd_url"
    4. Create an Azure image from the VHD file you just uploaded with the following command:

      $ az image create --resource-group $az_resource_group \
          --name "$image_name" \
          --source "${az_vhd_url}" \
          --location ${az_location} \
          --os-type Linux \
          --hyper-v-generation V2

6.2. Deploying your instance on Azure using the CLI

You can launch an instance with your new RHEL AI Azure image from the Azure web console or the CLI. You can use whichever method of deployment you want to launch your instance. The following procedure displays how you can use the CLI to launch an Azure instance with the custom Azure image

If you choose to use the CLI as a deployment option, there are several configurations you have to create, as shown in "Prerequisites".

Prerequisites

  • You created your RHEL AI Azure image. For more information, see "Converting the RHEL AI image to an Azure image".
  • You installed the Azure CLI on your specific machine, see Install the Azure CLI on Linux.

Procedure

  1. Log in to your Azure account by running the following command:

    $ az login
  2. You need to select the instance profile that you want to use for the deployment. List all the profiles in the desired region by running the following command:

    $ az vm list-sizes --location <region> --output table

    Make a note of your preferred instance profile, you will need it for your instance deployment.

  3. You can now start creating your Azure instance. Populate environment variables for when you create the instance.

    name=my-rhelai-instance
    az_location=eastus
    az_resource_group=my_resource_group
    az_admin_username=azureuser
    az_vm_size=Standard_ND96isr_H100_v5
    az_image=my-custom-rhelai-image
    sshpubkey=$HOME/.ssh/id_rsa.pub
    disk_size=1024
  4. You can launch your instance, by running the following command:

    $ az vm create \
        --resource-group $az_resource_group \
        --name ${name} \
        --image ${az_image} \
        --size ${az_vm_size} \
        --location ${az_location} \
        --admin-username ${az_admin_username} \
        --ssh-key-values @$sshpubkey \
        --authentication-type ssh \
        --nic-delete-option Delete \
        --accelerated-networking true \
        --os-disk-size-gb 1024 \
        --os-disk-name ${name}-${az_location}

Verification

  • To verify that your Red Hat Enterprise Linux AI tools are installed correctly, run the ilab command:

    $ ilab

    Example output

    $ ilab
    Usage: ilab [OPTIONS] COMMAND [ARGS]...
    
      CLI for interacting with InstructLab.
    
      If this is your first time running ilab, it's best to start with `ilab
      config init` to create the environment.
    
    Options:
      --config PATH  Path to a configuration file.  [default:
                     /home/auser/.config/instructlab/config.yaml]
      -v, --verbose  Enable debug logging (repeat for even more verbosity)
      --version      Show the version and exit.
      --help         Show this message and exit.
    
    Commands:
      config    Command Group for Interacting with the Config of InstructLab.
      data      Command Group for Interacting with the Data generated by...
      model     Command Group for Interacting with the Models in InstructLab.
      system    Command group for all system-related command calls
      taxonomy  Command Group for Interacting with the Taxonomy of InstructLab.
    
    Aliases:
      chat      model chat
      convert   model convert
      diff      taxonomy diff
      download  model download
      evaluate  model evaluate
      generate  data generate
      init      config init
      list      model list
      serve     model serve
      sysinfo   system info
      test      model test
      train     model train

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.