Skip to content

Automate builds of OpenCV for Windows/Ubuntu #1

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 66 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
900d913
update download scripts
jveitchmichaelis Feb 16, 2024
09da0d4
update workflow
jveitchmichaelis Feb 16, 2024
9a53ed8
update cuda/cudnn paths
jveitchmichaelis Feb 16, 2024
a2c1779
update workflows
jveitchmichaelis Feb 16, 2024
994c1fb
disable cudnn in build for now
jveitchmichaelis Feb 16, 2024
4855c57
use gcc 10 for cuda
jveitchmichaelis Feb 16, 2024
6207483
attempt to patch stdlib
jveitchmichaelis Feb 16, 2024
3d2d4e7
only use main apt repo for 2300
jveitchmichaelis Feb 16, 2024
db3db26
let's try cudnn again
jveitchmichaelis Feb 16, 2024
fb3aa5d
simplify deps and remove jasper
jveitchmichaelis Feb 16, 2024
75131d1
attempt rollback cudnn to 8
jveitchmichaelis Feb 17, 2024
c3718a5
Try to free up space on runner
jveitchmichaelis Feb 17, 2024
fdcb53d
add badge
jveitchmichaelis Feb 17, 2024
240343c
add release task
jveitchmichaelis Feb 18, 2024
c149668
tidy up build/download scripts
jveitchmichaelis Feb 18, 2024
7d081c8
use containers for build
jveitchmichaelis Feb 18, 2024
3217416
non-interactive for cudnn
jveitchmichaelis Feb 18, 2024
fbdfc28
manually specify CUDA compute targets
jveitchmichaelis Feb 18, 2024
32df1f6
add 23.10
jveitchmichaelis Feb 18, 2024
e7aea85
use gcc-11
jveitchmichaelis Feb 18, 2024
08b212f
update windows
jveitchmichaelis Feb 18, 2024
5bbb7f5
remove windows cuda for now
jveitchmichaelis Feb 18, 2024
08d5c88
update readme
jveitchmichaelis Feb 18, 2024
afc15c8
add fix for tzdata if needed
jveitchmichaelis Feb 18, 2024
8031e2f
try windows again with 2019
jveitchmichaelis Feb 18, 2024
0a6db24
remove upload tarball as runner runs out of space
jveitchmichaelis Feb 19, 2024
c275748
don't specify cuda subpackages, install everything
jveitchmichaelis Feb 19, 2024
f9878ac
split out linux and windows
jveitchmichaelis Feb 19, 2024
2335ee4
attempt to use local cudnn installer
jveitchmichaelis Feb 19, 2024
02ea274
drop cudnn on windows until we can figure out how to do it headless
jveitchmichaelis Feb 19, 2024
f86f7c5
Update CUDA compute targets in build.bat
jveitchmichaelis Feb 20, 2024
c8068c1
test archiving
jveitchmichaelis Feb 20, 2024
9190484
fix ref name
jveitchmichaelis Feb 20, 2024
a9d6167
update archiving
jveitchmichaelis Feb 21, 2024
7ffca92
fix colons in tar path
jveitchmichaelis Feb 21, 2024
f033e19
fix colon replace
jveitchmichaelis Feb 21, 2024
3c84b9c
fix tar tags
jveitchmichaelis Feb 21, 2024
ef6bcec
update cudnn version extraction
jveitchmichaelis Feb 22, 2024
bad0794
add check for nvcc after CUDA install
jveitchmichaelis Feb 22, 2024
fbb1952
move cuda check to actions
jveitchmichaelis Feb 22, 2024
68a5c0f
add cuda-12 to path to check nvcc
jveitchmichaelis Feb 22, 2024
13b60c0
check paths
jveitchmichaelis Feb 22, 2024
f0704fb
locate nvcc
jveitchmichaelis Feb 22, 2024
9193016
install locate
jveitchmichaelis Feb 22, 2024
734ef0e
install locate
jveitchmichaelis Feb 22, 2024
063de82
Merge branch 'auto_release' of https://github.com/jveitchmichaelis/bu…
jveitchmichaelis Feb 22, 2024
bd1ed5d
update locate
jveitchmichaelis Feb 22, 2024
242bc4b
dpkg to find install location?
jveitchmichaelis Feb 22, 2024
5e45156
try replacing periods in env variable
jveitchmichaelis Feb 22, 2024
6faae02
just ignore the check and hardcode cuda/cudnn versions for now
jveitchmichaelis Feb 22, 2024
3f1f94b
try again
jveitchmichaelis Feb 22, 2024
3771d04
compute sha hashes for release files
jveitchmichaelis Apr 7, 2024
07e145a
fix cuda version to 12-0
jveitchmichaelis Apr 7, 2024
29215d1
compute checksums as workflow item
jveitchmichaelis Apr 7, 2024
13416a0
bump gds version
jveitchmichaelis Apr 7, 2024
7bb5d4a
try cuda 12.2
jveitchmichaelis Apr 7, 2024
bad4456
add checksums at end of each workflow
jveitchmichaelis Apr 7, 2024
37ed291
check cuda versions in script
jveitchmichaelis Apr 7, 2024
a4eeff8
try using grep ii to identify installed packages
jveitchmichaelis Apr 7, 2024
0e53427
take lowest installed cuda version
jveitchmichaelis Apr 7, 2024
1217f76
fix naming for windows release
jveitchmichaelis Apr 7, 2024
6cf9bf3
fix release name
jveitchmichaelis Apr 7, 2024
e7973ca
update cuda version check (again)
jveitchmichaelis Apr 7, 2024
cd36c40
add tests when building
jveitchmichaelis Apr 10, 2024
a5115d1
todo: fix release not being build correctly
jveitchmichaelis Apr 10, 2024
ff8816c
fix minor typo that caused release to not build
jveitchmichaelis Apr 10, 2024
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
40 changes: 0 additions & 40 deletions .github/workflows/build-options.yml

This file was deleted.

115 changes: 115 additions & 0 deletions .github/workflows/linux-cuda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build Linux CUDA/Cudnn

on: push

env:
option_path: options/options_opencv4.9.0_contrib_cuda_cudnn_vc15.txt
jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
os: ["ubuntu:20.04","ubuntu:22.04", "ubuntu:23.04", "ubuntu:23.10"]
container:
image: ${{matrix.os}}
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- uses: actions/checkout@v2

- name: Setup things in container
run: |
apt-get update
apt-get install -y --no-install-recommends sudo wget git build-essential debconf-utils apt-utils dialog ca-certificates
echo 'tzdata tzdata/Areas select Etc' | sudo debconf-set-selections
echo 'tzdata tzdata/Zones/Etc select UTC' | sudo debconf-set-selections
DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata

- name: Download CUDA
working-directory: scripts/linux
run: |
sudo ./download_cuda.sh

- name: Download CUDNN8
working-directory: scripts/linux
run: |
sudo ./download_cudnn.sh

- name: Determine CUDA and cuDNN Versions
run: |
# Extract CUDA version
CUDA_VERSION=$(dpkg -l | grep '^ii' | grep -E 'nvidia-cuda-toolkit|cuda-toolkit' | awk '{print $3}' | awk -F'[.~+]' '{print $1 "." $2}' | sort -u | head -n 1)
echo "Extracted CUDA Version: $CUDA_VERSION"

# Extract cuDNN version
CUDNN_VERSION=$(dpkg -l | grep '^ii' | grep -E 'libcudnn|nvidia-cudnn' | awk '{print $3}' | awk -F'[.~+]' '{print $1 "." $2}' | sort -u | head -n 1)
echo "Extracted CUDNN Version: $CUDNN_VERSION"

# Set environment variables properly
echo "CUDA_VERSION=$CUDA_VERSION" >> $GITHUB_ENV
echo "CUDNN_VERSION=$CUDNN_VERSION" >> $GITHUB_ENV
shell: bash

- name: Download OpenCV repo/s
run: |
scripts/linux/download.sh $option_path

- name: Patch stdlib
run: |
sudo sed -i '/_S_nothrow_init<.*>/ s/^/ \/\/ /' /usr/include/c++/*/bits/std_function.h

- name: Build OpenCV
run: |
scripts/linux/build.sh $option_path

- name: Remove build folder
uses: JesseTG/[email protected]
with:
path: build

- name: Create Tarball
if: startsWith(github.ref, 'refs/tags/')
run: |
asset_name=opencv-${{github.ref_name}}-${{ matrix.os }}-cuda$CUDA_VERSION-cudnn$CUDNN_VERSION.tar.gz
asset_name=$(echo $asset_name | sed 's/:/-/g')
tar -czf ${asset_name} install
echo "ASSET_NAME=${asset_name}" >> $GITHUB_ENV

- name: Upload Release Asset
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: ${{ env.ASSET_NAME }}
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Calculate SHA256 Checksum
- name: Calculate SHA256 Checksum
run: |
echo "Calculating SHA256 for ${{ env.ASSET_NAME }}"
sha256sum ${{ env.ASSET_NAME }} > ${{ env.ASSET_NAME }}.sha256
shell: bash

- name: Upload SHA256 Checksum File
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: ${{ env.ASSET_NAME }}.sha256
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76 changes: 76 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build Linux

on: push

env:
option_path: options/options_opencv4.9.0_contrib_vc16.txt

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
os: ["ubuntu:20.04", "ubuntu:22.04", "ubuntu:23.04", "ubuntu:23.10"]
container:
image: ${{matrix.os}}
options: --privileged
steps:
- name: Setup things in container
run: |
apt-get update
apt-get install -y --no-install-recommends sudo wget git build-essential debconf-utils apt-utils dialog ca-certificates
echo 'tzdata tzdata/Areas select Etc' | sudo debconf-set-selections
echo 'tzdata tzdata/Zones/Etc select UTC' | sudo debconf-set-selections
DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata

- uses: actions/checkout@v2
- name: Download OpenCV repo/s
run: |
scripts/linux/download.sh $option_path
- name: Build OpenCV
run: |
scripts/linux/build.sh $option_path

- name: Remove build folder
uses: JesseTG/[email protected]
with:
path: build

- name: Create Tarball
if: startsWith(github.ref, 'refs/tags/')
run: |
asset_name=opencv-${{github.ref_name}}-${{ matrix.os }}.tar.gz
asset_name=$(echo $asset_name | sed 's/:/-/g')
tar -czf ${asset_name} install
echo "ASSET_NAME=${asset_name}" >> $GITHUB_ENV

- name: Upload Release Asset
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: ${{ env.ASSET_NAME }}
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Calculate SHA256 Checksum
- name: Calculate SHA256 Checksum
run: |
echo "Calculating SHA256 for ${{ env.ASSET_NAME }}"
sha256sum ${{ env.ASSET_NAME }} > ${{ env.ASSET_NAME }}.sha256
shell: bash

- name: Upload SHA256 Checksum File
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: ${{ env.ASSET_NAME }}.sha256
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74 changes: 74 additions & 0 deletions .github/workflows/windows-cuda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build Windows CUDA

on: push

jobs:
build-windows:
runs-on: windows-2019
env:
CUDNN_URL: https://developer.download.nvidia.com/compute/redist/cudnn/v8.8.0/local_installers/12.0/cudnn_8.8.0.121_windows.exe
steps:

- name: Set up MSBuild path
uses: microsoft/[email protected]

#- name: Download cuDNN installer
# run: Invoke-WebRequest -Uri "${{ env.CUDNN_URL }}" -OutFile "cudnn_installer.exe"

#- name: Install cuDNN
# run: Start-Process -FilePath "cudnn_installer.exe" -ArgumentList '/S' -Wait

- name: Install CUDA
uses: Jimver/[email protected]
id: cuda-toolkit

- uses: actions/checkout@v2

- name: Download OpenCV repo/s
working-directory: scripts/windows
shell: cmd
run: .\download.bat options\options_opencv4.9.0_contrib_vc16.txt

- name: Build OpenCV
working-directory: scripts/windows
shell: cmd
run: .\build.bat options\options_opencv4.9.0_contrib_vc16.txt

- name: Remove build folder
uses: JesseTG/[email protected]
with:
path: build

- run: Compress-Archive -Path install/* -Destination opencv-${{github.ref_name}}-windows-cuda12.zip

- name: Upload Release Asset
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: opencv-${{github.ref_name}}-windows-cuda12.zip
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Calculate SHA256 Checksum
- name: Calculate SHA256 Checksum
run: |
echo "Calculating SHA256 foropencv-${{github.ref_name}}-windows-cuda12.zip"
sha256sum opencv-${{github.ref_name}}-windows-cuda12.zip > opencv-${{github.ref_name}}-windows-cuda12.zip.sha256
shell: bash

- name: Upload SHA256 Checksum File
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: opencv-${{github.ref_name}}-windows-cuda12.zip.sha256
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

60 changes: 60 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build Windows

on: push

jobs:
build-windows:
runs-on: "windows-2019"
steps:
- name: Set up MSBuild path
uses: microsoft/[email protected]

- uses: actions/checkout@v2

- name: Download OpenCV repo/s
working-directory: scripts/windows
shell: cmd
run: .\download.bat options\options_opencv4.9.0_contrib_vc16.txt

- name: Build OpenCV
working-directory: scripts/windows
shell: cmd
run: .\build.bat options\options_opencv4.9.0_contrib_vc16.txt

- name: Remove build folder
uses: JesseTG/[email protected]
with:
path: build

- run: Compress-Archive -Path install/* -Destination opencv-${{github.ref_name}}-windows.zip

- name: Upload Release Asset
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: opencv-${{github.ref_name}}-windows.zip
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Calculate SHA256 Checksum
- name: Calculate SHA256 Checksum
run: |
echo "Calculating SHA256 for opencv-${{github.ref_name}}-windows.zip"
sha256sum opencv-${{github.ref_name}}-windows.zip > opencv-${{github.ref_name}}-windows.zip.sha256
shell: bash

- name: Upload SHA256 Checksum File
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: opencv-${{github.ref_name}}-windows.zip.sha256
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading