Created
May 15, 2024 14:48
-
-
Save fpaupier/4f95bf6e348bf5f06b8c9349a2fbed66 to your computer and use it in GitHub Desktop.
Initializes a GPU machine to start a vLLM server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script initializes a GPU machine to start a vLLM server | |
# Ensure the script is run as root | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
# Update and install necessary packages | |
echo "Updating system packages..." | |
sudo apt update && sudo apt install python3.10-venv tmux -y || { echo "Failed to install required packages"; exit 1; } | |
# Clone the project repository | |
echo "Cloning the project repository..." | |
mkdir -p projects && cd projects || exit | |
# Set up Python virtual environment | |
echo "Setting up Python virtual environment..." | |
python3.10 -m venv .venv || { echo "Failed to create Python virtual environment"; exit 1; } | |
source .venv/bin/activate | |
pip install vllm || { echo "Failed to install vllm"; exit 1; } | |
# Configure and start the vLLM server | |
echo "Starting vLLM server..." | |
export VLLM_NO_USAGE_STATS=1 | |
export DO_NOT_TRACK=1 | |
mkdir -p ~/.config/vllm && touch ~/.config/vllm/do_not_track | |
# Check if required environment variables are set | |
if [ -z "$VLLM_PORT" ] || [ -z "$VLLM_API_KEY" ] || [ -z "$VLLM_MODEL" ]; then | |
echo "Error: Required environment variables are not set." | |
exit 1 | |
fi | |
# Start the server in a new tmux session | |
tmux new -s vllm -d "python -m vllm.entrypoints.openai.api_server \ | |
--model $VLLM_MODEL \ | |
--dtype auto \ | |
--api-key $VLLM_API_KEY \ | |
--gpu-memory-utilization 0.9 \ | |
--port $VLLM_PORT" | |
echo "vLLM server started successfully in tmux session 'vllm'." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment