text-embeddings-inference documentation

AMD Instinct GPU(ROCm)에서 TEI 사용

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

AMD Instinct GPU(ROCm)에서 TEI 사용

Text Embeddings Inference는 ROCm를 사용하여 AMD Instinct GPU(MI200, MI300 시리즈)를 지원합니다.

필수 조건

  • 호스트에 ROCm 드라이버가 설치된 AMD Instinct GPU(MI200, MI300 시리즈)

옵션 A: Docker (권장)

AMD GPU에서 TEI를 실행하는 가장 쉬운 방법은 사전 구축된 Docker 이미지를 사용하는 것입니다:

model=BAAI/bge-base-en-v1.5
volume=$PWD/data  # share a volume to avoid re-downloading weights

docker run \
  --device /dev/kfd --device /dev/dri/renderD128 \
  --group-add video \
  --ipc=host \
  -p 8080:80 \
  -v $volume:/data \
  --pull always \
  ghcr.io/huggingface/text-embeddings-inference:rocm-latest \
  --model-id $model --dtype bfloat16

그리고 테스트해 보세요:

curl http://localhost:8080/v1/embeddings \
    -H 'Content-Type: application/json' \
    -d '{
      "input": "What is Deep Learning?",
      "model": "text-embeddings-inference",
      "encoding_format": "float"
    }'

옵션 B: TEI ROCm 이미지에서 소스에서 빌드

TEI를 수정하고 다시 빌드하려면 AMD의 rocm/pytorch 이미지 대신 공식 TEI ROCm 이미지(아래 고정된 이미지)를 기본 환경으로 사용하세요. 해당 이미지는 TEI가 기대하는 PyTorch의 정확한 ROCm 빌드, flash-attn, 계산 커널, 설치된 Python 백엔드를 이미 포함하고 있으므로 PyTorch/의존성 설정을 완전히 생략하고 버전 불일치 문제를 피할 수 있으며, 변경한 부분만 다시 빌드하면 됩니다.

1단계: 컨테이너 시작

체크아웃의 저장소 루트에서 마운트하고 엔트리포인트를 오버라이드하여 셸을 얻습니다. 이미지 다이제스트는 여기에서 사용되는 rocm-latest 빌드를 고정합니다. 다른 TEI 리비전으로 작업할 경우 일치하는 이미지를 선택하세요:

docker run -it --device=/dev/kfd --device=/dev/dri/renderD128 \
  --group-add video --ipc=host --shm-size 8g \
  -v "$PWD:/workspace" -w /workspace \
  --entrypoint bash \
  ghcr.io/huggingface/text-embeddings-inference@sha256:9b3f24f8740d4c3fa656666e07a383a50a9e4f3273d3856980841cd8d45e727f

PyTorch (ROCm), flash-attn, compute kernels, 그리고 text-embeddings-server Python 백엔드는 이미 이 이미지에 설치되어 있으며, 미리 빌드된 text-embeddings-router가 PATH에 있습니다. 아래 단계는 소스를 수정한 후 다시 빌드하는 경우에만 해당합니다.

2단계: Rust 설치(라우터 재빌드에만 필요)

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"

# Required by the router's protobuf build step.
apt-get update && apt-get install -y protobuf-compiler pkg-config libssl-dev

3단계: 소스에서 Rust 라우터 다시 빌드

cargo build --release \
    --no-default-features \
    --features python,http \
    --bin text-embeddings-router

Python 백엔드도 변경한 경우, editable 모드로 다시 설치하기 전에 마운트된 체크아웃에서 protobuf 스텁을 생성하세요. 이미지에 설치된 패키지는 새로 체크아웃한 저장소의 무시 대상인 text_embeddings_server/pb 디렉토리를 채우지 않습니다. 서브셸은 저장소 루트에서 나머지 명령을 유지합니다.

(
  cd backends/python/server
  make gen-server
  pip install --no-deps -e .
)

4단계: 빌드 시작

model=BAAI/bge-base-en-v1.5

./target/release/text-embeddings-router --model-id $model --dtype bfloat16 --port 8080

서버가 준비되면 간단한 embed 요청으로 테스트할 수 있습니다:

curl http://localhost:8080/v1/embeddings \
    -H 'Content-Type: application/json' \
    -d '{
      "input": "What is Deep Learning?",
      "model": "text-embeddings-inference",
      "encoding_format": "float"
    }'

GPU 감지 확인

시작 후 ROCm이 감지되었음을 확인하는 로그 줄이 표시되어야 합니다:

INFO text_embeddings_server::utils::device: ROCm / HIP version: X.Y.Z

Python에서도 확인할 수 있습니다:

import torch
print(torch.cuda.is_available())  # True
print(torch.version.hip)          # e.g. 6.2.12345-...

The input is a single word "Notes". 참고

이것은 진행 중인 작업이며, AMD GPU에 대한 추가 모델 지원 및 최적화된 연산이 곧 제공됩니다.

Update on GitHub