Skip to content

Commit

Permalink
Add supports for Ubuntu 18.04 and other Linux Distro with GLIBC Versi…
Browse files Browse the repository at this point in the history
…on < 2.29 and cmake version < 3.15

Signed-off-by: ArchieMeng <[email protected]>
  • Loading branch information
ArchieMeng committed May 4, 2021
1 parent 22a8413 commit 9e984fe
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 13 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,32 @@ jobs:
cmake ../src
cmake --build . -j 2
ubuntu-1804: # no needs to install swig for it is already there
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: cache-vulkansdk
id: cache-vulkansdk
uses: actions/cache@v1
with:
path: "1.2.162.0"
key: vulkansdk-linux-x86_64-1.2.162.0
- name: vulkansdk
if: steps.cache-vulkansdk.outputs.cache-hit != 'true'
run: |
wget https://sdk.lunarg.com/sdk/download/1.2.162.0/linux/vulkansdk-linux-x86_64-1.2.162.0.tar.gz?Human=true -O vulkansdk-linux-x86_64-1.2.162.0.tar.gz
tar -xf vulkansdk-linux-x86_64-1.2.162.0.tar.gz
rm -rf 1.2.162.0/source 1.2.162.0/samples
find 1.2.162.0 -type f | grep -v -E 'vulkan|glslang' | xargs rm
- name: build
run: |
export VULKAN_SDK=`pwd`/1.2.162.0/x86_64
mkdir build && cd build
cmake ../src
cmake --build . -j 2
macos:
runs-on: macos-latest
steps:
Expand Down
75 changes: 65 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
env:
DEVELOPER_DIR: /Applications/Xcode_12.2.app/Contents/Developer
APPLICATION_NAME: srmd-ncnn-vulkan-python
APPNAME_SHORT: srmd

jobs:

Expand Down Expand Up @@ -55,9 +56,9 @@ jobs:
run: |
mkdir -p ${{ env.PACKAGENAME }}
cp README.md LICENSE ${{ env.PACKAGENAME }}
cp build/srmd_ncnn_vulkan.py ${{ env.PACKAGENAME }}
cp build/srmd_ncnn_vulkan_wrapper.py ${{ env.PACKAGENAME }}
cp build/_srmd_ncnn_vulkan_wrapper.so ${{ env.PACKAGENAME }}
cp build/${{ env.APPNAME_SHORT }}_ncnn_vulkan.py ${{ env.PACKAGENAME }}
cp build/${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.py ${{ env.PACKAGENAME }}
cp build/_${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.so ${{ env.PACKAGENAME }}
cp -r models/ ${{ env.PACKAGENAME }}
zip -9 -r ${{ env.PACKAGENAME }}.zip ${{ env.PACKAGENAME }}
- name: upload
Expand All @@ -66,6 +67,49 @@ jobs:
name: ${{ env.PACKAGENAME }}
path: ${{ env.PACKAGENAME }}.zip

ubuntu-1804:
needs: [setup]
runs-on: ubuntu-18.04
env:
PACKAGENAME: ${{ needs.setup.outputs.APPNAME }}-${{ needs.setup.outputs.VERSION }}-ubuntu-1804
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: cache-vulkansdk
id: cache-vulkansdk
uses: actions/cache@v1
with:
path: "1.2.162.0"
key: vulkansdk-linux-x86_64-1.2.162.0
- name: vulkansdk
if: steps.cache-vulkansdk.outputs.cache-hit != 'true'
run: |
wget https://sdk.lunarg.com/sdk/download/1.2.162.0/linux/vulkansdk-linux-x86_64-1.2.162.0.tar.gz?Human=true -O vulkansdk-linux-x86_64-1.2.162.0.tar.gz
tar -xf vulkansdk-linux-x86_64-1.2.162.0.tar.gz
rm -rf 1.2.162.0/source 1.2.162.0/samples
find 1.2.162.0 -type f | grep -v -E 'vulkan|glslang' | xargs rm
- name: build
run: |
export VULKAN_SDK=`pwd`/1.2.162.0/x86_64
mkdir build && cd build
cmake ../src
cmake --build . -j 2
- name: package
run: |
mkdir -p ${{ env.PACKAGENAME }}
cp README.md LICENSE ${{ env.PACKAGENAME }}
cp build/${{ env.APPNAME_SHORT }}_ncnn_vulkan.py ${{ env.PACKAGENAME }}
cp build/${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.py ${{ env.PACKAGENAME }}
cp build/_${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.so ${{ env.PACKAGENAME }}
cp -r models/ ${{ env.PACKAGENAME }}
zip -9 -r ${{ env.PACKAGENAME }}.zip ${{ env.PACKAGENAME }}
- name: upload
uses: actions/upload-artifact@v2
with:
name: ${{ env.PACKAGENAME }}
path: ${{ env.PACKAGENAME }}.zip

openmp-macos:
runs-on: macos-latest
steps:
Expand Down Expand Up @@ -182,9 +226,9 @@ jobs:
run: |
mkdir -p ${{ env.PACKAGENAME }}
cp README.md LICENSE ${{ env.PACKAGENAME }}
cp build-x86_64/srmd_ncnn_vulkan.py ${{ env.PACKAGENAME }}
cp build-x86_64/srmd_ncnn_vulkan_wrapper.py ${{ env.PACKAGENAME }}
cp build-x86_64/_srmd_ncnn_vulkan_wrapper.so ${{ env.PACKAGENAME }}
cp build-x86_64/${{ env.APPNAME_SHORT }}_ncnn_vulkan.py ${{ env.PACKAGENAME }}
cp build-x86_64/${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.py ${{ env.PACKAGENAME }}
cp build-x86_64/_${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.so ${{ env.PACKAGENAME }}
cp -r models/ ${{ env.PACKAGENAME }}
zip -9 -r ${{ env.PACKAGENAME }}.zip ${{ env.PACKAGENAME }}
- name: upload
Expand Down Expand Up @@ -241,9 +285,9 @@ jobs:
ls build
Copy-Item -Verbose -Path "README.md" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "LICENSE" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "src\srmd_ncnn_vulkan.py" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "build\srmd_ncnn_vulkan_wrapper.py" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "build\Release\_srmd_ncnn_vulkan_wrapper.pyd" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "src\${{ env.APPNAME_SHORT }}_ncnn_vulkan.py" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "build\${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.py" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "build\Release\_${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.pyd" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "C:\windows\system32\vcomp140.dll" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Recurse -Path "models" -Destination "${{ env.PACKAGENAME }}"
7z a -r ${{ env.PACKAGENAME }}.zip ${{ env.PACKAGENAME }}
Expand All @@ -254,7 +298,7 @@ jobs:
path: ${{ env.PACKAGENAME }}.zip

release:
needs: [setup, ubuntu, macos, windows]
needs: [setup, ubuntu, ubuntu-1804, macos, windows]
runs-on: ubuntu-latest
steps:
- name: download
Expand Down Expand Up @@ -284,6 +328,17 @@ jobs:
asset_name: ${{ env.PACKAGENAME }}.zip
asset_content_type: application/zip

- name: upload-ubuntu-1804
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGENAME: ${{ needs.setup.outputs.APPNAME }}-${{ needs.setup.outputs.VERSION }}-ubuntu-1804
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/${{ env.PACKAGENAME }}/${{ env.PACKAGENAME }}.zip
asset_name: ${{ env.PACKAGENAME }}.zip
asset_content_type: application/zip

- name: upload-macos
uses: actions/upload-release-asset@v1
env:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ linux x64, Windows x64 and MacOS x64 releases are available now. For other platf
The reason why MacOS ARM64 build is not available is that it needs ARM Python Dev Libs which I have no ideas on how to
get it on Github's MacOS x64 VM. Moreover, I don't have a Mac.

**However, for Linux (Like Ubuntu 18.04) with an older GLIBC (version < 2.29), you may try to use the ubuntu-1804 release or just compile it on your own.**

## Build

First, you have to install python, python development package (Python native development libs in Visual Studio), vulkan SDK and SWIG on your platform. And then:
Expand Down
17 changes: 14 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0091 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

project(srmd-ncnn-vulkan-python)

# Python
if (${CMAKE_VERSION} VERSION_LESS "3.15")
find_package(Python REQUIRED)
else()
find_package(Python REQUIRED COMPONENTS Development)
endif()

# SWIG
find_package(Python REQUIRED COMPONENTS Development)
find_package(SWIG REQUIRED COMPONENTS python)
if(SWIG_FOUND)
message("SWIG found: ${SWIG_EXECUTABLE}")
Expand Down Expand Up @@ -273,4 +279,9 @@ include_directories(.)
swig_add_library(srmd_ncnn_vulkan_wrapper LANGUAGE python SOURCES srmd.i srmd.cpp srmd_wrapper.cpp)
add_dependencies(srmd_ncnn_vulkan_wrapper generate-spirv)
target_compile_options(srmd_ncnn_vulkan_wrapper PUBLIC -fexceptions)
target_link_libraries(srmd_ncnn_vulkan_wrapper ${SRMD_LINK_LIBRARIES} Python::Module)
if (${CMAKE_VERSION} VERSION_LESS "3.15")
include_directories(${PYTHON_INCLUDE_DIRS})
target_link_libraries(srmd_ncnn_vulkan_wrapper ${SRMD_LINK_LIBRARIES} ${PYTHON_LIBRARIES})
else()
target_link_libraries(srmd_ncnn_vulkan_wrapper ${SRMD_LINK_LIBRARIES} Python::Module)
endif()

0 comments on commit 9e984fe

Please sign in to comment.