Skip to content

Commit

Permalink
[ci] Add custom gpu call for linux wheel (#12)
Browse files Browse the repository at this point in the history
* Update Publish.yml

* Update Publish.yml

* Update Publish.yml

* Update Publish.yml

* Update Publish.yml

* Update pyproject.toml

* Update pyproject.toml

* Update Publish.yml

* Update pyproject.toml

* Update pyproject.toml

* Update requirements-dev.txt

* Update Publish.yml

* Fix macos and windows

* Update Publish.yml

* Update Publish.yml

* Update Publish.yml

* Update permission

* Update Publish.yml

* Update Publish.yml

* Update

* Update Publish.yml

* Update

* Update

* Update

* Update pyproject.toml

* Update pyproject.toml

* Fix python version compat

* Update pyproject.toml

* Update Publish.yml

* Update

* Update

* Update prepare_build_wheel_on_cuda.sh

* Update prepare_build_wheel_on_cuda.sh

* Update prepare_build_wheel_on_cuda.sh

* Update prepare_build_wheel_on_cuda.sh

* Update prepare_build_wheel_on_cuda.sh

* Update

* Update prepare_build_wheel_on_cuda.sh

* Update prepare_build_wheel_on_cuda.sh

* Update setup_cuda.py
  • Loading branch information
Routhleck authored Sep 12, 2024
1 parent 4bca395 commit 71c9f1a
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 118 deletions.
54 changes: 9 additions & 45 deletions .github/workflows/Publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ on:
required: false
jobs:
# Define test jobs as part of the publish workflow
test_linux:
name: Test on Linux
test_linux_cpu:
name: Test on Linux(CPU)
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -40,10 +40,11 @@ jobs:
run: |
pip install dist/*.whl
pytest tests/
build_linux_cpu:
build_linux:
name: Build on Linux(CPU)
runs-on: ubuntu-latest
needs: [test_linux]
needs: [test_linux_cpu]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -63,41 +64,10 @@ jobs:
- name: Archive Wheel Artifacts
uses: actions/upload-artifact@v3
with:
name: dist-linux-cpu
name: dist-linux
path: dist/*.whl
retention-days: 20

# build_linux_gpu:
# name: Build on Linux(GPU)
# runs-on: ubuntu-latest
# needs: [test_linux]
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Set up Python 3.9
# uses: actions/setup-python@v5
# with:
# python-version: 3.9
# - name: Install dependencies
# run: |
# python -m pip cache purge
# python -m pip install --upgrade pip setuptools --no-cache-dir
# python -m pip install -r requirements-dev.txt --no-cache-dir
# python -m pip install setuptools==68.2.0
# pip install cibuildwheel
# - name: Build Wheel
# run: |
# rm -rf setup.py
# cp setup_cuda.py setup.py
# cibuildwheel --platform linux
# mkdir dist
# cp wheelhouse/*.whl dist/
# - name: Archive Wheel Artifacts
# uses: actions/upload-artifact@v3
# with:
# name: dist-linux-gpu
# path: dist/*.whl
# retention-days: 20

build_and_test_macos_arm:
name: Build and Test on macOS(ARM)
runs-on: macos-latest
Expand Down Expand Up @@ -206,7 +176,7 @@ jobs:
publish_pypi:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: [build_linux_cpu, build_and_test_macos_arm, build_and_test_windows]
needs: [build_linux, build_and_test_macos_arm, build_and_test_windows]
permissions:
id-token: write
contents: write
Expand All @@ -217,14 +187,8 @@ jobs:
- name: Download linux(CPU) Artifacts
uses: actions/download-artifact@v3
with:
name: dist-linux-cpu
name: dist-linux
path: dist/

# - name: Download linux(GPU) Artifacts
# uses: actions/download-artifact@v3
# with:
# name: dist-linux-gpu
# path: dist/

- name: Download macOS(ARM) Artifacts
uses: actions/download-artifact@v3
Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ include_directories(${CMAKE_CURRENT_LIST_DIR}/lib)

if (BRAINPY_CUDA)
find_package(CUDAToolkit REQUIRED)
find_library(CUDA_DRIVER_LIBRARY cuda PATHS /usr/lib/x86_64-linux-gnu /usr/lib64)
enable_language(CUDA)
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
pybind11_add_module(
Expand All @@ -55,7 +54,6 @@ if (BRAINPY_CUDA)
)
target_link_libraries(gpu_ops PRIVATE Taichi::Runtime)
# target_link_libraries(gpu_ops PRIVATE ${PYTHON_LIBRARIES})
target_link_libraries(gpu_ops PRIVATE ${CUDA_DRIVER_LIBRARY})
install(TARGETS gpu_ops DESTINATION braintaichi)
else()
message(STATUS "Building without CUDA")
Expand Down
2 changes: 1 addition & 1 deletion braintaichi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'__minimal_taichi_version__',
]

__version__ = "0.0.1"
__version__ = "0.0.1.post20240912"
__minimal_taichi_version__ = (1, 7, 2)

import ctypes
Expand Down
67 changes: 8 additions & 59 deletions ci/linux/gpu/prepare_build_wheel_on_cuda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,71 +8,20 @@ rm setup.py
mv setup_cuda.py setup.py
# mv setup_cpu.py setup.py

# https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/

# Install CUDA 11.2, see:
# * https://gitlab.com/nvidia/container-images/cuda/-/blob/master/dist/11.2.2/centos7-x86_64/base/Dockerfile
# * https://gitlab.com/nvidia/container-images/cuda/-/blob/master/dist/11.2.2/centos7-x86_64/devel/Dockerfile
#yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
#yum install --setopt=obsoletes=0 -y \
# cuda-nvcc-11-2-11.2.152-1 \
# cuda-cudart-devel-11-2-11.2.152-1 \
# libcurand-devel-11-2-10.2.3.152-1 \
# libcudnn8-devel-8.1.1.33-1.cuda11.2 \
# libcublas-devel-11-2-11.4.1.1043-1
#ln -s cuda-11.2 /usr/local/cuda
#
#yum install -y python3-devel.x86_64


# Install CUDA 11.4
#yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
#yum install --setopt=obsoletes=0 -y \
# cuda-nvcc-11-4-11.4.152-1 \
# cuda-cudart-devel-11-4-11.4.148-1 \
# libcurand-devel-11-4-10.2.5.120-1 \
# libcudnn8-devel-8.2.4.15-1.cuda11.4 \
# libcublas-devel-11-4-11.6.5.2-1
#ln -s cuda-11.4 /usr/local/cuda
#
#yum install -y python3-devel.x86_64


# Install CUDA 11.6
# sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
#yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
#yum install --setopt=obsoletes=0 -y \
# cuda-nvcc-11-6-11.6.124-1 \
# cuda-cudart-devel-11-6-11.6.55-1 \
# libcurand-devel-11-6-10.2.9.124-1 \
# libcudnn8-devel-8.4.1.50-1.cuda11.6 \
# libcublas-devel-11-6-11.9.2.110-1
#ln -s cuda-11.6 /usr/local/cuda


# Install CUDA 11.8
# yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
# yum install --setopt=obsoletes=0 -y \
# cuda-nvcc-11-8-11.8.89-1 \
# cuda-cudart-devel-11-8-11.8.89-1 \
# libcurand-devel-11-8-10.3.0.86-1\
# libcudnn8-devel-8.8.0.121-1.cuda11.8 \
# libcublas-devel-11-8-11.11.3.6-1
# ln -s cuda-11.8 /usr/local/cuda

# yum install -y python3-devel.x86_64
yum -y install yum-utils

# Install CUDA 12.0
yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo

yum install --setopt=obsoletes=0 -y \
cuda-drivers-525.147.05-1.x86_64 \
cuda-nvcc-12-0-12.0.140-1 \
cuda-cudart-devel-12-0-12.0.146-1
ln -s cuda-12.0 /usr/local/cuda
cuda-nvcc-12-4-12.4.131-1 \
cuda-cudart-devel-12-4-12.4.127-1 \

ln -s cuda-12.4 /usr/local/cuda

yum install glibc-devel
# yum install glibc-devel

yum install --disableplugin=fastmirror -y python3-devel.x86_64
yum install -y python3-devel

pip_config_dir="${HOME}/.pip"
pip_config_file="${pip_config_dir}/pip.conf"
Expand Down
2 changes: 1 addition & 1 deletion ci/linux/gpu/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-backend = "setuptools.build_meta"
[project]
requires-python = ">=3.8, <=3.12"
name = "braintaichi"
version = "0.0.1"
version = "0.0.1.post20240912"

[tool.cibuildwheel.linux]
before-all = "sh prepare_build_wheel_on_cuda.sh"
Expand Down
2 changes: 1 addition & 1 deletion ci/mac/arm64/pyproject3.10.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-backend = "setuptools.build_meta"
[project]
requires-python = ">=3.10, <3.11"
name = "braintaichi"
version = "0.0.1"
version = "0.0.1.post20240912"

[tool.cibuildwheel.linux]
before-all = "sh prepare_build_wheel_on_cuda.sh"
Expand Down
2 changes: 1 addition & 1 deletion ci/mac/arm64/pyproject3.11.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-backend = "setuptools.build_meta"
[project]
requires-python = ">=3.11, <3.12"
name = "braintaichi"
version = "0.0.1"
version = "0.0.1.post20240912"

[tool.cibuildwheel.linux]
before-all = "sh prepare_build_wheel_on_cuda.sh"
Expand Down
2 changes: 1 addition & 1 deletion ci/mac/arm64/pyproject3.12.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-backend = "setuptools.build_meta"
[project]
requires-python = ">=3.12, <3.13"
name = "braintaichi"
version = "0.0.1"
version = "0.0.1.post20240912"

[tool.cibuildwheel.linux]
before-all = "sh prepare_build_wheel_on_cuda.sh"
Expand Down
2 changes: 1 addition & 1 deletion ci/mac/arm64/pyproject3.9.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-backend = "setuptools.build_meta"
[project]
requires-python = ">=3.9, <3.10"
name = "braintaichi"
version = "0.0.1"
version = "0.0.1.post20240912"

[tool.cibuildwheel.linux]
before-all = "sh prepare_build_wheel_on_cuda.sh"
Expand Down
2 changes: 1 addition & 1 deletion ci/mac/x86_64/pyproject3.10.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-backend = "setuptools.build_meta"
[project]
requires-python = ">=3.10, <3.11"
name = "braintaichi"
version = "0.0.1"
version = "0.0.1.post20240912"

[tool.cibuildwheel.linux]
before-all = "sh prepare_build_wheel_on_cuda.sh"
Expand Down
2 changes: 1 addition & 1 deletion ci/mac/x86_64/pyproject3.11.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-backend = "setuptools.build_meta"
[project]
requires-python = ">=3.11, <3.12"
name = "braintaichi"
version = "0.0.1"
version = "0.0.1.post20240912"

[tool.cibuildwheel.linux]
before-all = "sh prepare_build_wheel_on_cuda.sh"
Expand Down
2 changes: 1 addition & 1 deletion ci/mac/x86_64/pyproject3.12.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-backend = "setuptools.build_meta"
[project]
requires-python = ">=3.12, <3.13"
name = "braintaichi"
version = "0.0.1"
version = "0.0.1.post20240912"

[tool.cibuildwheel.linux]
before-all = "sh prepare_build_wheel_on_cuda.sh"
Expand Down
2 changes: 1 addition & 1 deletion ci/mac/x86_64/pyproject3.9.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-backend = "setuptools.build_meta"
[project]
requires-python = ">=3.9, <3.10"
name = "braintaichi"
version = "0.0.1"
version = "0.0.1.post20240912"

[tool.cibuildwheel.linux]
before-all = "sh prepare_build_wheel_on_cuda.sh"
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ build-backend = "setuptools.build_meta"
[project]
requires-python = ">=3.8, <=3.12"
name = "braintaichi"
version = "0.0.1"
version = "0.0.1.post20240912"

[tool.cibuildwheel.linux]
# before-all = "sh prepare_build_wheel_on_cuda.sh"
before-all = "sh ci/linux/gpu/prepare_build_wheel_on_cuda.sh"
before-build = "sh copy_so_linux.sh"
#before-build = "pip install -r requirements-test.txt"
archs = ["x86_64"]
Expand Down
7 changes: 7 additions & 0 deletions setup_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import glob
import os
import io
import platform
import re
import subprocess
Expand Down Expand Up @@ -62,6 +63,10 @@

HERE = os.path.dirname(os.path.realpath(__file__))

# obtain long description from README
here = os.path.abspath(os.path.dirname(__file__))
with io.open(os.path.join(here, 'README.md'), 'r', encoding='utf-8') as f:
README = f.read()

# This custom class for building the extensions uses CMake to compile. You
# don't have to use CMake for this task, but I found it to be the easiest when
Expand Down Expand Up @@ -156,6 +161,8 @@ def build_extension(self, ext):
name='braintaichi',
version=__version__,
description='Leveraging Taichi Lang to customize brain dynamics operators',
long_description=README,
long_description_content_type="text/markdown",
author='BrainTaichi Developers',
author_email='[email protected]',
packages=find_namespace_packages(exclude=['lib*', 'docs*', 'tests*', 'win_dll*', 'out*', 'cmake*', 'scripts*']),
Expand Down

0 comments on commit 71c9f1a

Please sign in to comment.