Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ To build for SM100 instead, set the `MOK_ARCH` environment variable:
MOK_ARCH=SM100 pip install . --no-build-isolation
```

To use a specific CUDA compiler, set `MOK_NVCC` (or `NVCC`). The selected compiler is used for both the CUDA version check and the build:

```bash
MOK_NVCC=/path/to/cuda-13.0/bin/nvcc pip install . --no-build-isolation
```

To verify the installation:

```bash
Expand Down
14 changes: 10 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ def check_pytorch() -> None:
warnings.warn(f"MoK should run with PyTorch CUDA {torch.version.cuda}, but it is built and tested for CUDA 13.0.", RuntimeWarning, stacklevel=2)


def check_nvcc() -> None:
nvcc_name = os.environ.get("NVCC", "nvcc")
def get_nvcc_name() -> str:
return os.environ.get("MOK_NVCC", os.environ.get("NVCC", "nvcc"))


def check_nvcc() -> str:
nvcc_name = get_nvcc_name()
nvcc = shutil.which(nvcc_name)
if nvcc is None:
raise RuntimeError(
Expand All @@ -93,6 +97,8 @@ def check_nvcc() -> None:
"Install the matching CUDA toolkit or ensure PATH points to its bin directory."
)

return nvcc


def check_thunderkittens() -> None:
thunderkittens_header = THUNDERKITTENS_ROOT / "include" / "kittens.cuh"
Expand All @@ -119,7 +125,7 @@ def build_extension(self, ext) -> None:
check_make()
check_python()
check_pytorch()
check_nvcc()
nvcc = check_nvcc()
check_thunderkittens()

pytorch_includes = " ".join(f"-I{path}" for path in include_paths())
Expand All @@ -130,7 +136,7 @@ def build_extension(self, ext) -> None:
subprocess.check_call([
"make",
f"SRC={REPO_ROOT / 'csrc' / 'bindings.cu'}",
f"NVCC={os.environ.get('MOK_NVCC', 'nvcc')}",
f"NVCC={nvcc}",
f"ARCH={os.environ.get('MOK_ARCH', 'SM103')}",
f"PYTHON={sys.executable}",
f"THUNDERKITTENS_ROOT={THUNDERKITTENS_ROOT}",
Expand Down