Skip to content

Commit 0231710

Browse files
author
zhoujiamei
committed
fix utils for metax
1 parent 27cda22 commit 0231710

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

.github/workflows/functional_tests_common.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,14 @@ jobs:
6666
6767
- name: Setup Python environment
6868
env:
69-
MACA_HOME: /opt/maca
70-
CUDA_HOME: /opt/maca
71-
NVTE_WITH_CUDA: '0'
69+
7270
NVTE_WITH_MACA: '1'
71+
NVTE_WITH_CUDA: '0'
7372
NVCC: /opt/maca/bin/mcc
74-
PATH: /opt/maca/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
73+
CUDA_HOME: /opt/maca
74+
75+
PATH: /opt/maca/bin:${{ env.PATH }}
76+
LD_LIBRARY_PATH: /opt/maca/lib:${{ env.LD_LIBRARY_PATH }}
7577
run: |
7678
set -euo pipefail
7779
cd $PROJECT_ROOT

build_tools/utils.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ def cuda_toolkit_include_path() -> Tuple[str, str]:
198198

199199

200200
@functools.lru_cache(maxsize=None)
201-
def nvcc_path() -> Tuple[str, str]:
202-
"""Returns the NVCC binary path.
201+
def nvcc_path() -> Path:
202+
203+
if os.getenv("NVCC"):
204+
return Path(os.getenv("NVCC"))
203205

204-
Throws FileNotFoundError if NVCC is not found."""
205-
# Try finding NVCC
206206
nvcc_bin: Optional[Path] = None
207207
if nvcc_bin is None and os.getenv("CUDA_HOME"):
208208
# Check in CUDA_HOME
@@ -214,13 +214,12 @@ def nvcc_path() -> Tuple[str, str]:
214214
if nvcc_bin is not None:
215215
cuda_home = Path(nvcc_bin.rstrip("/bin/nvcc"))
216216
nvcc_bin = Path(nvcc_bin)
217-
if nvcc_bin is None:
218-
# Last-ditch guess in /usr/local/cuda
219-
cuda_home = Path("/usr/local/cuda")
220-
nvcc_bin = cuda_home / "bin" / "nvcc"
221-
if not nvcc_bin.is_file():
222-
raise FileNotFoundError(f"Could not find NVCC at {nvcc_bin}")
223-
217+
if nvcc_bin is None or not nvcc_bin.is_file():
218+
219+
mcc_bin = shutil.which("mcc")
220+
if mcc_bin:
221+
return Path(mcc_bin)
222+
raise FileNotFoundError(f"Could not find NVCC/MCC executable")
224223
return nvcc_bin
225224

226225

@@ -259,6 +258,8 @@ def skip_cuda_build() -> bool:
259258

260259
@functools.lru_cache(maxsize=None)
261260
def cuda_archs() -> str:
261+
if skip_cuda_build() or os.getenv("NVTE_WITH_MACA") == "1":
262+
return "" # Return empty string when skipping CUDA build or when building with MACA, since MACA requires CUDA 12.1 which supports a wide range of architectures and we want to avoid accidentally excluding some architectures
262263
if skip_cuda_build():
263264
return "" # Return empty string when skipping CUDA build
264265
archs = os.getenv("NVTE_CUDA_ARCHS")
@@ -280,6 +281,8 @@ def cuda_version() -> Tuple[int, ...]:
280281
nvcc is not found, look for the cuda runtime package pip `nvidia-cuda-runtime-cu12`
281282
and check pip version.
282283
"""
284+
if os.getenv("NVTE_WITH_MACA") == "1" or os.environ.get("NVTE_WITH_CUDA") == "0":
285+
return (12, 1) # Assume CUDA 12.1 when building with MACA or when CUDA build is disabled, since MACA requires CUDA 12.1
283286

284287
try:
285288
nvcc_bin = nvcc_path()

0 commit comments

Comments
 (0)