Skip to content

Commit 6ed2940

Browse files
tylertitsworthyoukaichao
authored andcommitted
[Bugfix][Intel] Fix XPU Dockerfile Build (vllm-project#7824)
Signed-off-by: tylertitsworth <[email protected]> Co-authored-by: youkaichao <[email protected]> Signed-off-by: Alvant <[email protected]>
1 parent 269ba84 commit 6ed2940

9 files changed

+87
-14
lines changed

.buildkite/run-xpu-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ trap remove_docker_container EXIT
1111
remove_docker_container
1212

1313
# Run the image and launch offline inference
14-
docker run --network host --name xpu-test --device /dev/dri -v /dev/dri/by-path:/dev/dri/by-path xpu-test python3 examples/offline_inference.py
14+
docker run --network host --name xpu-test --device /dev/dri -v /dev/dri/by-path:/dev/dri/by-path --entrypoint="" xpu-test python3 examples/offline_inference.py

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
vllm/*.so
1+
/.github/
22
/.venv
33
/build
44
dist
5+
Dockerfile*
6+
vllm/*.so

Dockerfile.xpu

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM intel/oneapi-basekit:2024.2.1-0-devel-ubuntu22.04
1+
FROM intel/oneapi-basekit:2024.2.1-0-devel-ubuntu22.04 AS vllm-base
22

33
RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | tee /usr/share/keyrings/intel-oneapi-archive-keyring.gpg > /dev/null && \
44
echo "deb [signed-by=/usr/share/keyrings/intel-oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main " | tee /etc/apt/sources.list.d/oneAPI.list && \
@@ -7,20 +7,49 @@ RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRO
77
echo "deb [arch=amd64,i386 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/graphics/ubuntu jammy arc" | tee /etc/apt/sources.list.d/intel.gpu.jammy.list && \
88
chmod 644 /usr/share/keyrings/intel-graphics.gpg
99

10-
RUN apt-get update -y && \
11-
apt-get install -y curl libicu70 lsb-release git wget vim numactl python3 python3-pip ffmpeg libsm6 libxext6 libgl1
12-
13-
COPY ./ /workspace/vllm
10+
RUN apt-get update -y && \
11+
apt-get install -y --no-install-recommends --fix-missing \
12+
curl \
13+
ffmpeg \
14+
git \
15+
libsndfile1 \
16+
libsm6 \
17+
libxext6 \
18+
libgl1 \
19+
lsb-release \
20+
numactl \
21+
python3 \
22+
python3-dev \
23+
python3-pip \
24+
# vim \
25+
wget
1426

1527
WORKDIR /workspace/vllm
28+
COPY requirements-xpu.txt /workspace/vllm/requirements-xpu.txt
29+
COPY requirements-common.txt /workspace/vllm/requirements-common.txt
1630

1731
RUN --mount=type=cache,target=/root/.cache/pip \
18-
pip install -v --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/ \
19-
cmake>=3.26 ninja packaging setuptools-scm>=8 wheel jinja2 \
20-
-r requirements-xpu.txt
32+
pip install --no-cache-dir \
33+
--extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/ \
34+
-r requirements-xpu.txt
35+
36+
COPY ./ /workspace/vllm
37+
38+
ENV VLLM_TARGET_DEVICE=xpu
2139

2240
RUN --mount=type=cache,target=/root/.cache/pip \
2341
--mount=type=bind,source=.git,target=.git \
24-
VLLM_TARGET_DEVICE=xpu python3 setup.py install
42+
python3 setup.py install
2543

2644
CMD ["/bin/bash"]
45+
46+
FROM vllm-base AS vllm-openai
47+
48+
# install additional dependencies for openai api server
49+
RUN --mount=type=cache,target=/root/.cache/pip \
50+
pip install accelerate hf_transfer 'modelscope!=1.15.0'
51+
52+
ENV VLLM_USAGE_SOURCE production-docker-image \
53+
TRITON_XPU_PROFILE 1
54+
55+
ENTRYPOINT ["python3", "-m", "vllm.entrypoints.openai.api_server"]

requirements-common.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
psutil
22
sentencepiece # Required for LLaMA tokenizer.
33
numpy < 2.0.0
4-
requests
4+
requests >= 2.26.0
55
tqdm
66
py-cpuinfo
77
transformers >= 4.45.0 # Required for Llama 3.2.

requirements-xpu.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Common dependencies
22
-r requirements-common.txt
33

4-
setuptools < 70.0.0 # IPEX's torch have some dependency. to be removed.
5-
64
ray >= 2.9
5+
cmake>=3.26
6+
ninja
7+
packaging
8+
setuptools-scm>=8
9+
wheel
10+
jinja2
711
# Following pkgs retrieved from https://pytorch-extension.intel.com/release-whl/stable/xpu/us/
812
torch == 2.3.1+cxx11.abi
913
intel-extension-for-pytorch == 2.3.110+xpu

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ def _read_requirements(filename: str) -> List[str]:
415415
for line in requirements:
416416
if line.startswith("-r "):
417417
resolved_requirements += _read_requirements(line.split()[1])
418+
elif line.startswith("--"):
419+
continue
418420
else:
419421
resolved_requirements.append(line)
420422
return resolved_requirements

vllm/platforms/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@
4242
except Exception:
4343
pass
4444

45+
is_xpu = False
46+
47+
try:
48+
import torch
49+
if hasattr(torch, 'xpu') and torch.xpu.is_available():
50+
is_xpu = True
51+
except Exception:
52+
pass
53+
4554
is_cpu = False
4655
try:
4756
from importlib.metadata import version
@@ -60,6 +69,9 @@
6069
elif is_rocm:
6170
from .rocm import RocmPlatform
6271
current_platform = RocmPlatform()
72+
elif is_xpu:
73+
from .xpu import XPUPlatform
74+
current_platform = XPUPlatform()
6375
elif is_cpu:
6476
from .cpu import CpuPlatform
6577
current_platform = CpuPlatform()

vllm/platforms/interface.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class PlatformEnum(enum.Enum):
88
CUDA = enum.auto()
99
ROCM = enum.auto()
1010
TPU = enum.auto()
11+
XPU = enum.auto()
1112
CPU = enum.auto()
1213
UNSPECIFIED = enum.auto()
1314

@@ -41,6 +42,9 @@ def is_rocm(self) -> bool:
4142
def is_tpu(self) -> bool:
4243
return self._enum == PlatformEnum.TPU
4344

45+
def is_xpu(self) -> bool:
46+
return self._enum == PlatformEnum.XPU
47+
4448
def is_cpu(self) -> bool:
4549
return self._enum == PlatformEnum.CPU
4650

vllm/platforms/xpu.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import torch
2+
3+
from .interface import DeviceCapability, Platform, PlatformEnum
4+
5+
6+
class XPUPlatform(Platform):
7+
_enum = PlatformEnum.XPU
8+
9+
@staticmethod
10+
def get_device_capability(device_id: int = 0) -> DeviceCapability:
11+
return DeviceCapability(major=int(
12+
torch.xpu.get_device_capability(device_id)['version'].split('.')
13+
[0]),
14+
minor=int(
15+
torch.xpu.get_device_capability(device_id)
16+
['version'].split('.')[1]))
17+
18+
@staticmethod
19+
def get_device_name(device_id: int = 0) -> str:
20+
return torch.xpu.get_device_name(device_id)

0 commit comments

Comments
 (0)