阿里云部署LLM模型命令

推荐使用 Ubuntu 22.04,相比 CentOS 环境更完整,需要配置的地方更少。

# 更新 apt
apt update

# 获取并安装 Anaconda
wget https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh
chmod +x Anaconda3-2024.02-1-Linux-x86_64.sh
./Anaconda3-2024.02-1-Linux-x86_64.sh

# 启用 Anaconda
export PATH=/root/anaconda3/bin:$PATH
conda init
source ~/.bashrc

# 创建 python3.8 的虚拟环境
conda activate base
conda create -n llm python=3.8

# 安装 huggingface_hub
pip install huggingface_hub

# 配置HF镜像地址
export HF_ENDPOINT=https://hf-mirror.com

# 使用 HF 下载 LLAMA3 模型(找了个无限制词的)
huggingface-cli download QuantFactory/DarkIdol-Llama-3.1-8B-Instruct-1.2-Uncensored-GGUF DarkIdol-Llama-3.1-8B-Instruct-1.2-Uncensored.Q4_K_M.gguf  --local-dir . --local-dir-use-symlinks False

# 获取 koboldcpp
wget https://github.com/LostRuins/koboldcpp/releases/download/v1.76/koboldcpp-linux-x64-cuda1210

# 使用 koboldcpp 启动模型
nohup ./koboldcpp --model DarkIdol-Llama-3.1-8B-Instruct-1.2-Uncensored.Q4_K_M.gguf --contextsize 8192 --port 8080 --threads 16 --usecublas > /dev/null 2>&1 &