Skip to content

Commit fcb6908

Browse files
committed
[dist] Add CUDA PTX architecutres to cv2.version
Use stable OpenCV and expand PTX architectures for build.
1 parent fb829bc commit fcb6908

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

.github/workflows/build_wheels_windows.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ on:
2424
required: false
2525
type: boolean
2626
default: true
27+
rolling_build:
28+
description: "Use latest commit from upstream OpenCV repo."
29+
required: false
30+
type: boolean
31+
default: false
2732

2833

2934
jobs:
@@ -39,6 +44,7 @@ jobs:
3944
SDIST: 0
4045
ENABLE_HEADLESS: 0
4146
ENABLE_CONTRIB: 1
47+
ENABLE_ROLLING: ${{ inputs.rolling_build && 1 || 0 }}
4248
OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
4349
steps:
4450
- name: Cleanup
@@ -47,12 +53,6 @@ jobs:
4753
rm -rf ./* || true
4854
rm -rf ./.??* || true
4955
working-directory: ${{ github.workspace }}
50-
- name: Setup environment
51-
shell: bash
52-
run: |
53-
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
54-
echo "ENABLE_ROLLING=1" >> $GITHUB_ENV
55-
fi
5656
- name: Checkout
5757
uses: actions/checkout@v4
5858
with:

find_version.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
headless = sys.argv[2]
88
rolling = sys.argv[3]
99
ci_build = sys.argv[4]
10+
cuda_arch_bin = sys.argv[5]
11+
cuda_arch_ptx = sys.argv[6]
1012

1113
opencv_version = ""
1214
# dig out the version from OpenCV sources
@@ -53,6 +55,12 @@
5355
print(e.output)
5456
raise
5557

58+
59+
# TODO(@Breakthrough): Update this so that we just use the tag name directly as the version
60+
# identifier. We might need to strip off a "v" suffix if we include that in the repo, but it
61+
# will greatly simplify things. This can also get out of sync since we cache artifacts now.
62+
# Move invoking this script to the builder!
63+
5664
if len(tag) == 1:
5765
# tag identifies the build and should be a sequential revision number
5866
version = tag[0]
@@ -72,4 +80,5 @@
7280
f.write("contrib = {}\n".format(contrib))
7381
f.write("headless = {}\n".format(headless))
7482
f.write("rolling = {}\n".format(rolling))
75-
f.write("ci_build = {}".format(ci_build))
83+
f.write("cuda_arch_bin = {}".format(cuda_arch_bin))
84+
f.write("cuda_arch_ptx = {}".format(cuda_arch_ptx))

setup.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,24 @@ def main():
1717
CI_BUILD = os.environ.get("CI_BUILD", "False")
1818
is_CI_build = True if CI_BUILD == "1" else False
1919
cmake_source_dir = "opencv"
20-
minimum_supported_numpy = "1.13.3"
2120
build_contrib = get_build_env_var_by_name("contrib")
2221
build_headless = get_build_env_var_by_name("headless")
2322
build_java = "ON" if get_build_env_var_by_name("java") else "OFF"
2423
build_rolling = get_build_env_var_by_name("rolling")
2524

25+
# fermi = "2.0"
26+
# kepler = "3.0;3.5;3.7"
27+
# maxwell = "5.0;5.2"
28+
# pascal = "6.0;6.1"
29+
# volta = "7.0"
30+
# turing = "7.5"
31+
# ampere = "8.0;8.6"
32+
# lovelace = "8.9"
33+
# hopper = "9.0"
34+
# blackwell = "10.0;12.0"
35+
cuda_arch_bin = "6.0;6.1;7.0;7.5,8.0"
36+
cuda_arch_ptx = "8.0"
37+
2638
# NOTE: since 2.3.0 numpy upgraded from manylinux2014 to manylinux_2_28
2739
# see https://numpy.org/doc/stable/release/2.3.0-notes.html#numpy-2-3-0-release-notes
2840
install_requires = [
@@ -70,7 +82,7 @@ def main():
7082
)
7183

7284
package_version, build_contrib, build_headless, build_rolling = get_and_set_info(
73-
build_contrib, build_headless, build_rolling, is_CI_build
85+
build_contrib, build_headless, build_rolling, is_CI_build, cuda_arch_bin, cuda_arch_ptx
7486
)
7587

7688
# https://stackoverflow.com/questions/1405913/python-32bit-or-64bit-mode
@@ -151,8 +163,6 @@ def main():
151163

152164
cudnn_library = os.environ["CUDNN_LIBRARY"]
153165
cudnn_include_dir = os.environ["CUDNN_INCLUDE_DIR"]
154-
cuda_arch_bin = "6.0;6.1;7.0;7.5"
155-
cuda_arch_ptx = "7.5"
156166

157167
cmake_args = (
158168
(ci_cmake_generator if is_CI_build else [])
@@ -490,7 +500,7 @@ def _classify_installed_files_override(
490500
)
491501

492502

493-
def get_and_set_info(contrib, headless, rolling, ci_build):
503+
def get_and_set_info(contrib, headless, rolling, ci_build, cuda_arch_bin, cuda_arch_ptx):
494504
# cv2/version.py should be generated by running find_version.py
495505
version = {}
496506
here = os.path.abspath(os.path.dirname(__file__))
@@ -500,7 +510,7 @@ def get_and_set_info(contrib, headless, rolling, ci_build):
500510
# (in sdists the version.py file already exists)
501511
if os.path.exists(".git"):
502512
old_args = sys.argv.copy()
503-
sys.argv = ["", str(contrib), str(headless), str(rolling), str(ci_build)]
513+
sys.argv = ["", str(contrib), str(headless), str(rolling), str(ci_build), str(cuda_arch_bin), str(cuda_arch_ptx)]
504514
runpy.run_path("find_version.py", run_name="__main__")
505515
sys.argv = old_args
506516

0 commit comments

Comments
 (0)