GGUF 파일을 Llama.cpp 도구로 실행하는 방법
Ubuntu 24.04 기준으로 작성하였습니다.
모델 다운로드 디렉토리(/data/Llama4/Q4_K_M/)는 임의로 정하였습니다.
1. 모델 다운로드
모델은 기본적으로 파일 사이즈가 크므로, 용량이 넉넉한 디렉토리를 선택해야 합니다.
# mkdir -p /data/Llama4/Q4_K_M
# cd /data/Llama4/Q4_K_M
# wget https://huggingface.co/unsloth/Llama-4-Scout-17B-16E-Instruct-GGUF/resolve/main/Q4_K_M/Llama-4-Scout-17B-16E-Instruct-Q4_K_M-0000{1..2}-of-00002.gguf
2. Llama.cpp 다운로드
Llama.cpp 는 모델을 간단히 가동, 병합, 양자화 등을 할 수 있는 도구 입니다.
# apt -y install cmake libopenblas-dev g++ libcurl4-openssl-dev
# git clone https://github.com/ggerganov/llama.cpp.git
# cd llama.cpp
# mkdir build
# cd build
# cmake ..
# cmake --build . --config Release
3. 분할된 파일 합치기
# cd bin
# ./llama-gguf-split --merge \
/data/Llama4/Q4_K_M/Llama-4-Scout-17B-16E-Instruct-Q4_K_M-00001-of-00002.gguf \
/data/Llama4/Q4_K_M/Llama-4-Scout-17B-16E-Instruct-Q4_K_M.gguf
4. LLM 실행
1) 로컬 질의
로컬에서 간단히 실행하고 질의합니다.
# ./llama-cli -m /data/Llama4/Q4_K_M/Llama-4-Scout-17B-16E-Instruct-Q4_K_M.gguf -p "오늘은 며칠이야?"
2) API 사용
API를 사용해 외부 네트워크에서도 접근 허용합니다.
# ./llama-server -m /data/Llama4/Q4_K_M/Llama-4-Scout-17B-16E-Instruct-Q4_K_M.gguf --host 0.0.0.0 --port 8080
다음과 같이 다른 터미널이나 외부 네트워크의 시스템에서 질의해 봅니다.
# apt -y install jq
# curl http://{서버IP}:8080/completion -H "Content-Type: application/json" -d '{
"prompt": "오늘은 며칠이야?",
"n_predict": 100
}' | jq
'AI' 카테고리의 다른 글
LLM 파일 형식 변환하기 (Safetensors to GGUF) (0) | 2025.04.28 |
---|---|
Ubuntu 24.04 에서 BitNet 1-bit LLM 설치 및 사용하기 (0) | 2025.04.23 |
Ubuntu 24.04 에서 그래픽카드 (GPU) 선택적 비활성화 하기 (0) | 2025.04.14 |
AMD Radeon w6800 + Ollama + DeepSeek-R1:70B 사용하기 (0) | 2025.02.21 |
RTX 4090 + Ubuntu 24.04 + (Llama 3.2-3B & 한국어 언어 모델) 설치하기 (0) | 2024.12.27 |