Skip to content

Commit 3d4cd59

Browse files
authored
Cache OpenBLAS to docker image for SBSA builds (#1842)
* apply openblas cache for cpu-aarch64 * reapply for cuda-aarch64
1 parent 9116886 commit 3d4cd59

File tree

4 files changed

+36
-40
lines changed

4 files changed

+36
-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
@@ -227,7 +189,6 @@ def parse_arguments():
227189
elif branch.startswith(("v1.", "v2.")):
228190
build_vars += f"BUILD_TEST=0 PYTORCH_BUILD_VERSION={branch[1:branch.find('-')]} PYTORCH_BUILD_NUMBER=1 "
229191

230-
build_OpenBLAS()
231192
if enable_mkldnn:
232193
build_ArmComputeLibrary()
233194
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_aarch64

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,16 @@ ADD ./common/install_openssl.sh install_openssl.sh
7878
RUN bash ./install_openssl.sh && rm install_openssl.sh
7979
ENV SSL_CERT_FILE=/opt/_internal/certs.pem
8080

81+
FROM base as openblas
82+
# Install openblas
83+
ADD ./common/install_openblas.sh install_openblas.sh
84+
RUN bash ./install_openblas.sh && rm install_openblas.sh
85+
8186
FROM openssl as final
8287
# remove unncessary python versions
8388
RUN rm -rf /opt/python/cp26-cp26m /opt/_internal/cpython-2.6.9-ucs2
8489
RUN rm -rf /opt/python/cp26-cp26mu /opt/_internal/cpython-2.6.9-ucs4
8590
RUN rm -rf /opt/python/cp33-cp33m /opt/_internal/cpython-3.3.6
8691
RUN rm -rf /opt/python/cp34-cp34m /opt/_internal/cpython-3.4.6
92+
COPY --from=openblas /opt/OpenBLAS/ /opt/OpenBLAS/
93+
ENV LD_LIBRARY_PATH=/opt/OpenBLAS/lib:$LD_LIBRARY_PATH

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)