Skip to content

Update build_wheels_windows.yml #1107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from
Open
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
26 changes: 24 additions & 2 deletions .github/workflows/build_wheels_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ jobs:
with_contrib: [0, 1]
without_gui: [0, 1]
build_sdist: [0]
cuda: [0, 1] # 添加 CUDA 选项,0 表示禁用,1 表示启用
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
SDIST: ${{ matrix.build_sdist || 0 }}
ENABLE_HEADLESS: ${{ matrix.without_gui }}
ENABLE_CONTRIB: ${{ matrix.with_contrib }}
OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
WITH_CUDA: ${{ matrix.cuda }} # 定义 CUDA 环境变量
steps:
- name: Cleanup
shell: bash
Expand Down Expand Up @@ -61,6 +63,11 @@ jobs:
uses: microsoft/[email protected]
- name: Setup NASM
uses: ilammy/setup-nasm@v1
- name: Setup CUDA Toolkit
if: ${{ matrix.cuda == 1 }}
uses: Jimver/[email protected]
with:
cuda: '11.8.0' # 指定 CUDA 版本
- name: Build a package
# CMake 3.25 regression fix. See https://stackoverflow.com/questions/74162633/problem-compiling-from-source-opencv-with-mvsc2019-in-64-bit-version
run: |
Expand All @@ -69,12 +76,26 @@ jobs:
python -m pip install --upgrade setuptools
python -m pip install cmake==3.24.2
python -m pip install toml && python -c "import toml; c = toml.load('pyproject.toml'); print('\n'.join(c['build-system']['requires']))" >> requirements.txt | python -m pip install -r requirements.txt

# 设置 CUDA 相关环境变量
if "%WITH_CUDA%"=="1" (
set "ENABLE_CUDA=1"
set "ENABLE_CUDNN=1"
set "CUDA_ARCH_BIN=5.2 6.0 6.1 7.0 7.5 8.0 8.6" # 支持的 CUDA 架构
set "BUILD_opencv_cudacodec=1"
echo "CUDA support enabled"
) else (
set "ENABLE_CUDA=0"
echo "CUDA support disabled"
)

# 构建命令,添加 CUDA 相关选项
set "CI_BUILD=1" && python setup.py bdist_wheel --py-limited-api=cp37 --dist-dir=%cd%\wheelhouse -v
shell: cmd
- name: Saving all wheels
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }}
name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }}-${{ matrix.cuda }}
path: wheelhouse/opencv*

Test:
Expand All @@ -91,6 +112,7 @@ jobs:
with_contrib: [0, 1]
without_gui: [0, 1]
build_sdist: [0]
cuda: [0, 1] # 添加 CUDA 选项
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
Expand All @@ -115,7 +137,7 @@ jobs:
- name: Download a wheel accordingly to matrix
uses: actions/download-artifact@v4
with:
name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }}
name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }}-${{ matrix.cuda }}
path: wheelhouse/
- name: Package installation
run: |
Expand Down