Skip to content

Commit a1eb471

Browse files
committed
document the buildtime environment variables
1 parent 4cbab16 commit a1eb471

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

cuda_bindings/docs/source/install.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ During the build process, environment variable `CUDA_HOME` or `CUDA_PATH` are us
4646
export CUDA_HOME=/usr/local/cuda
4747
```
4848

49+
Some other build time environment variables are as follows:
50+
51+
`CUDA_PYTHON_PARSER_CACHING` : bool, toggles the caching of parsed header files during the cuda-bindings build process. If caching is enabled (`CUDA_PYTHON_PARSER_CACHING` is True), the cache path is set to ./cache_<library_name>, where <library_name> is derived from the cuda toolkit libraries used to build cuda-bindings.
52+
53+
`CUDA_PYTHON_PARALLEL_LEVEL` (previously `PARALLEL_LEVEL`) : int, sets the number of threads used in the compilation of cython files. This is passed as the `nthreads` argument to :meth:`cython.cythonize` and as the parallel attribute for building extension modules.
54+
4955
### In-place
5056

5157
To compile the extension in-place, run:

cuda_bindings/setup.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sys
1616
import sysconfig
1717
import tempfile
18+
from warnings import warn
1819

1920
from Cython import Tempita
2021
from Cython.Build import cythonize
@@ -32,7 +33,13 @@
3233
raise RuntimeError("Environment variable CUDA_HOME or CUDA_PATH is not set")
3334

3435
CUDA_HOME = CUDA_HOME.split(os.pathsep)
35-
nthreads = int(os.environ.get("PARALLEL_LEVEL", "0") or "0")
36+
if os.environ.get("PARALLEL_LEVEL") is not None:
37+
warn(
38+
"Environment variable PARALLEL_LEVEL is deprecated. Use CUDA_PYTHON_PARALLEL_LEVEL instead",
39+
DeprecationWarning,
40+
stacklevel=1,
41+
)
42+
nthreads = int(os.environ.get("CUDA_PYTHON_PARALLEL_LEVEL", "0") or "0")
3643
PARSER_CACHING = os.environ.get("CUDA_PYTHON_PARSER_CACHING", False)
3744
PARSER_CACHING = bool(PARSER_CACHING)
3845

@@ -80,7 +87,7 @@
8087
found_values = []
8188

8289
include_path_list = [os.path.join(path, "include") for path in CUDA_HOME]
83-
print(f'Parsing headers in "{include_path_list}" (Caching {PARSER_CACHING})')
90+
print(f'Parsing headers in "{include_path_list}" (Caching = {PARSER_CACHING})')
8491
for library, header_list in header_dict.items():
8592
header_paths = []
8693
for header in header_list:
@@ -308,9 +315,9 @@ def build_extension(self, ext):
308315
# Allow extensions to discover libraries at runtime
309316
# relative their wheels installation.
310317
if ext.name == "cuda.bindings._bindings.cynvrtc":
311-
ldflag = f"-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/cuda_nvrtc/lib"
318+
ldflag = "-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/cuda_nvrtc/lib"
312319
elif ext.name == "cuda.bindings._internal.nvjitlink":
313-
ldflag = f"-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/nvjitlink/lib"
320+
ldflag = "-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/nvjitlink/lib"
314321
else:
315322
ldflag = None
316323

@@ -326,7 +333,7 @@ def build_extension(self, ext):
326333
cmdclass = {
327334
"bdist_wheel": WheelsBuildExtensions,
328335
"build_ext": ParallelBuildExtensions,
329-
}
336+
}
330337

331338
# ----------------------------------------------------------------------
332339
# Setup

0 commit comments

Comments
 (0)