Skip to content

nightly_cpu_windows #445

nightly_cpu_windows

nightly_cpu_windows #445

# Copyright 2021 Fangjun Kuang ([email protected])
# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: nightly_cpu_windows
on:
push:
branches:
- nightly
paths:
- '.github/workflows/nightly-cpu-windows.yml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'k2/csrc/**'
- 'k2/python/**'
schedule:
# minute (0-59)
# hour (0-23)
# day of the month (1-31)
# month (1-12)
# day of the week (0-6)
# nightly build at 23:50 UTC time every day
- cron: "50 23 * * *"
concurrency:
group: nightly_cpu_windows-${{ github.ref }}
cancel-in-progress: true
env:
BUILD_TYPE: Release
jobs:
enable_nightly_build:
if: github.repository == 'k2-fsa/k2'
runs-on: ubuntu-latest
outputs:
enabled: ${{ steps.set-enabled.outputs.enabled }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set enabled
id: set-enabled
run: |
enabled=$(python scripts/github_actions/run-nightly-build.py)
echo "enabled: $enabled"
echo "::set-output name=enabled::${enabled}"
generate_build_matrix:
needs: enable_nightly_build
if: needs.enable_nightly_build.outputs.enabled == 'true' || github.event_name == 'push'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Generating build matrix
id: set-matrix
run: |
# outputting for debugging purposes
python scripts/github_actions/generate_build_matrix.py
MATRIX=$(python scripts/github_actions/generate_build_matrix.py)
echo "::set-output name=matrix::${MATRIX}"
nightly_cpu_windows:
needs: generate_build_matrix
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
# see https://github.com/microsoft/setup-msbuild
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install PyTorch ${{ matrix.torch }}
run: |
pip3 install -qq torch==${{ matrix.torch }}+cpu -f https://download.pytorch.org/whl/torch_stable.html numpy
pip3 install -qq wheel twine dataclasses typing_extensions
python3 -m torch.utils.collect_env
- name: Display CMake version
run: |
cmake --version
cmake --help
- name: Build wheel
shell: bash
run: |
export K2_CMAKE_ARGS="-DK2_WITH_CUDA=OFF -DCMAKE_BUILD_TYPE=Release"
python3 setup.py bdist_wheel
ls -lh dist/
pip install ./dist/*.whl
- name: Upload Wheel
uses: actions/upload-artifact@v2
with:
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-windows-cpu
path: dist/*.whl
- name: Copy wheels to k2-fsa.org
if: ${{ github.repository_owner == 'k2-fsa' }}
shell: bash
run: |
user=${{ secrets.K2_USERNAME }}
server=${{ secrets.K2_HOST }}
port=${{ secrets.K2_PORT }}
echo "${{ secrets.K2_KEY }}" > id_rsa && chmod 600 id_rsa
scp -P $port -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i id_rsa dist/*.whl $user@$server:~/nightly/whl
rm id_rsa
- name: Configure CMake
shell: bash
run: |
mkdir build_release
cd build_release
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DK2_WITH_CUDA=OFF ..
ls -lh
cat k2/csrc/version.h
cat CMakeCache.txt
- name: Build k2
shell: bash
run: |
cd build_release
cmake --build . --target _k2 --config Release -- -m
cmake --build . --target ALL_BUILD --config Release
- name: Display generated files
shell: bash
run: |
cd build_release
ls -lh lib/*/*
ls -lh bin/*/*
- name: Run tests
shell: bash
run: |
cd build_release
# disable python tests for k2host
ctest -C Release --output-on-failure -E host