8000 Update build_wheels_windows.yml · opencv/opencv-python@38c3a64 · GitHub
[go: up one dir, main page]

Skip to content

Commit 38c3a64

Browse files
authored
Update build_wheels_windows.yml
1 parent 2606a60 commit 38c3a64

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

.github/workflows/build_wheels_windows.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ jobs:
2828
with_contrib: [0, 1]
2929
without_gui: [0, 1]
3030
build_sdist: [0]
31+
cuda: [0, 1] # 添加 CUDA 选项,0 表示禁用,1 表示启用
3132
env:
3233
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
3334
SDIST: ${{ matrix.build_sdist || 0 }}
3435
ENABLE_HEADLESS: ${{ matrix.without_gui }}
3536
ENABLE_CONTRIB: ${{ matrix.with_contrib }}
3637
OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
38+
WITH_CUDA: ${{ matrix.cuda }} # 定义 CUDA 环境变量
3739
steps:
3840
- name: Cleanup
3941
shell: bash
@@ -61,6 +63,11 @@ jobs:
6163
uses: microsoft/setup-msbuild@v1.1
6264
- name: Setup NASM
6365
uses: ilammy/setup-nasm@v1
66+
- name: Setup CUDA Toolkit
67+
if: ${{ matrix.cuda == 1 }}
68+
uses: Jimver/cuda-toolkit@v0.2.1
69+
with:
70+
cuda: '11.8.0' # 指定 CUDA 版本
6471
- name: Build a package
6572
# CMake 3.25 regression fix. See https://stackoverflow.com/questions/74162633/problem-compiling-from-source-opencv-with-mvsc2019-in-64-bit-version
6673
run: |
@@ -69,12 +76,26 @@ jobs:
6976
python -m pip install --upgrade setuptools
7077
python -m pip install cmake==3.24.2
7178
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
79+
80+
# 设置 CUDA 相关环境变量
81+
if "%WITH_CUDA%"=="1" (
82+
set "ENABLE_CUDA=1"
83+
set "ENABLE_CUDNN=1"
84+
set "CUDA_ARCH_BIN=5.2 6.0 6.1 7.0 7.5 8.0 8.6" # 支持的 CUDA 架构
85+
set "BUILD_opencv_cudacodec=1"
86+
echo "CUDA support enabled"
87+
) else (
88+
set "ENABLE_CUDA=0"
89+
echo "CUDA support disabled"
90+
)
91+
92+
# 构建命令,添加 CUDA 相关选项
7293
set "CI_BUILD=1" && python setup.py bdist_wheel --py-limited-api=cp37 --dist-dir=%cd%\wheelhouse -v
7394
shell: cmd
7495
- name: Saving all wheels
7596
uses: actions/upload-artifact@v4
7697
with:
77-
name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }}
98+
name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }}-${{ matrix.cuda }}
7899
path: wheelhouse/opencv*
79100

80101
Test:
@@ -91,6 +112,7 @@ jobs:
91112
with_contrib: [0, 1]
92113
without_gui: [0, 1]
93114
build_sdist: [0]
115+
cuda: [0, 1] # 添加 CUDA 选项
94116
env:
95117
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
96118
OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
@@ -115,7 +137,7 @@ jobs:
115137
- name: Download a wheel accordingly to matrix
116138
uses: actions/download-artifact@v4
117139
with:
118-
name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }}
140+
name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }}-${{ matrix.cuda }}
119141
path: wheelhouse/
120142
- name: Package installation
121143
run: |

0 commit comments

Comments
 (0)
0