Skip to content

Add dockerfile for Intel XPU #1668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docker/Dockerfile.xpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM intel/oneapi-basekit:2025.0.1-0-devel-ubuntu22.04 AS base
SHELL ["/bin/bash", "-c"]

ARG PYTHON_VER=3.11
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get remove -y python3.10 && apt-get autoremove -y
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y python$PYTHON_VER python$PYTHON_VER-dev python3-pip && \
ln -sf /usr/bin/python$PYTHON_VER /usr/bin/python3 && \
ln -sf /usr/bin/python3 /usr/bin/python && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get -y install apt-utils build-essential \
git vim numactl python3-dev wget google-perftools && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade pip
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/xpu --no-cache-dir
RUN pip install -U transformers accelerate peft pytest

# install bitsandbytes
RUN git clone https://github.com/bitsandbytes-foundation/bitsandbytes.git && cd bitsandbytes/ && \
pip install . && cd ../

RUN touch /entrypoint.sh
RUN chmod +x /entrypoint.sh
RUN echo "#!/bin/bash" >> /entrypoint.sh
RUN echo "/bin/bash" >> /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
12 changes: 11 additions & 1 deletion docs/source/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,19 @@ You can install the pre-built wheels for each backend, or compile from source fo

<hfoptions id="platform">
<hfoption id="Linux">
This wheel provides support for ROCm and Intel XPU platforms.
This wheel provides support for ROCm platforms.

```
# Note, if you don't want to reinstall our dependencies, append the `--no-deps` flag!
pip install --force-reinstall 'https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_multi-backend-refactor/bitsandbytes-0.44.1.dev0-py3-none-manylinux_2_24_x86_64.whl'
```

This wheel provides support for Intel XPU platforms.
```
# Note, if you don't want to reinstall our dependencies, append the `--no-deps` flag!
pip install --force-reinstall https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-manylinux_2_24_x86_64.whl --extra-index-url https://download.pytorch.org/whl/test/xpu
```

</hfoption>
<hfoption id="Windows">
This wheel provides support for the Intel XPU platform.
Expand Down Expand Up @@ -241,9 +247,11 @@ pip install -e . # `-e` for "editable" install, when developing BNB (otherwise
If you are using Intel CPU on Linux or Intel XPU on Linux/Windows, please follow the [instruction](https://pytorch-extension.intel.com/) or the following command to install intel_extension_for_pytorch so you can get better performance.

CPU: `pip install intel_extension_for_pytorch`

XPU: `pip install intel_extension_for_pytorch --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/`

Install bitsandbytes:

CPU: Need to build CPU C++ codes
```
git clone https://github.com/bitsandbytes-foundation/bitsandbytes.git && cd bitsandbytes/
Expand All @@ -256,6 +264,8 @@ XPU:
pip install git+https://github.com/bitsandbytes-foundation/bitsandbytes.git
```

You can also use docker by `docker build -f docker/Dockerfile.xpu -t bnb-xpu .` on XPU.

</hfoption>
<hfoption id="Ascend NPU">

Expand Down