Building your RHEL AI environment Red Hat Enterprise Linux AI 1.3 Creating accounts, initalizing RHEL AI, downloading models, and serving/chat customizations Red Hat RHEL AI Documentation Team

Commands:
rhc connect --organization <org id> --activation-key <created key>
sudo mkdir -p /etc/ilab sudo touch /etc/ilab/insights-opt-out
ilab system info
ilab config init
Generating config file and profiles: /home/user/.config/instructlab/config.yaml /home/user/.local/share/instructlab/internal/system_profiles/ We have detected the NVIDIA H100 X4 profile as an exact match for your system. -------------------------------------------- Initialization completed successfully! You're ready to start using `ilab`. Enjoy! --------------------------------------------
Please choose a system profile to use. System profiles apply to all parts of the config file and set hardware specific defaults for each command. First, please select the hardware vendor your system falls into [0] NO SYSTEM PROFILE [1] NVIDIA Enter the number of your choice [0]: 4 You selected: NVIDIA Next, please select the specific hardware configuration that most closely matches your system. [0] No system profile [1] NVIDIA H100 X2 [2] NVIDIA H100 X8 [3] NVIDIA H100 X4 [4] NVIDIA L4 X8 [5] NVIDIA A100 X2 [6] NVIDIA A100 X8 [7] NVIDIA A100 X4 [8] NVIDIA L40S X4 [9] NVIDIA L40S X8 Enter the number of your choice [hit enter for hardware defaults] [0]: 3
You selected: /Users/<user>/.local/share/instructlab/internal/system_profiles/nvidia/H100/h100_x4.yaml -------------------------------------------- Initialization completed successfully! You're ready to start using `ilab`. Enjoy! --------------------------------------------
rm -rf ~/.local/share/instructlab/taxonomy/ ; git clone https://github.com/RedHatOfficial/rhelai-sample-taxonomy.git ~/.local/share/instructlab/taxonomy/
ilab config init --profile <path-to-system-profile>
ilab config init --profile ~/.local/share/instructlab/internal/system_profiles/amd/mi300x/mi300x_x8.yaml
├─ ~/.config/instructlab/config.yaml 1 ├─ ~/.cache/instructlab/models/ 2 ├─ ~/.local/share/instructlab/datasets 3 ├─ ~/.local/share/instructlab/taxonomy 4 ├─ ~/.local/share/instructlab/phased/<phase1-or-phase2>/checkpoints/ 5
ilab config show
ilab config edit
ilab model download --repository docker://registry.redhat.io/rhelai1/knowledge-adapter-v3 --release latest
ilab model download --repository docker://<repository_and_model> --release <release>
ilab model download --repository docker://registry.redhat.io/rhelai1/granite-8b-starter-v1 --release latest
ilab model list
+-----------------------------------+---------------------+---------+ | Model Name | Last Modified | Size | +-----------------------------------+---------------------+---------+ | models/prometheus-8x7b-v2-0 | 2024-08-09 13:28:50 | 87.0 GB| | models/mixtral-8x7b-instruct-v0-1 | 2024-08-09 13:28:24 | 87.0 GB| | models/granite-8b-starter-v1 | 2024-08-09 14:28:40 | 16.6 GB| | models/granite-8b-lab-v1 | 2024-08-09 14:40:35 | 16.6 GB| +-----------------------------------+---------------------+---------+
ls ~/.cache/instructlab/models
granite-8b-starter-v1 granite-8b-lab-v1
ilab model serve
ilab model serve --model-path <model-path>
ilab model serve --model-path ~/.cache/instructlab/models/granite-8b-code-instruct
INFO 2024-03-02 02:21:11,352 lab.py:201 Using model 'models/granite-8b-code-instruct' with -1 gpu-layers and 4096 max context size. Starting server process After application startup complete see http://127.0.0.1:8000/docs for API. Press CTRL+C to shut down the server.
mkdir -p USDHOME/.config/systemd/user
cat << EOF > USDHOME/.config/systemd/user/ilab-serve.service [Unit] Description=ilab model serve service [Install] WantedBy=multi-user.target default.target 1 [Service] ExecStart=ilab model serve --model-family granite Restart=always EOF
systemctl --user daemon-reload
systemctl --user start ilab-serve.service
systemctl --user status ilab-serve.service
journalctl --user-unit ilab-serve.service
sudo loginctl enable-linger
systemctl --user stop ilab-serve.service
mkdir -p `pwd`/nginx/ssl/
cat > openssl.cnf <<EOL [ req ] default_bits = 2048 distinguished_name = <req-distinguished-name> 1 x509_extensions = v3_req prompt = no [ req_distinguished_name ] C = US ST = California L = San Francisco O = My Company OU = My Division CN = rhelai.redhat.com [ v3_req ] subjectAltName = <alt-names> 2 basicConstraints = critical, CA:true subjectKeyIdentifier = hash authorityKeyIdentifier = keyid:always,issuer [ alt_names ] DNS.1 = rhelai.redhat.com 3 DNS.2 = www.rhelai.redhat.com 4
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout `pwd`/nginx/ssl/rhelai.redhat.com.key -out `pwd`/nginx/ssl/rhelai.redhat.com.crt -config openssl.cnf
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout
mkdir -p `pwd`/nginx/conf.d echo 'server { listen 8443 ssl; server_name <rhelai.redhat.com> 1 ssl_certificate /etc/nginx/ssl/rhelai.redhat.com.crt; ssl_certificate_key /etc/nginx/ssl/rhelai.redhat.com.key; location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host USDhost; proxy_set_header X-Real-IP USDremote_addr; proxy_set_header X-Forwarded-For USDproxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto USDscheme; } } ' > `pwd`/nginx/conf.d/rhelai.redhat.com.conf
podman run --net host -v `pwd`/nginx/conf.d:/etc/nginx/conf.d:ro,Z -v `pwd`/nginx/ssl:/etc/nginx/ssl:ro,Z nginx
ilab model chat -m /instructlab/instructlab/granite-7b-redhat-lab --endpoint-url
curl --location 'https://rhelai.redhat.com:8443/v1' --header 'Content-Type: application/json' --header 'Authorization: Bearer <api-key>' --data '{ "model": "/var/home/cloud-user/.cache/instructlab/models/granite-7b-redhat-lab", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Hello!" } ] }' | jq .
openssl s_client -connect rhelai.redhat.com:8443 </dev/null 2>/dev/null | openssl x509 -outform PEM > server.crt
sudo cp server.crt /etc/pki/ca-trust/source/anchors/
sudo update-ca-trust
cat server.crt >> USD(python -m certifi)
ilab model chat -m /instructlab/instructlab/granite-7b-redhat-lab --endpoint-url https://rhelai.redhat.com:8443/v1
ilab model chat
ilab model chat --model <model-path>
ilab model chat --model ~/.cache/instructlab/models/granite-8b-code-instruct
ilab model chat ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── system ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Welcome to InstructLab Chat w/ GRANITE-8B-CODE-INSTRUCT (type /h for help) │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ >>> [S][default]
export VLLM_API_KEY=USD(python -c 'import secrets; print(secrets.token_urlsafe())')
echo USDVLLM_API_KEY
ilab config edit
serve: vllm: vllm_args: - --api-key - <api-key-string>
ilab model chat
openai.AuthenticationError: Error code: 401 - {'error': 'Unauthorized'}
ilab model chat -m granite-7b-redhat-lab --endpoint-url https://inference.rhelai.com/v1 --api-key USDVLLM_API_KEY
ilab model chat ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── system ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Welcome to InstructLab Chat w/ GRANITE-7B-LAB (type /h for help) │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ >>> [S][default]