본문 바로가기
C.W.K.
Stream
Lesson 01 of 06 · published

설치, 그리고 백엔드 셋의 현실

~25 min · transformers, install

Level 0스카우트
0 XP0/50 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

라이브러리는 하나, 백엔드는 여럿

transformers는 PyTorch, TensorFlow, JAX/Flax를 지원해. 2026년에 특별한 이유가 없다면 PyTorch가 기본 선택이야. TensorFlow 쪽은 유지보수 중심이고 JAX/Flax는 연구 분야에서 주로 쓰여. Apple Silicon에서는 PyTorch와 MPS로 시작하되, 큰 로컬 추론에서 메모리 효율이 중요하면 별도 생태계인 MLX도 검토해.

  • transformers는 모델 클래스, tokenizer, pipeline을 제공해.
  • torch는 계산 백엔드이므로 CUDA·MPS·CPU 환경에 맞는 wheel을 골라야 해.
  • accelerate는 여러 GPU, 혼합 정밀도, device_map='auto'를 맡아.
  • safetensors는 안전한 가중치 형식이며 최신 Transformers에 함께 들어와.
  • 4·8비트 양자화에는 bitsandbytes, LoRA에는 peft, 데이터에는 datasets를 추가해.

설치가 끝났다는 말은 출력으로 증명해

속도나 장치 문제를 추측하기 전에 transformers-cli env를 실행해. 운영체제, Python·Transformers·PyTorch 버전, CUDA나 MPS 사용 가능 여부, GPU 이름이 한 번에 나와. 환경 문제와 라이브러리 문제를 가르는 첫 증거이므로 버그 보고에도 이 출력을 붙여.

Code

플랫폼별로 transformers 정확하게 깔기·bash
# Linux + CUDA
pip install --upgrade torch  # 시스템 CUDA 버전 매치
pip install --upgrade transformers accelerate safetensors

# macOS Apple Silicon (MPS)
pip install --upgrade torch torchvision torchaudio
pip install --upgrade transformers accelerate safetensors

# 검증
python -c "import torch; print('cuda:', torch.cuda.is_available(), 'mps:', torch.backends.mps.is_available())"
transformers-cli env
최소 smoke test·python
from transformers import pipeline

# 빠른 iteration 위한 tiny BERT. 초 단위 로드.
pipe = pipeline("text-classification", model="prajjwal1/bert-tiny")
print(pipe("Hugging Face is the GitHub of AI."))
# [{'label': 'LABEL_0', 'score': 0.5...}]

External links

Exercise

Fresh venv 셋업. 플랫폼 매치되는 transformers + torch 깔아. transformers-cli env 돌려서 출력 저장. bert-tiny smoke test 돌려. 그다음 meta-llama/Llama-3.2-1B-Instruct (또는 Llama 가 gated 면 1B 급 apache/mit license 모델) 를 pipeline('text-generation', ...) 로 로드해서 짧은 문장 생성.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.