Skip to content

Commit a3497eb

Browse files
authored
[PATCH] Static libg++ linking fix (#854)
* bump version to 0.1.6 * phaseout py38 * py39 * Update submodule 'tvm' to latest commit adc0e48 * [Build] Update CMake and Python environment settings - Added static linking flags for GCC and libstdc++ in CMakeLists.txt to enhance library linking. - Removed the cmake version requirement from pyproject.toml to allow for broader compatibility. - Updated the tox command in the Docker distribution script to include Python 3.8 for testing environments. * [Build] Update Python version requirements in scripts and documentation - Changed Python version requirement in README.md from 3.9+ to 3.8+. - Updated installation and testing scripts to use Python 3.8 instead of 3.9, ensuring compatibility with the new minimum version. - Adjusted tox commands in local and PyPI distribution scripts to include Python 3.8 in the testing environments. * [Build] Update Python and CMake requirements in Dockerfile and pyproject.toml - Added CMake version requirement (>=3.26) to pyproject.toml for build compatibility. - Created a Python 3.8 environment in the Dockerfile and added a symlink for easier access to the Python 3.8 executable. * [Build] Update CMake and Dockerfile for improved compatibility - Removed static linking flags from CMakeLists.txt to simplify build configuration. - Updated Dockerfile to use Ubuntu 20.04 and streamlined the installation of dependencies, removing gcc-9 and g++-9. - Adjusted symlink creation for Python environments to use the `-sf` option for safer linking. * [Build] Bump version to 0.1.6.post1 for post-release updates * [Build] Remove static linking flags from CMakeLists.txt - Eliminated static linking flags for GCC and libstdc++ to simplify build configuration and avoid potential conflicts with Python extensions. * [Build] Update Docker distribution scripts for manylinux compatibility - Changed base image from `tilelang-builder:18.04` to `tilelang-builder:manylinux` in both local and PyPI distribution scripts. - Updated Dockerfile references to use `pypi.manylinux.Dockerfile`. - Added `--gpus all` flag to the Docker run command to enable GPU support during execution. * lint fix * add cmake
1 parent 1ad6e46 commit a3497eb

File tree

9 files changed

+63
-37
lines changed

9 files changed

+63
-37
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ project(TILE_LANG C CXX)
77
option(TILE_LANG_STATIC_STDCPP "Statically link libstdc++ for TileLang libraries" ON)
88
option(TILE_LANG_INSTALL_STATIC_LIB "Install the static library" ON)
99

10-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
11-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++")
12-
1310
if(TILE_LANG_STATIC_STDCPP)
1411
message(STATUS "Enabling static linking of C++ standard library")
1512
# Note: We'll apply static linking flags selectively to avoid Python extension conflicts

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.6
1+
0.1.6.post1
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Get the CUDA version from the command line
2-
IMAGE="tilelang-builder:18.04"
3-
docker build . -f "$(dirname "${BASH_SOURCE[0]}")/pypi.Dockerfile" --tag ${IMAGE}
2+
IMAGE="tilelang-builder:manylinux"
3+
docker build . -f "$(dirname "${BASH_SOURCE[0]}")/pypi.manylinux.Dockerfile" --tag ${IMAGE}
44

55
install_pip="python3.8 -m pip install --upgrade pip && python3.8 -m pip install -r requirements-build.txt"
66

77
tox_command="python3.8 -m tox -e py38,py39,py310,py311,py312"
88

9-
docker run --rm -v $(pwd):/tilelang ${IMAGE} /bin/bash -c "$install_pip && $tox_command"
9+
docker run --rm --gpus all -v $(pwd):/tilelang ${IMAGE} /bin/bash -c "$install_pip && $tox_command"
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Get the CUDA version from the command line
2-
IMAGE="tilelang-builder:18.04"
3-
docker build . -f "$(dirname "${BASH_SOURCE[0]}")/pypi.Dockerfile" --tag ${IMAGE}
2+
IMAGE="tilelang-builder:manylinux"
3+
docker build . -f "$(dirname "${BASH_SOURCE[0]}")/pypi.manylinux.Dockerfile" --tag ${IMAGE}
44

55
install_pip="python3.8 -m pip install --upgrade pip && python3.8 -m pip install -r requirements-build.txt"
66

7-
tox_command="python3.8 -m tox -e py38-pypi,py39-pypi,py310-pypi,py311-pypi,py312-pypi,audit_2_27"
7+
tox_command="python3.8 -m tox -e py38-pypi,py39-pypi,py310-pypi,py311-pypi,py312-pypi"
88

9-
docker run --rm -v $(pwd):/tilelang ${IMAGE} /bin/bash -c "$install_pip && $tox_command"
9+
docker run --rm --gpus all -v $(pwd):/tilelang ${IMAGE} /bin/bash -c "$install_pip && $tox_command"

maint/scripts/pypi.Dockerfile

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
FROM nvidia/cuda:12.1.0-devel-ubuntu18.04
1+
FROM nvidia/cuda:12.1.0-devel-ubuntu20.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive \
4+
TZ=Etc/UTC
25

36
RUN set -eux; \
47
apt-get update; \
5-
# Install gcc-9 and g++-9
68
apt-get install -y software-properties-common; \
79
add-apt-repository ppa:ubuntu-toolchain-r/test -y; \
810
apt-get update; \
911
apt-get install -y wget curl libtinfo-dev zlib1g-dev libssl-dev build-essential \
10-
libedit-dev libxml2-dev git gcc-9 g++-9; \
11-
# Switch default gcc/g++ to new version
12-
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100; \
13-
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100; \
14-
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100; \
15-
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100; \
16-
gcc --version; g++ --version; \
12+
libedit-dev libxml2-dev git; \
1713
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh; \
1814
bash Miniconda3-latest-Linux-x86_64.sh -b -p /miniconda3; \
1915
rm Miniconda3-latest-Linux-x86_64.sh;
@@ -23,7 +19,7 @@ RUN apt-get update && apt-get install -y ninja-build
2319
ENV PATH=/miniconda3/bin/:$PATH
2420

2521
# ✅ Accept Anaconda Terms of Service for both required channels
26-
RUN conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \
22+
RUN conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main; \
2723
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
2824

2925
# Create environments
@@ -33,11 +29,11 @@ RUN set -eux; \
3329
conda create -n py310 python=3.10 -y; \
3430
conda create -n py311 python=3.11 -y; \
3531
conda create -n py312 python=3.12 -y; \
36-
ln -s /miniconda3/envs/py38/bin/python3.8 /usr/bin/python3.8; \
37-
ln -s /miniconda3/envs/py39/bin/python3.9 /usr/bin/python3.9; \
38-
ln -s /miniconda3/envs/py310/bin/python3.10 /usr/bin/python3.10; \
39-
ln -s /miniconda3/envs/py311/bin/python3.11 /usr/bin/python3.11; \
40-
ln -s /miniconda3/envs/py312/bin/python3.12 /usr/bin/python3.12; \
32+
ln -sf /miniconda3/envs/py38/bin/python3.8 /usr/bin/python3.8; \
33+
ln -sf /miniconda3/envs/py39/bin/python3.9 /usr/bin/python3.9; \
34+
ln -sf /miniconda3/envs/py310/bin/python3.10 /usr/bin/python3.10; \
35+
ln -sf /miniconda3/envs/py311/bin/python3.11 /usr/bin/python3.11; \
36+
ln -sf /miniconda3/envs/py312/bin/python3.12 /usr/bin/python3.12; \
4137
conda install -y cmake patchelf
4238

4339
WORKDIR /tilelang
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM pytorch/manylinux-builder:cuda12.1
2+
3+
ENV DEBIAN_FRONTEND=noninteractive \
4+
TZ=Etc/UTC
5+
6+
RUN set -eux; \
7+
yum -y update && yum install -y \
8+
zlib-devel openssl-devel \
9+
libedit-devel libxml2-devel \
10+
bzip2 bzip2-devel xz xz-devel \
11+
epel-release
12+
13+
RUN set -eux; \
14+
conda create -n py38 python=3.8 -y && \
15+
conda create -n py39 python=3.9 -y && \
16+
conda create -n py310 python=3.10 -y && \
17+
conda create -n py311 python=3.11 -y && \
18+
conda create -n py312 python=3.12 -y && \
19+
ln -sf /opt/conda/envs/py38/bin/python3.8 /usr/bin/python3.8 && \
20+
ln -sf /opt/conda/envs/py39/bin/python3.9 /usr/bin/python3.9 && \
21+
ln -sf /opt/conda/envs/py310/bin/python3.10 /usr/bin/python3.10 && \
22+
ln -sf /opt/conda/envs/py311/bin/python3.11 /usr/bin/python3.11 && \
23+
ln -sf /opt/conda/envs/py312/bin/python3.12 /usr/bin/python3.12 && \
24+
conda install -y cmake patchelf
25+
26+
WORKDIR /tilelang

tilelang/transform/add_bufstore_wrapper.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from tvm.tir import (BufferStore, For, AttrStmt, ForKind, Var, PrimFunc, BufferLoad, Buffer, IntImm)
22
from tvm.tir.stmt_functor import ir_transform, post_order_visit
33
from tvm.tir.transform import prim_func_pass
4+
from typing import Tuple, List, Dict
45

56

67
def AddWrapperForSingleBufStore():
@@ -41,7 +42,7 @@ def visit_variable(node):
4142
post_order_visit(operation, visit_variable)
4243
return used_variables
4344

44-
def collect_buffer_accesses(statement) -> tuple[list[Buffer], list[Buffer]]:
45+
def collect_buffer_accesses(statement) -> Tuple[List[Buffer], List[Buffer]]:
4546
"""
4647
Categorizes buffers accessed in the statement by their scope.
4748
@@ -68,7 +69,7 @@ def visit_buffer_access(node):
6869
local_buffers.append(buffer)
6970
return local_buffers, fragment_buffers
7071

71-
def collect_buffer_indices(statement) -> dict[Buffer, list[int]]:
72+
def collect_buffer_indices(statement) -> Dict[Buffer, List[int]]:
7273
"""
7374
Maps each buffer to its access indices.
7475

tilelang/utils/sparse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import torch
33
import warnings
4-
from typing import Optional
4+
from typing import Optional, Tuple
55
from tilelang.contrib import nvcc
66
from torch.utils.cpp_extension import load, _import_module_from_library
77
from tilelang import env
@@ -44,7 +44,7 @@ def _get_cached_lib():
4444

4545

4646
def compress_sm90(A: torch.Tensor, block_k: int,
47-
transposed: bool) -> tuple[torch.Tensor, torch.Tensor]:
47+
transposed: bool) -> Tuple[torch.Tensor, torch.Tensor]:
4848
if block_k > 128:
4949
block_k = 128
5050
# Ref: https://github.com/NVIDIA/cutlass/blob/c2ad7c5b20f131c4ba33601860f1da3f9c9df0f3/include/cutlass/gemm/collective/builders/sm90_sparse_gmma_builder.inl#L145-L146
@@ -56,7 +56,7 @@ def compress_sm90(A: torch.Tensor, block_k: int,
5656
return compress_lib.compress_sm90(A, block_k, transposed)
5757

5858

59-
def compress_sm80(A: torch.Tensor, transposed: bool) -> tuple[torch.Tensor, torch.Tensor]:
59+
def compress_sm80(A: torch.Tensor, transposed: bool) -> Tuple[torch.Tensor, torch.Tensor]:
6060
try:
6161
from torch.sparse import to_sparse_semi_structured, SparseSemiStructuredTensor
6262
except ImportError as err:
@@ -76,7 +76,7 @@ def compress_sm80(A: torch.Tensor, transposed: bool) -> tuple[torch.Tensor, torc
7676
def compress(A: torch.Tensor,
7777
transposed: bool,
7878
arch: Optional[str] = None,
79-
**kwargs) -> tuple[torch.Tensor, torch.Tensor]:
79+
**kwargs) -> Tuple[torch.Tensor, torch.Tensor]:
8080
"""
8181
Compress a tensor using the appropriate method based on the CUDA architecture.
8282
"""

tox.ini

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
[tox]
22
envlist = py38,py39,py310,py311,py312
3-
isolated_build = True
3+
isolated_build = False
44

55
[testenv:py{38,39,310,311,312}]
6+
skip_install = false
67
deps =
78
wheel
89
build
10+
setenv =
11+
PYTHON_EXECUTABLE = {envpython}
12+
Python3_EXECUTABLE = {envpython}
913
commands =
1014
python -m build --wheel -o {toxinidir}/dist
1115

12-
1316
[testenv:py{38,39,310,311,312}-pypi]
17+
skip_install = false
1418
setenv =
1519
PYPI_BUILD = TRUE
20+
PYTHON_EXECUTABLE = {envpython}
21+
Python3_EXECUTABLE = {envpython}
1622
commands =
17-
python setup.py bdist_wheel
23+
python setup.py bdist_wheel --plat-name=manylinux2014_x86_64
1824

19-
[testenv:audit_2_27]
25+
[testenv:audit_manylinux2014]
2026
skip_install = true
2127
allowlist_externals =
2228
bash
2329
deps =
2430
auditwheel
2531
patchelf
2632
commands =
27-
bash -c 'auditwheel repair -L=/lib --exclude=/usr/local/cuda* --exclude=libcuda.so.1 --plat=manylinux_2_27_x86_64 dist/*'
33+
bash -c 'auditwheel repair -L=/lib --exclude=/usr/local/cuda* --exclude=libcuda.so.1 --plat=manylinux2014_x86_64 dist/*'
2834

2935
[testenv:py38]
3036
basepython = python3.8

0 commit comments

Comments
 (0)