mirror of
https://github.com/ROCm/ROCm.git
synced 2026-04-05 03:01:17 -04:00
[FRONTEND] Update path for headers to support Python 3.10 (#1123)
Python 3.10 changes where packages are installed by default, causing problems with Ubuntu into `/local`. See [this](https://lists.debian.org/debian-python/2022/03/msg00039.html) and [this](https://bugs.launchpad.net/ubuntu/+source/python3.10/+bug/1967920). Triton seems to break when using 3.10 as it looks for the headers, but the headers are not in `/local`, e.g. they are at `/usr/include/python3.X` and not `/usr/local/include/python3.X` Not 100% sure what's going on here since it's deep in python / pip, but I think this should fix it. Otherwise, you have to hack around it in dockerfiles, e.g. `ENV DEB_PYTHON_INSTALL_LAYOUT=deb`, which breaks things with the release of pip that went. --------- Co-authored-by: Keren Zhou <kerenzhou@openai.com>
This commit is contained in:
@@ -16,7 +16,6 @@ import tempfile
|
||||
import warnings
|
||||
from collections import namedtuple
|
||||
from pathlib import Path
|
||||
from sysconfig import get_paths
|
||||
from typing import Any, Callable, Dict, Tuple, Union
|
||||
|
||||
import setuptools
|
||||
@@ -1393,7 +1392,16 @@ def _build(name, src, srcdir):
|
||||
cc = gcc if gcc is not None else clang
|
||||
if cc is None:
|
||||
raise RuntimeError("Failed to find C compiler. Please specify via CC environment variable.")
|
||||
py_include_dir = get_paths()["include"]
|
||||
# This function was renamed and made public in Python 3.10
|
||||
if hasattr(sysconfig, 'get_default_scheme'):
|
||||
scheme = sysconfig.get_default_scheme()
|
||||
else:
|
||||
scheme = sysconfig._get_default_scheme()
|
||||
# 'posix_local' is a custom scheme on Debian. However, starting Python 3.10, the default install
|
||||
# path changes to include 'local'. This change is required to use triton with system-wide python.
|
||||
if scheme == 'posix_local':
|
||||
scheme = 'posix_prefix'
|
||||
py_include_dir = sysconfig.get_paths(scheme=scheme)["include"]
|
||||
|
||||
cc_cmd = [cc, src, "-O3", f"-I{cu_include_dir}", f"-I{py_include_dir}", f"-I{srcdir}", "-shared", "-fPIC", "-lcuda", "-o", so]
|
||||
cc_cmd += [f"-L{dir}" for dir in cuda_lib_dirs]
|
||||
|
||||
Reference in New Issue
Block a user