-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add build script and release workflow (#9)
- Loading branch information
Showing
18 changed files
with
574 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Language: Cpp | ||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: Align | ||
AllowShortEnumsOnASingleLine: false | ||
AlignConsecutiveAssignments: true | ||
AlignConsecutiveDeclarations: true | ||
AlignEscapedNewlines: Right | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowAllArgumentsOnNextLine: true | ||
AllowShortBlocksOnASingleLine: Empty | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: Empty | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: true | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BreakBeforeBinaryOperators: NonAssignment | ||
BreakBeforeBraces: Stroustrup | ||
BreakBeforeTernaryOperators: false | ||
BreakConstructorInitializers: AfterColon | ||
BreakInheritanceList: AfterColon | ||
BreakStringLiterals: false | ||
ColumnLimit: 120 | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
FixNamespaceComments: true | ||
IndentCaseLabels: true | ||
IndentPPDirectives: None | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
PointerAlignment: Left | ||
ReflowComments: true | ||
SortIncludes: true | ||
SortUsingDeclarations: false | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterTemplateKeyword: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCtorInitializerColon: false | ||
SpaceBeforeInheritanceColon: false | ||
SpaceBeforeParens: ControlStatements | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 2 | ||
SpacesInAngles: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInContainerLiterals: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: c++17 | ||
TabWidth: 4 | ||
UseTab: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
name: cuda11.8-whl-release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
linux-build: | ||
strategy: | ||
matrix: | ||
pyver: [py38, py39, py310, py311, py312] | ||
runs-on: ubuntu-latest | ||
env: | ||
PYTHON_VERSION: ${{ matrix.pyver }} | ||
PLAT_NAME: manylinux2014_x86_64 | ||
DOCKER_TAG: cuda11.8 | ||
OUTPUT_FOLDER: cuda11.8_dist | ||
CUDA_VER: 11.8 | ||
steps: | ||
- name: Free disk space | ||
uses: jlumbroso/free-disk-space@main | ||
with: | ||
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB | ||
tool-cache: false | ||
docker-images: false | ||
# All of these default to true, but feel free to set to "false" if necessary for your workflow | ||
android: true | ||
dotnet: true | ||
haskell: true | ||
large-packages: true | ||
swap-storage: false | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Build | ||
run: | | ||
echo ${PYTHON_VERSION} | ||
echo ${PLAT_NAME} | ||
echo ${DOCKER_TAG} | ||
echo ${OUTPUT_FOLDER} | ||
# remove -it | ||
sed -i 's/docker run --rm -it/docker run --rm/g' builder/manylinux/build_wheel.sh | ||
bash builder/manylinux/build_wheel.sh ${PYTHON_VERSION} ${PLAT_NAME} ${DOCKER_TAG} ${OUTPUT_FOLDER} | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
if-no-files-found: error | ||
path: builder/manylinux/${{ env.OUTPUT_FOLDER }}/* | ||
retention-days: 1 | ||
name: linux-${{ matrix.pyver }} | ||
|
||
windows-build: | ||
strategy: | ||
matrix: | ||
pyver: ['3.8', '3.9', '3.10', '3.11', '3.12'] | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Set up python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.pyver }} | ||
- name: Install python packages | ||
run: | | ||
pip install pybind11 wheel | ||
- name: Setup CUDA Toolkit | ||
id: cuda-toolkit | ||
shell: pwsh | ||
run: ./builder/windows/setup_cuda.ps1 | ||
env: | ||
INPUT_CUDA_VERSION: '11.8.0' | ||
- name: Build wheel | ||
run: | | ||
mkdir build | ||
cd build | ||
pip install -U setuptools | ||
..\builder\windows\generate.ps1 | ||
cmake --build . --config Release -- /m /v:q | ||
if (-Not $?) { | ||
echo "build failed" | ||
exit 1 | ||
} | ||
cmake --install . --config Release | ||
cd .. | ||
rm build -Force -Recurse | ||
python setup.py bdist_wheel -d build/wheel | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
if-no-files-found: error | ||
path: build/wheel/* | ||
retention-days: 1 | ||
name: windows-${{ matrix.pyver }} | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
environment: 'prod' | ||
needs: | ||
- linux-build | ||
- windows-build | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: artifact | ||
merge-multiple: true | ||
- name: Add cuda version to package name | ||
run: | | ||
ver=$(cat turbomind/version.py | grep '__version__ =' | cut -d\' -f2) | ||
cuver=$ver+cu118 | ||
ls -lh | ||
cd artifact | ||
for file in *; do | ||
mv "$file" "`echo $file | sed "s/$ver/$cuver/g"`"; | ||
done | ||
- name: Display artifacts | ||
run: ls artifact/ -lh | ||
- name: Publish | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: artifact/* |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
name: publish to pypi | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "turbomind/version.py" | ||
workflow_dispatch: | ||
|
||
|
||
jobs: | ||
linux-build: | ||
strategy: | ||
matrix: | ||
pyver: [py38, py39, py310, py311, py312] | ||
runs-on: ubuntu-latest | ||
env: | ||
PYTHON_VERSION: ${{ matrix.pyver }} | ||
PLAT_NAME: manylinux2014_x86_64 | ||
DOCKER_TAG: cuda12.1 | ||
OUTPUT_FOLDER: cuda12.1_dist | ||
steps: | ||
- name: Free disk space | ||
uses: jlumbroso/free-disk-space@main | ||
with: | ||
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB | ||
tool-cache: false | ||
docker-images: false | ||
# All of these default to true, but feel free to set to "false" if necessary for your workflow | ||
android: true | ||
dotnet: true | ||
haskell: true | ||
large-packages: true | ||
swap-storage: false | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Build | ||
run: | | ||
echo ${PYTHON_VERSION} | ||
echo ${PLAT_NAME} | ||
echo ${DOCKER_TAG} | ||
echo ${OUTPUT_FOLDER} | ||
# remove -it | ||
sed -i 's/docker run --rm -it/docker run --rm/g' builder/manylinux/build_wheel.sh | ||
bash builder/manylinux/build_wheel.sh ${PYTHON_VERSION} ${PLAT_NAME} ${DOCKER_TAG} ${OUTPUT_FOLDER} | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
if-no-files-found: error | ||
path: builder/manylinux/${{ env.OUTPUT_FOLDER }}/* | ||
retention-days: 1 | ||
name: linux-${{ matrix.pyver }} | ||
|
||
windows-build: | ||
strategy: | ||
matrix: | ||
pyver: ['3.8', '3.9', '3.10', '3.11', '3.12'] | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Set up python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.pyver }} | ||
- name: Install python packages | ||
run: | | ||
pip install -r requirements/build.txt | ||
pip install wheel | ||
- name: Setup CUDA Toolkit | ||
id: cuda-toolkit | ||
shell: pwsh | ||
run: ./builder/windows/setup_cuda.ps1 | ||
env: | ||
INPUT_CUDA_VERSION: '12.1.0' | ||
- name: Build wheel | ||
run: | | ||
mkdir build | ||
cd build | ||
# https://github.com/pypa/setuptools/issues/1631 | ||
pip install -U setuptools | ||
..\builder\windows\generate.ps1 | ||
cmake --build . --config Release -- /m /v:q | ||
if (-Not $?) { | ||
echo "build failed" | ||
exit 1 | ||
} | ||
cmake --install . --config Release | ||
cd .. | ||
rm build -Force -Recurse | ||
python setup.py bdist_wheel -d build/wheel | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
if-no-files-found: error | ||
path: build/wheel/* | ||
retention-days: 1 | ||
name: windows-${{ matrix.pyver }} | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
environment: 'prod' | ||
needs: | ||
- linux-build | ||
- windows-build | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: artifact | ||
merge-multiple: true | ||
- name: Display artifacts | ||
run: ls artifact/ -lh | ||
- name: Set up python3.8 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.8' | ||
- name: Upload to pypi | ||
run: | | ||
pip install twine | ||
twine upload artifact/* -u __token__ -p ${{ secrets.pypi_password }} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
set -eux | ||
|
||
PYTHON_VERSION="$1" | ||
PLAT_NAME="$2" | ||
DOCKER_TAG="$3" | ||
OUTPUT_DIR="$4" | ||
|
||
DOCKER_IMAGE="openmmlab/lmdeploy-builder:${DOCKER_TAG}" | ||
export USERID=$(id -u) | ||
export GROUPID=$(id -g) | ||
|
||
cd "$(dirname "$0")" # move inside the script directory | ||
mkdir -p "${OUTPUT_DIR}" | ||
docker pull ${DOCKER_IMAGE} | ||
docker run --rm -it \ | ||
--env PYTHON_VERSION="${PYTHON_VERSION}" \ | ||
--env PLAT_NAME="${PLAT_NAME}" \ | ||
--env USERID="${USERID}" \ | ||
--env GROUPID="${GROUPID}" \ | ||
--volume "$(pwd)/../../:/turbomind" \ | ||
--volume "$(pwd)/${OUTPUT_DIR}:/turbomind_build" \ | ||
--volume "$(pwd)/entrypoint_build.sh:/entrypoint_build.sh" \ | ||
--entrypoint /entrypoint_build.sh \ | ||
${DOCKER_IMAGE} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
set -eux | ||
|
||
export PYTHON_VERSION=$PYTHON_VERSION | ||
export PLAT_NAME=$PLAT_NAME | ||
export USERID=${USERID} | ||
export GROUPID=${GROUPID} | ||
export CUDAVER=$(nvcc --version | sed -n 's/^.*release \([0-9]\+\).*$/\1/p') | ||
|
||
source /opt/conda/bin/activate | ||
conda activate $PYTHON_VERSION | ||
|
||
cd turbomind | ||
rm -rf turbomind/lib | ||
mkdir -p build && cd build && rm -rf * | ||
bash ../generate.sh make | ||
make -j$(nproc) && make install | ||
if [ $? != 0 ]; then | ||
echo "build failed" | ||
exit 1 | ||
fi | ||
cd .. | ||
rm -rf build | ||
python setup.py bdist_wheel --cuda=${CUDAVER} --plat-name $PLAT_NAME -d /tmpbuild/ | ||
chown ${USERID}:${GROUPID} /tmpbuild/* | ||
mv /tmpbuild/* /turbomind_build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake .. -A x64 -T "v142,cuda=$env:CUDA_PATH" ` | ||
-DCMAKE_BUILD_TYPE=Release ` | ||
-DCMAKE_INSTALL_PREFIX=install ` | ||
-DBUILD_PY_FFI=ON ` | ||
-DBUILD_MULTI_GPU=OFF ` | ||
-DCMAKE_CUDA_FLAGS="-lineinfo" ` | ||
-DUSE_NVTX=ON ` | ||
-DBUILD_TEST="$env:BUILD_TEST" |
Oops, something went wrong.