Skip to content
Merged
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
24 changes: 10 additions & 14 deletions .github/workflows/build-torch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ on:
workflow_dispatch:
inputs:
version:
description: 'torch version to build (git tag without leading v, e.g. 2.13.0)'
description: 'torch version to build (git tag without leading v)'
required: true
default: '2.13.0'
default: '2.14.0'
pull_request:
paths:
- '.github/workflows/build-torch.yml'
- 'patches/torch/**'

run-name: build-torch - ${{ inputs.version || '2.13.0' }}
run-name: build-torch - ${{ inputs.version || '2.14.0' }}

concurrency:
group: ${{ github.workflow }}-${{ inputs.version || '2.13.0' }}-${{ github.head_ref || github.run_id }}
group: ${{ github.workflow }}-${{ inputs.version || '2.14.0' }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
Expand All @@ -31,7 +31,7 @@ defaults:
shell: bash --noprofile --norc -exo pipefail {0}

env:
TORCH_VERSION: ${{ inputs.version || '2.13.0' }}
TORCH_VERSION: ${{ inputs.version || '2.14.0' }}

jobs:
setup:
Expand Down Expand Up @@ -67,9 +67,7 @@ jobs:
- name: Patch pytorch source
working-directory: pytorch
run: |
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0001-CI-Add-manywheel-Dockerfile-for-riscv64.patch
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0002-CI-Add-cpu-riscv64-support-to-manywheel-scripts.patch
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0003-CI-Add-native-build-image-for-linux-riscv64.patch
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/*.patch

- name: Login to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
Expand Down Expand Up @@ -106,7 +104,7 @@ jobs:
docker push "${DOCKER_IMAGE}"

build_wheels:
name: Build torch ${{ inputs.version || '2.13.0' }} ${{ matrix.python-version }}-manylinux_riscv64
name: Build torch ${{ inputs.version || '2.14.0' }} ${{ matrix.python-version }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 1440 # 24h
needs:
Expand Down Expand Up @@ -151,9 +149,7 @@ jobs:
- name: Patch pytorch source
working-directory: pytorch
run: |
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0001-CI-Add-manywheel-Dockerfile-for-riscv64.patch
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0002-CI-Add-cpu-riscv64-support-to-manywheel-scripts.patch
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0003-CI-Add-native-build-image-for-linux-riscv64.patch
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/*.patch

- name: Populate binary env
working-directory: pytorch
Expand Down Expand Up @@ -194,11 +190,11 @@ jobs:
path: ${{ steps.artifact-name.outputs.wheel-dir }}/*.whl

publish:
name: Publish torch ${{ inputs.version || '2.13.0' }}
name: Publish torch ${{ inputs.version || '2.14.0' }}
needs: [setup, build_wheels]
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
with:
artifact-pattern: torch-${{ inputs.version || '2.13.0' }}-*-manylinux_riscv64
artifact-pattern: torch-${{ inputs.version || '2.14.0' }}-*-manylinux_riscv64
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
From 0000000000000000000000000000000000000001 Mon Sep 17 00:00:00 2001
From: RISE Project CI <ci@riseproject.dev>
Date: Thu, 10 Jul 2026 00:00:00 +0000
Subject: [PATCH 1/2] [CI] Add manywheel Dockerfile for riscv64

Add Dockerfile_2_39_riscv64 for building riscv64 manywheel images using
quay.io/pypa/manylinux_2_39_riscv64 as base, and register the new
manylinux2_39_riscv64-builder:cpu-riscv64 image in build.sh.

Pin OPENBLAS_VERSION to v0.3.34: v0.3.33 (install_openblas.sh's default)
fails to build on riscv64 with "'coremsg' undeclared" in
dynamic_riscv64.c; v0.3.34 declares that buffer. Set as a plain shell
variable (not folded into DOCKER_GPU_BUILD_ARG) since build.sh
unconditionally appends its own `--build-arg "OPENBLAS_VERSION=..."`
after DOCKER_GPU_BUILD_ARG on the docker build command line, and a
later --build-arg for the same key silently wins.

Upstream-Status: To upstream

Signed-off-by: RISE Project CI <ci@riseproject.dev>
---
.ci/docker/manywheel/Dockerfile_2_39_riscv64 | 66 +++++++++++++++++++++++++++++++++
.ci/docker/manywheel/build.sh | 11 +++++++
2 files changed, 77 insertions(+)

diff --git a/.ci/docker/manywheel/Dockerfile_2_39_riscv64 b/.ci/docker/manywheel/Dockerfile_2_39_riscv64
new file mode 100644
--- /dev/null
+++ b/.ci/docker/manywheel/Dockerfile_2_39_riscv64
@@ -0,0 +1,66 @@
+FROM quay.io/pypa/manylinux_2_39_riscv64 as base
+
+ARG GCCTOOLSET_VERSION=14
+
+# Language variables
+ENV LC_ALL=en_US.UTF-8
+ENV LANG=en_US.UTF-8
+ENV LANGUAGE=en_US.UTF-8
+
+ARG PIP_EXTRA_INDEX_URL
+ENV PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}
+ARG PIP_PREFER_BINARY
+ENV PIP_PREFER_BINARY=${PIP_PREFER_BINARY}
+
+# Installed needed OS packages. This is to support all
+# the binary builds (torch, vision, audio, text, data)
+RUN yum -y update
+RUN yum install -y \
+ autoconf \
+ automake \
+ bison \
+ bzip2 \
+ curl \
+ diffutils \
+ file \
+ git \
+ less \
+ libffi-devel \
+ libgomp \
+ make \
+ openssl-devel \
+ patch \
+ perl \
+ unzip \
+ util-linux \
+ wget \
+ which \
+ xz \
+ zstd \
+ sudo \
+ gcc \
+ gcc-c++ \
+ gcc-gfortran \
+ gdb
+RUN yum install -y ninja-build
+
+# git236+ would refuse to run git commands in repos owned by other users
+# Which causes version check to fail, as pytorch repo is bind-mounted into the image
+# Override this behaviour by treating every folder as safe
+# For more details see https://github.com/pytorch/pytorch/issues/78659#issuecomment-1144107327
+RUN git config --global --add safe.directory "*"
+
+# Build CPython 3.15.0 / 3.15.0t from source; quay.io/pypa does not ship them yet
+COPY ./common/install_cpython.sh install_cpython.sh
+RUN CPYTHON_VERSIONS="3.15.0 3.15.0t" bash ./install_cpython.sh && rm install_cpython.sh
+
+FROM base as openblas
+# Install openblas
+ARG OPENBLAS_VERSION
+ADD ./common/install_openblas.sh install_openblas.sh
+RUN bash ./install_openblas.sh && rm install_openblas.sh
+
+FROM base as final
+
+# remove unnecessary python versions
+COPY --from=openblas /opt/OpenBLAS/ /opt/OpenBLAS/

diff --git a/.ci/docker/manywheel/build.sh b/.ci/docker/manywheel/build.sh
--- a/.ci/docker/manywheel/build.sh
+++ b/.ci/docker/manywheel/build.sh
@@ -43,6 +43,17 @@
DOCKER_GPU_BUILD_ARG=" --build-arg DEVTOOLSET_VERSION=13"
MANY_LINUX_VERSION="2_28_aarch64"
;;
+ manylinux2_39_riscv64-builder:cpu-riscv64)
+ TARGET=final
+ GPU_IMAGE=riscv64/almalinux:10-kitten
+ # Use a custom PyPI index to get pre-built wheels for RISC-V
+ # See https://riseproject-dev.github.io/python-wheels/
+ # v0.3.33 (install_openblas.sh's default) fails to build on riscv64
+ # with "'coremsg' undeclared" in dynamic_riscv64.c; v0.3.34 fixes it.
+ OPENBLAS_VERSION="v0.3.34"
+ DOCKER_GPU_BUILD_ARG=" --platform linux/riscv64 --build-arg DEVTOOLSET_VERSION=14 --build-arg PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple --build-arg PIP_PREFER_BINARY=1"
+ MANY_LINUX_VERSION="2_39_riscv64"
+ ;;
manylinuxs390x-builder:cpu-s390x)
TARGET=final
GPU_IMAGE=s390x/almalinux:8
--
2.39.0
Loading