Ollama 설치 및 사용방법

AI 2025. 11. 6. 10:18
반응형

Ollama는 로컬에서 대형 언어 모델(LLM) 을 실행할 수 있는 도구입니다.

즉, ChatGPT나 Claude처럼 클라우드 연결 없이 내 PC에서 직접 LLM을 구동할 수 있습니다.

 

1. Ollama 주요 특징

항목설명

지원 OS macOS, Windows, Linux
지원 모델 Llama 3, Mistral, Gemma, Phi, CodeLlama 등
인터넷 연결 최초 다운로드 시만 필요 (이후 오프라인 사용 가능)
API 호환성 http://localhost:11434 REST API 제공
활용 예시 ChatGPT 대체, 로컬 챗봇, 코딩 어시스턴트, ComfyUI·LM Studio 연동

 

2. 설치 방법

 

macOS

1) Homebrew로 설치
Homebrew가 없으면 설치

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

ollama 설치

brew install ollama

2) 설치 확인

ollama --version

3) 실행

ollama serve

서버가 http://localhost:11434 에서 실행됩니다.

 

Windows

1) 공식 사이트에서 설치 파일 다운로드

https://ollama.com/download

2) 설치 진행

  • .exe 파일을 실행하고 지시에 따라 설치합니다.
  • 설치 후 자동으로 Ollama 서버(ollama.exe)가 실행됩니다.

3) 명령 프롬프트 또는 PowerShell에서 버전 확인

ollama --version

 

Linux (Ubuntu 기준)

1) 설치 스크립트 실행

curl -fsSL https://ollama.com/install.sh | sh

2) 실행

ollama serve

 

3. 모델 다운로드 및 실행

 

모델 목록 보기

ollama list

 

모델 다운로드 및 실행 예시

(Llama 3.1 모델 실행)

ollama run llama3.1

(Gemma 2 모델 실행)

ollama run gemma2

(Mistral 모델 실행)

ollama run mistral

처음 실행 시 모델이 자동 다운로드되며, 약 4~8GB의 용량을 차지합니다.

 

4. Ollama 사용 예시

 

단순 대화

ollama run llama3.1
> 안녕! 너는 뭐하는 모델이야?

 

한 줄로 질문하기

ollama run llama3.1 "한국에서 Ollama 설치 방법 요약해줘"

 

멈추기

Ctrl + C 로 종료합니다.

 

5. Ollama + 다른 프로그램 연동

 

ComfyUI 연결

  • ComfyUI 설치 후 comfyui-ollama 노드 추가
  • Ollama 실행 중이어야 함 (ollama serve)
  • 설정에서 모델 이름을 예: llama3.1 로 지정
  • “Reasoning/Thinking not supported (400)” 오류 발생 시 → thinking 옵션 OFF

 

VS Code / Cursor 통합

  • Cursor 또는 VS Code 플러그인 중 "Continue" 혹은 "ChatGPT for Ollama" 설치
  • 설정에서 API URL을 http://localhost:11434 로 지정
  • 이후 “ollama” 모델 선택 → 로컬에서 AI 코딩 지원 가능

 

API 직접 사용

curl 또는 Python 등으로 REST 요청 가능:

curl http://localhost:11434/api/generate -d '{
  "model": "llama3.1",
  "prompt": "Explain how to use Ollama"
}'

Python 예시:

import requests, json

url = http://localhost:11434/api/generate
data = {model: llama3.1, prompt: 한국에서 Ollama 설치 요약}
response = requests.post(url, json=data, stream=True)
for line in response.iter_lines():
if line:
print(json.loads(line)[response], end=”“)

 

6. 모델 관리 명령어

명령어설명

ollama list 설치된 모델 목록 확인
ollama pull <모델명> 새 모델 다운로드
ollama run <모델명> 모델 실행
ollama rm <모델명> 모델 삭제
ollama serve 서버 수동 실행
ollama ps 실행 중인 모델 확인
ollama stop <모델명> 특정 모델 세션 중단

 

7. 자주 발생하는 문제

문제원인 및 해결

400 does not support thinking 모델이 “Reasoning 모드” 비지원 → “thinking 옵션” 끄기
모델 다운로드 느림 VPN 사용 또는 수동 다운로드 (Ollama Hub 미러 사용)
포트 충돌 다른 서비스가 11434 사용 중 → OLLAMA_HOST=127.0.0.1:11500 ollama serve
메모리 부족 최소 8GB RAM 필요, Llama 3.1 8B 모델 이상은 16GB 이상 권장

 

8. 추천 모델 리스트

모델명특징크기용도

Llama 3.1:8B Meta의 범용 모델, 한글 지원 우수 약 4.7GB 일반 대화, 코딩
Gemma 2:9B Google 모델, 빠르고 자연스러움 약 5GB 요약/글쓰기
Mistral 7B 속도 빠름, 가벼운 작업용 약 4GB 로컬 채팅
Phi 3 mini 초경량 모델 1.8GB 저사양 PC용
CodeLlama 프로그래밍 특화 6~8GB 개발용

 

9. 고급 사용

Modelfile 예시:

Modelfile
FROM llama3.1
SYSTEM 당신은 친절한 한국어 비서입니다.
PARAMETER temperature 0.7

실행:
bash
ollama create mybot -f Modelfile
ollama run mybot

 

10. 요약

구분명령어

설치 brew install ollama / curl -fsSL https://ollama.com/install.sh | sh / 설치파일
실행 ollama serve
모델 실행 ollama run llama3.1
모델 관리 ollama list, ollama pull, ollama rm
API http://localhost:11434/api/...
연동 ComfyUI, Cursor, VSCode, LM Studio 등

 

반응형
Posted by 까칠코더
,