Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 87feb22

Browse files
authored
Cache OpenBLAS build to CUDA ARM Docker image (#1833)
* add openblas to docker file * fix make command and add to docker final stage * disable build_OpenBLAS() from aarch64_wheel_ci_build.py * copying whole OpenBLAS dir as include and bin are also needed
1 parent 36dc387 commit 87feb22

File tree

3 files changed

+29
-40
lines changed

3 files changed

+29
-40
lines changed

aarch64_linux/aarch64_wheel_ci_build.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,6 @@ def list_dir(path: str) -> List[str]:
1414
"""
1515
return check_output(["ls", "-1", path]).decode().split("\n")
1616

17-
18-
def build_OpenBLAS() -> None:
19-
'''
20-
Building OpenBLAS, because the package in many linux is old
21-
'''
22-
print('Building OpenBLAS')
23-
openblas_build_flags = [
24-
"NUM_THREADS=128",
25-
"USE_OPENMP=1",
26-
"NO_SHARED=0",
27-
"DYNAMIC_ARCH=1",
28-
"TARGET=ARMV8",
29-
"CFLAGS=-O3",
30-
]
31-
openblas_checkout_dir = "OpenBLAS"
32-
33-
check_call(
34-
[
35-
"git",
36-
"clone",
37-
"https://github.com/OpenMathLib/OpenBLAS.git",
38-
"-b",
39-
"v0.3.25",
40-
"--depth",
41-
"1",
42-
"--shallow-submodules",
43-
]
44-
)
45-
46-
check_call(["make", "-j8"]
47-
+ openblas_build_flags,
48-
cwd=openblas_checkout_dir)
49-
check_call(["make", "-j8"]
50-
+ openblas_build_flags
51-
+ ["install"],
52-
cwd=openblas_checkout_dir)
53-
54-
5517
def build_ArmComputeLibrary() -> None:
5618
"""
5719
Using ArmComputeLibrary for aarch64 PyTorch
@@ -222,7 +184,6 @@ def parse_arguments():
222184
elif branch.startswith(("v1.", "v2.")):
223185
build_vars += f"BUILD_TEST=0 PYTORCH_BUILD_VERSION={branch[1:branch.find('-')]} PYTORCH_BUILD_NUMBER=1 "
224186

225-
build_OpenBLAS()
226187
if enable_mkldnn:
227188
build_ArmComputeLibrary()
228189
print("build pytorch with mkldnn+acl backend")

common/install_openblas.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
cd /
6+
git clone https://github.com/OpenMathLib/OpenBLAS.git -b v0.3.25 --depth 1 --shallow-submodules
7+
8+
9+
OPENBLAS_BUILD_FLAGS="
10+
NUM_THREADS=128
11+
USE_OPENMP=1
12+
NO_SHARED=0
13+
DYNAMIC_ARCH=1
14+
TARGET=ARMV8
15+
CFLAGS=-O3
16+
"
17+
18+
OPENBLAS_CHECKOUT_DIR="OpenBLAS"
19+
20+
make -j8 ${OPENBLAS_BUILD_FLAGS} -C ${OPENBLAS_CHECKOUT_DIR}
21+
make -j8 ${OPENBLAS_BUILD_FLAGS} install -C ${OPENBLAS_CHECKOUT_DIR}

manywheel/Dockerfile_cuda_aarch64

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,17 @@ ARG BASE_CUDA_VERSION
7474
ADD ./common/install_magma.sh install_magma.sh
7575
RUN bash ./install_magma.sh ${BASE_CUDA_VERSION} && rm install_magma.sh
7676

77+
FROM base as openblas
78+
# Install openblas
79+
ADD ./common/install_openblas.sh install_openblas.sh
80+
RUN bash ./install_openblas.sh && rm install_openblas.sh
81+
7782
FROM final as cuda_final
7883
ARG BASE_CUDA_VERSION
7984
RUN rm -rf /usr/local/cuda-${BASE_CUDA_VERSION}
8085
COPY --from=cuda /usr/local/cuda-${BASE_CUDA_VERSION} /usr/local/cuda-${BASE_CUDA_VERSION}
8186
COPY --from=magma /usr/local/cuda-${BASE_CUDA_VERSION} /usr/local/cuda-${BASE_CUDA_VERSION}
87+
COPY --from=openblas /opt/OpenBLAS/ /opt/OpenBLAS/
8288
RUN ln -sf /usr/local/cuda-${BASE_CUDA_VERSION} /usr/local/cuda
83-
ENV PATH=/usr/local/cuda/bin:$PATH
89+
ENV PATH=/usr/local/cuda/bin:$PATH
90+
ENV LD_LIBRARY_PATH=/opt/OpenBLAS/lib:$LD_LIBRARY_PATH

0 commit comments

Comments
 (0)