Skip to content

Commit a98f4b7

Browse files
authored
Merge pull request #492 from Gregory-Pereira/apiserver-install-script
installing the RHEL-AI api-server via script
2 parents 6e5fd0e + 512c06c commit a98f4b7

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed

api-server/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ go run main.go --taxonomy-path ~/.local/share/instructlab/taxonomy/ --rhelai --c
4444
The `--rhelai` flag indicates that the ilab binary is available in the system's $PATH and does not require a virtual environment.
4545
When using `--rhelai`, the `--base-dir` flag is not required since it will be in a known location at least for meow.
4646

47+
#### RHELAI API server easy-install
48+
49+
It is recommended that you make a temporary directory for yourself to facilitate the install: `mkdir -p ~/temp-apiserver-install && cd ~/temp-apiserver-install`.
50+
51+
We have provided some scripts that should facilitate installation of the API server on RHEL-AI. First, we will download and run a script to install `glibc-devel` as a dependency and reboot the system.
52+
53+
```bash
54+
bash -c "$(curl -fsSL https://raw.githubusercontent.com/instructlab/ui/refs/heads/main/api-server/rhelai-install/install-glibc-devel.sh)"
55+
```
56+
57+
After the reboot has finished we can download the other two install scripts and run the `rhelai-install.sh` as the entrypoint. Make sure to return to your directory before you start:
58+
59+
```bash
60+
cd ~/temp-apiserver-install
61+
curl -fsSL https://raw.githubusercontent.com/instructlab/ui/refs/heads/main/api-server/rhelai-install/install-go.sh
62+
bash -c "$(curl -fsSL https://raw.githubusercontent.com/instructlab/ui/refs/heads/main/api-server/rhelai-install/rhelai-install.sh)"
63+
```
64+
65+
After this, we can cleanup our temp directory as it is no longer required: `rm -rf ~/temp-apiserver-install`.
66+
4767
### Example command with paths
4868

4969
Here's an example command for running the server on a macOS machine with Metal support:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
# -*- indent-tabs-mode: nil; tab-width: 2; sh-indentation: 2; -*-
3+
4+
# Dependency installations for RHELAI APIserver install
5+
6+
set -x
7+
set -e
8+
set -o pipefail
9+
10+
echo "Installing \`glibc-devel\` as a dependency of \`cgo\`."
11+
sudo rpm-ostree install glibc-devel
12+
echo "export CGO_ENABLED=1" >> ~/.bashrc
13+
14+
echo "The system needs to be rebooted for \`glibc-devel\` to be installed. Re-booting."
15+
sudo systemctl reboot
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
# -*- indent-tabs-mode: nil; tab-width: 2; sh-indentation: 2; -*-
3+
4+
# Dependency installations for RHELAI APIserver install
5+
6+
GO_VERSION="1.23.5"
7+
GO_ARCHIVE="go${GO_VERSION}.linux-amd64.tar.gz"
8+
GO_URL="https://go.dev/dl/${GO_ARCHIVE}"
9+
INSTALL_DIR="$HOME/.go"
10+
PATH_EXPORT="export PATH=\$PATH:${INSTALL_DIR}/bin"
11+
12+
for cmd in curl tar; do
13+
if ! command -v "$cmd" >/dev/null 2>&1; then
14+
echo "Error: '$cmd' is not installed. Please install it and retry."
15+
exit 1
16+
fi
17+
done
18+
19+
echo "Downloading Go ${GO_VERSION}..."
20+
curl -LO "$GO_URL"
21+
22+
mkdir -p "$INSTALL_DIR"
23+
24+
tar --strip-components=1 -C "$INSTALL_DIR" -xzf "$GO_ARCHIVE"
25+
26+
rm "$GO_ARCHIVE"
27+
28+
# Export PATH in current shell
29+
export PATH="$PATH:${INSTALL_DIR}/bin"
30+
echo "Go bin directory added to PATH for the current session."
31+
32+
# Add PATH export to ~/.bashrc if not already present
33+
grep -qxF "$PATH_EXPORT" "$HOME/.bashrc" || echo "$PATH_EXPORT" >> "$HOME/.bashrc"
34+
echo "Go bin directory added to PATH in ~/.bashrc."
35+
36+
# Verify
37+
go version
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# -*- indent-tabs-mode: nil; tab-width: 2; sh-indentation: 2; -*-
3+
4+
# Install script for the API server
5+
## dependencies: go, git
6+
7+
set -x
8+
set -e
9+
set -o pipefail
10+
11+
### installations
12+
13+
if [ -z "$(command -v git)" ]; then
14+
echo "please make sure \`git\` is installed."
15+
exit 1
16+
fi
17+
18+
if [ -z "$(command -v go)" ]; then
19+
echo "\`go\` is not installed, installing."
20+
./install-go.sh
21+
fi
22+
23+
if [ -z "$TAXONOMY_PATH" ]; then
24+
echo "Var \$TAXONOMY_PATH was not set, using default path: $HOME/.local/share/instructlab/taxonomy."
25+
export TAXONOMY_PATH="$HOME/.local/share/instructlab/taxonomy"
26+
fi
27+
28+
if [ ! -d "$TAXONOMY_PATH" ]; then
29+
echo "\$TAXONOMY_PATH was set as $TAXONOMY_PATH, but path does not exist."
30+
exit 1
31+
fi
32+
33+
### script
34+
35+
if [ -d "/tmp/ui" ]; then
36+
rm -rf /tmp/ui
37+
fi
38+
39+
git clone https://github.com/instructlab/ui.git /tmp/ui
40+
cd /tmp/ui/api-server
41+
go mod download
42+
go build -o ilab-api-router
43+
44+
CUDA_FLAG=""
45+
46+
if [ "$(command -v nvcc)" ] && [ -n "$(nvcc --version)" ]; then
47+
CUDA_FLAG="--cuda"
48+
fi
49+
50+
./ilab-api-router --taxonomy-path "$TAXONOMY_PATH" $CUDA_FLAG --rhelai --vllm

0 commit comments

Comments
 (0)