Skip to content

Commit 31ded06

Browse files
qiao-bopre-commit-ci[bot]
authored andcommitted
[ci] [build] Containerize Windows CPU build and test (#4933)
* [ci] [build] Containerize Windows CPU build and test * Disable ninja * Avoid pybind11_add_module() * Force reinstall * Find pybind11 * Include pybind11 dir * Update include dir * Remove trailing whitespace * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use correct pybind11 * Add path * Enable no extras for pybind11_add_module * Add no_extra * Clone in the container * Use github job container * Add runs-on * Revert back to docker based jobs * Install instead of develop * [ci] [build] Containerize Windows CPU build and test * Disable ninja * Avoid pybind11_add_module() * Force reinstall * Find pybind11 * Include pybind11 dir * Update include dir * Remove trailing whitespace * Use correct pybind11 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add path * Enable no extras for pybind11_add_module * Add no_extra * Clone in the container * Use github job container * Add runs-on * Revert back to docker based jobs * Install instead of develop * Use tar in jobs * Update cmake * Skip clone * Manual fixing white space * Remove comments Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 4078f25 commit 31ded06

File tree

4 files changed

+116
-2
lines changed

4 files changed

+116
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Build script for windows CPU
2+
# TODO unify this with the other Win scripts
3+
4+
param (
5+
[switch]$clone = $false,
6+
[switch]$install = $false,
7+
[string]$libsDir = "C:\"
8+
)
9+
10+
$ErrorActionPreference = "Stop"
11+
12+
$RepoURL = 'https://github.com/taichi-dev/taichi'
13+
14+
function WriteInfo($text) {
15+
Write-Host -ForegroundColor Green "[BUILD] $text"
16+
}
17+
18+
$libsDir = (Resolve-Path $libsDir).Path
19+
if (-not (Test-Path $libsDir)) {
20+
New-Item -ItemType Directory -Path $libsDir
21+
}
22+
Set-Location $libsDir
23+
24+
if (-not (Test-Path "taichi_llvm")) {
25+
WriteInfo("Download and extract LLVM")
26+
curl.exe --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/taichi-llvm-10.0.0-msvc2019.zip -LO
27+
7z x taichi-llvm-10.0.0-msvc2019.zip -otaichi_llvm
28+
}
29+
if (-not (Test-Path "taichi_clang")) {
30+
WriteInfo("Download and extract Clang")
31+
curl.exe --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/clang-10.0.0-win.zip -LO
32+
7z x clang-10.0.0-win.zip -otaichi_clang
33+
}
34+
35+
WriteInfo("Setting the env vars")
36+
$env:LLVM_DIR = "C://taichi_llvm"
37+
38+
#TODO enable build test
39+
$env:TAICHI_CMAKE_ARGS = "-DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=OFF -DTI_WITH_VULKAN:BOOL=OFF -DTI_WITH_CUDA:BOOL=OFF -DTI_BUILD_TESTS:BOOL=OFF"
40+
41+
#TODO: For now we need to hard code the compiler path from build tools 2019
42+
$env:TAICHI_CMAKE_ARGS +=' -DCMAKE_CXX_COMPILER=C:/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2019/BuildTools/vc/Tools/Llvm/x64/bin/clang++.exe -DCMAKE_C_COMPILER=C:/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2019/BuildTools/vc/Tools/Llvm/x64/bin/clang.exe'
43+
$env:TAICHI_CMAKE_ARGS += " -DCLANG_EXECUTABLE=C:\\taichi_clang\\bin\\clang++.exe"
44+
$env:TAICHI_CMAKE_ARGS += " -DLLVM_AS_EXECUTABLE=C:\\taichi_llvm\\bin\\llvm-as.exe -DTI_WITH_VULKAN:BOOL=OFF"
45+
46+
WriteInfo("Checking clang compiler")
47+
clang --version
48+
49+
WriteInfo("Enter the repository")
50+
Set-Location .\taichi
51+
52+
WriteInfo("Setting up Python environment")
53+
conda activate py37
54+
python -m pip install -r requirements_dev.txt
55+
python -m pip install -r requirements_test.txt
56+
57+
# These have to be re-installed to avoid strange certificate issue
58+
# on CPU docker environment
59+
python -m pip install --upgrade --force-reinstall numpy
60+
python -m pip install --upgrade --force-reinstall cmake
61+
python -m pip install --upgrade --force-reinstall wheel
62+
if (-not $?) { exit 1 }
63+
64+
WriteInfo("Building Taichi")
65+
python setup.py install
66+
if (-not $?) { exit 1 }
67+
WriteInfo("Build finished")
68+
69+
$env:TI_ENABLE_PADDLE = "0"
70+
WriteInfo("Testing Taichi")
71+
python tests/run_tests.py -vr2 -t4 -k "not torch and not paddle" -a cpu
72+
WriteInfo("Test finished")

.github/workflows/testing.yml

+42
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,48 @@ jobs:
239239
TI_WANTED_ARCHS: ${{ matrix.wanted_archs }}
240240
TI_CI: 1
241241

242+
build_and_test_cpu_windows:
243+
name: Build and Test Windows (CPU)
244+
needs: check_files
245+
timeout-minutes: 90
246+
runs-on: windows-2019
247+
permissions:
248+
packages: read
249+
contents: read
250+
steps:
251+
- uses: actions/checkout@v2
252+
with:
253+
submodules: 'recursive'
254+
255+
- name: Get docker images
256+
shell: bash
257+
run: |
258+
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
259+
exit 0
260+
fi
261+
echo $CR_PAT | docker login ghcr.io -u ${{ github.actor }} --password-stdin
262+
docker pull ghcr.io/taichi-dev/taichidev-cpu-windows:v0.0.1
263+
env:
264+
CR_PAT: ${{ secrets.GITHUB_TOKEN }}
265+
266+
- name: Build and Test
267+
shell: bash
268+
run: |
269+
if [[ ${{needs.check_files.outputs.run_job}} == false ]]; then
270+
exit 0
271+
fi
272+
docker create --name taichi_build_test \
273+
ghcr.io/taichi-dev/taichidev-cpu-windows:v0.0.1 \
274+
C:/taichi/.github/workflows/scripts/win_build_test_cpu.ps1
275+
tar -cf - ../${{ github.event.repository.name }} --mode u=+rwx,g=+rwx,o=+rwx | docker cp - taichi_build_test:C:/
276+
docker start -a taichi_build_test
277+
278+
- name: clean docker container
279+
shell: bash
280+
if: always()
281+
run: |
282+
docker rm taichi_build_test -f
283+
242284
build_and_test_gpu_linux:
243285
name: Build and Test (GPU)
244286
needs: check_files

cmake/PythonNumpyPybind11.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ message(" include: ${PYTHON_INCLUDE_DIR}")
1010
message(" library: ${PYTHON_LIBRARY}")
1111
message(" numpy include: ${NUMPY_INCLUDE_DIR}")
1212

13-
1413
include_directories(${NUMPY_INCLUDE_DIR})
1514

1615
find_package(pybind11 CONFIG REQUIRED)

cmake/TaichiCore.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@ if(NOT TI_EMSCRIPTENED)
465465
# Cannot compile Python source code with Android, but TI_EXPORT_CORE should be set and
466466
# Android should only use the isolated library ignoring those source code.
467467
if (NOT ANDROID)
468-
pybind11_add_module(${CORE_WITH_PYBIND_LIBRARY_NAME} ${TAICHI_PYBIND_SOURCE})
468+
# NO_EXTRAS is required here to avoid llvm symbol error during build
469+
pybind11_add_module(${CORE_WITH_PYBIND_LIBRARY_NAME} NO_EXTRAS ${TAICHI_PYBIND_SOURCE})
469470
else()
470471
add_library(${CORE_WITH_PYBIND_LIBRARY_NAME} SHARED)
471472
endif ()

0 commit comments

Comments
 (0)