Skip to content

Commit

Permalink
Merge pull request #4 from slim-abid/main
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufcanb committed Feb 27, 2024
2 parents a32466f + 0cb9fff commit e1349ca
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 46 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Yusuf Can Bayrak
Yusuf Can Bayrak
Slim Abid
103 changes: 58 additions & 45 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/bin/bash

set -eu

status() { echo ">>> $*" >&2; }
error() { echo "ERROR $*"; }
warning() { echo "WARNING: $*"; }


# OS and Architecture Detection
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
os="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
os="darwin"
else
echo "Unsupported operating system. Only Linux and macOS are currently supported."
error "Unsupported operating system. Only Linux and macOS are currently supported."
exit 1
fi

Expand All @@ -15,7 +22,7 @@ if [[ "$(uname -m)" == "x86_64" ]]; then
elif [[ "$(uname -m)" == "aarch64" || "$(uname -m)" == "arm64" ]]; then
arch="arm64"
else
echo "Unsupported architecture. tlm requires a 64-bit system (x86_64 or arm64)."
error "Unsupported architecture. tlm requires a 64-bit system (x86_64 or arm64)."
exit 1
fi

Expand All @@ -26,77 +33,83 @@ download_url="${base_url}/${version}/tlm_${version}_${os}_${arch}"

# Docker check
if ! command -v docker &>/dev/null; then
echo "Docker not found. Please install Docker from https://www.docker.com/get-started"
error "Docker not found. Please install Docker from https://www.docker.com/get-started"
exit 1
fi

# Ollama check
if ! curl -fsSL http://localhost:11434 &> /dev/null; then
echo "Ollama not found."
error "Ollama not found."
if [[ "$os" == "darwin" ]]; then
echo ""
echo "*** On macOS: ***"
echo ""
echo "Ollama can run with GPU acceleration inside Docker containers for Nvidia GPUs."
echo "To get started using the Docker image, please follow these steps:"
echo ""
echo "1. *** CPU only: ***"
echo " docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama"
echo ""
echo "2. *** GPU Acceleration: ***"
echo " This option requires running Ollama outside of Docker"
echo " To get started, simply download and install Ollama."
echo " https://ollama.com/download"
echo ""
echo ""
echo "Installation aborted. Please install Ollama using the methods above and try again."
status ""
status "*** On macOS: ***"
status ""
status "Ollama can run with GPU acceleration inside Docker containers for Nvidia GPUs."
status "To get started using the Docker image, please follow these steps:"
status ""
status "1. *** CPU only: ***"
status " docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama"
status ""
status "2. *** GPU Acceleration: ***"
status " This option requires running Ollama outside of Docker"
status " To get started, simply download and install Ollama."
status " https://ollama.com/download"
status ""
status ""
status "Installation aborted. Please install Ollama using the methods above and try again."
exit 1

elif [[ "$os" == "linux" ]]; then
echo ""
echo "*** On Linux: ***"
echo ""
echo "Ollama can run with GPU acceleration inside Docker containers for Nvidia GPUs."
echo "To get started using the Docker image, please follow these steps:"
echo ""
echo "1. *** CPU only: ***"
echo " docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama"
echo ""
echo "2. *** Nvidia GPU: ***"
echo " docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama"
echo ""
echo ""
echo "Installation aborted. Please install Ollama using the methods above and try again."
status ""
status "*** On Linux: ***"
status ""
status "Ollama can run with GPU acceleration inside Docker containers for Nvidia GPUs."
status "To get started using the Docker image, please follow these steps:"
status ""
status "1. *** CPU only: ***"
status " docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama"
status ""
status "2. *** Nvidia GPU: ***"
status " docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama"
status ""
status ""
status "Installation aborted. Please install Ollama using the methods above and try again."
exit 1

fi
fi

# Download the binary
echo "Downloading tlm version ${version} for ${os}/${arch}..."
status "Downloading tlm version ${version} for ${os}/${arch}..."
if ! curl -fsSL -o tlm ${download_url}; then
echo "Download failed. Please check your internet connection and try again."
error "Download failed. Please check your internet connection and try again."
exit 1
fi

# Make executable
chmod +x tlm

# Move to installation directory
echo "Installing tlm..."
if ! mv tlm /usr/local/bin/; then
echo "Installation requires administrator permissions. Please use sudo or run the script as root."
exit 1
else
echo ""
status "Installing tlm..."

SUDO=
if [ "$(id -u)" -ne 0 ]; then
# Running as root, no need for sudo
if ! available sudo; then
error "This script requires superuser permissions. Please re-run as root."
fi

SUDO="sudo"
fi

$SUDO mv tlm /usr/local/bin/;

if ! tlm deploy; then
echo ""
error ""
exit 1
else
echo ""
status ""
fi

echo "Type 'tlm' to get started."
status "Type 'tlm' to get started."
exit 0

0 comments on commit e1349ca

Please sign in to comment.