From 61e03eee9cc9d81933f58fb2aec0b42593f60dfa Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Wed, 4 Jun 2025 09:53:20 +0000 Subject: [PATCH 1/9] upstream cpu docker Signed-off-by: jiqing-feng --- docker/Dockerfile.cpu | 37 +++++++++++++++++++++++++++++++++++++ docker/Dockerfile.xpu | 0 2 files changed, 37 insertions(+) create mode 100755 docker/Dockerfile.cpu create mode 100755 docker/Dockerfile.xpu diff --git a/docker/Dockerfile.cpu b/docker/Dockerfile.cpu new file mode 100755 index 000000000..ea3e5a80e --- /dev/null +++ b/docker/Dockerfile.cpu @@ -0,0 +1,37 @@ +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/cpu --no-cache-dir +RUN pip install intel-extension-for-pytorch --no-cache-dir +RUN pip install -U transformers accelerate peft pytest intel-openmp + +# install bitsandbytes +RUN git clone https://github.com/bitsandbytes-foundation/bitsandbytes.git && cd bitsandbytes/ && \ + cmake -DCOMPUTE_BACKEND=cpu -S . && make && pip install . && cd ../ + +ENV LD_PRELOAD=${LD_PRELOAD}:/usr/local/lib/libiomp5.so:/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4 + +RUN touch /entrypoint.sh +RUN chmod +x /entrypoint.sh +RUN echo "#!/bin/bash" >> /entrypoint.sh +RUN echo "/bin/bash" >> /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker/Dockerfile.xpu b/docker/Dockerfile.xpu new file mode 100755 index 000000000..e69de29bb From 8cde5d962821462660e4e2f77ec2f225dfc2dacf Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Wed, 4 Jun 2025 10:35:18 +0000 Subject: [PATCH 2/9] add xpu dockerfile Signed-off-by: jiqing-feng --- docker/Dockerfile.xpu | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docker/Dockerfile.xpu b/docker/Dockerfile.xpu index e69de29bb..68a1ab0f5 100755 --- a/docker/Dockerfile.xpu +++ b/docker/Dockerfile.xpu @@ -0,0 +1,35 @@ +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 intel-extension-for-pytorch --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/ --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"] From 5faf66fc91d5108b8fdc0eeae0883e57dbcec114 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Wed, 4 Jun 2025 12:21:12 +0000 Subject: [PATCH 3/9] fix doc Signed-off-by: jiqing-feng --- docs/source/installation.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/source/installation.mdx b/docs/source/installation.mdx index e61ce4655..7c3d3984e 100644 --- a/docs/source/installation.mdx +++ b/docs/source/installation.mdx @@ -241,9 +241,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/ @@ -256,6 +258,8 @@ XPU: pip install git+https://github.com/bitsandbytes-foundation/bitsandbytes.git ``` +You can also use docker by `docker build -f docker/Dockerfile.cpu -t bnb-cpu .` on CPU or `docker build -f docker/Dockerfile.xpu -t bnb-xpu .` on XPU. + From fb960f93a8f044af5229b1ea921bbcccff420b04 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Wed, 4 Jun 2025 13:58:27 +0000 Subject: [PATCH 4/9] update xpu docs Signed-off-by: jiqing-feng --- docs/source/installation.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/installation.mdx b/docs/source/installation.mdx index 7c3d3984e..05351b383 100644 --- a/docs/source/installation.mdx +++ b/docs/source/installation.mdx @@ -188,15 +188,15 @@ pip install torch --index-url https://download.pytorch.org/whl/rocm6.3/ You can install the pre-built wheels for each backend, or compile from source for custom configurations. -#### Pre-built Wheel Installation (recommended)[[multi-backend-pip]] +#### Pre-built Wheel Installation (recommended) -This wheel provides support for ROCm and Intel XPU platforms. +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_multi-backend-refactor/bitsandbytes-0.44.1.dev0-py3-none-manylinux_2_24_x86_64.whl' +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 ``` From bebde9a77a3518f9a89d2a47ff7305dcf984df99 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Fri, 6 Jun 2025 09:00:58 +0000 Subject: [PATCH 5/9] update Signed-off-by: jiqing-feng --- docker/Dockerfile.cpu | 5 +---- docs/source/installation.mdx | 8 +++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile.cpu b/docker/Dockerfile.cpu index ea3e5a80e..df323a527 100755 --- a/docker/Dockerfile.cpu +++ b/docker/Dockerfile.cpu @@ -20,15 +20,12 @@ RUN apt-get update && apt-get -y install apt-utils build-essential \ RUN pip install --upgrade pip RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu --no-cache-dir -RUN pip install intel-extension-for-pytorch --no-cache-dir -RUN pip install -U transformers accelerate peft pytest intel-openmp +RUN pip install -U transformers accelerate peft pytest # install bitsandbytes RUN git clone https://github.com/bitsandbytes-foundation/bitsandbytes.git && cd bitsandbytes/ && \ cmake -DCOMPUTE_BACKEND=cpu -S . && make && pip install . && cd ../ -ENV LD_PRELOAD=${LD_PRELOAD}:/usr/local/lib/libiomp5.so:/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4 - RUN touch /entrypoint.sh RUN chmod +x /entrypoint.sh RUN echo "#!/bin/bash" >> /entrypoint.sh diff --git a/docs/source/installation.mdx b/docs/source/installation.mdx index 05351b383..f81948604 100644 --- a/docs/source/installation.mdx +++ b/docs/source/installation.mdx @@ -192,8 +192,14 @@ You can install the pre-built wheels for each backend, or compile from source fo -This wheel provides support for 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 From c0464093fb885e0af043b63e9be00a0398c22f72 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Fri, 6 Jun 2025 09:03:06 +0000 Subject: [PATCH 6/9] revert Signed-off-by: jiqing-feng --- docs/source/installation.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/installation.mdx b/docs/source/installation.mdx index f81948604..eb052d6f3 100644 --- a/docs/source/installation.mdx +++ b/docs/source/installation.mdx @@ -188,7 +188,7 @@ pip install torch --index-url https://download.pytorch.org/whl/rocm6.3/ You can install the pre-built wheels for each backend, or compile from source for custom configurations. -#### Pre-built Wheel Installation (recommended) +#### Pre-built Wheel Installation (recommended)[[multi-backend-pip]] From 62e8d79924ee9dbc7f44e870e98e47a754be6aeb Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Fri, 6 Jun 2025 09:04:11 +0000 Subject: [PATCH 7/9] rm cpu dockerfile Signed-off-by: jiqing-feng --- docker/Dockerfile.cpu | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100755 docker/Dockerfile.cpu diff --git a/docker/Dockerfile.cpu b/docker/Dockerfile.cpu deleted file mode 100755 index df323a527..000000000 --- a/docker/Dockerfile.cpu +++ /dev/null @@ -1,34 +0,0 @@ -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/cpu --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/ && \ - cmake -DCOMPUTE_BACKEND=cpu -S . && make && 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"] From e36abd97af3ff9dabff8df7091e6daa8aabbd7f8 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Fri, 6 Jun 2025 09:07:54 +0000 Subject: [PATCH 8/9] rm ipex in xpu dockerfile Signed-off-by: jiqing-feng --- docker/Dockerfile.xpu | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/Dockerfile.xpu b/docker/Dockerfile.xpu index 68a1ab0f5..03661196f 100755 --- a/docker/Dockerfile.xpu +++ b/docker/Dockerfile.xpu @@ -20,7 +20,6 @@ RUN apt-get update && apt-get -y install apt-utils build-essential \ 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 intel-extension-for-pytorch --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/ --no-cache-dir RUN pip install -U transformers accelerate peft pytest # install bitsandbytes From 222d8d31b274422ff53dd4ec7595c013a2ef8556 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Fri, 6 Jun 2025 09:12:01 +0000 Subject: [PATCH 9/9] rm cpu docker build Signed-off-by: jiqing-feng --- docs/source/installation.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/installation.mdx b/docs/source/installation.mdx index eb052d6f3..666bbbcbc 100644 --- a/docs/source/installation.mdx +++ b/docs/source/installation.mdx @@ -264,7 +264,7 @@ XPU: pip install git+https://github.com/bitsandbytes-foundation/bitsandbytes.git ``` -You can also use docker by `docker build -f docker/Dockerfile.cpu -t bnb-cpu .` on CPU or `docker build -f docker/Dockerfile.xpu -t bnb-xpu .` on XPU. +You can also use docker by `docker build -f docker/Dockerfile.xpu -t bnb-xpu .` on XPU.