Environment variables¶
Here are the environment variables CuPy uses.
Moreover, as in any CUDA programs, all of the CUDA environment variables listed in the CUDA Toolkit
Documentation will also be honored. When CUPY_ACCELERATORS or NVCC environment variables
are set, g++-6 or later is required as the runtime host compiler. Please refer to
Installing CuPy from Source for the details on how to install g++.
CUDA_PATHPath to the directory containing CUDA. The parent of the directory containing
nvccis used as default. Whennvccis not found,/usr/local/cudais used. See Working with Custom CUDA Installation for details.CUPY_CACHE_DIRDefault:
${HOME}/.cupy/kernel_cachePath to the directory to store kernel cache. See Overview for details.
CUPY_CACHE_SAVE_CUDA_SOURCEDefault:
0If set to 1, CUDA source file will be saved along with compiled binary in the cache directory for debug purpose. Note: the source file will not be saved if the compiled binary is already stored in the cache.
CUPY_CACHE_IN_MEMORYDefault:
0If set to 1,
CUPY_CACHE_DIRandCUPY_CACHE_SAVE_CUDA_SOURCEwill be ignored, and the cache is in memory. This environment variable allows reducing disk I/O, but is ignoed whennvccis set to be the compiler backend.CUPY_DUMP_CUDA_SOURCE_ON_ERRORDefault:
0If set to 1, when CUDA kernel compilation fails, CuPy dumps CUDA kernel code to standard error.
CUPY_CUDA_COMPILE_WITH_DEBUGDefault:
0If set to 1, CUDA kernel will be compiled with debug information (
--device-debugand--generate-line-info).CUPY_GPU_MEMORY_LIMITDefault:
0(unlimited)The amount of memory that can be allocated for each device. The value can be specified in absolute bytes or fraction (e.g.,
"90%") of the total memory of each GPU. See Memory Management for details.CUPY_SEEDSet the seed for random number generators.
CUPY_EXPERIMENTAL_SLICE_COPYDefault:
0If set to 1, the following syntax is enabled:
cupy_ndarray[:] = numpy_ndarrayCUPY_ACCELERATORSDefault:
""(no accelerators)A comma-separated string of backend names (
cuborcutensor) which indicates the acceleration backends used in CuPy operations and its priority. All accelerators are disabled by default.CUPY_TF32Default:
0If set to 1, it allows CUDA libraries to use Tensor Cores TF32 compute for 32-bit floating point compute.
CUPY_CUDA_ARRAY_INTERFACE_SYNCDefault:
1This controls CuPy’s behavior as a Consumer. If set to 0, a stream synchronization will not be performed when a device array provided by an external library that implements the CUDA Array Interface is being consumed by CuPy. For more detail, see the Synchronization requirement in the CUDA Array Interface v3 documentation.
CUPY_CUDA_ARRAY_INTERFACE_EXPORT_VERSIONDefault:
3This controls CuPy’s behavior as a Producer. If set to 2, the CuPy stream on which the data is being operated will not be exported and thus the Consumer (another library) will not perform any stream synchronization. For more detail, see the Synchronization requirement in the CUDA Array Interface v3 documentation.
NVCCDefault:
nvccDefine the compiler to use when compiling CUDA source. Note that most CuPy kernels are built with NVRTC; this environment is only effective for RawKernels/RawModules with
nvccbackend or when usingcubas the accelerator.
Note
When CUPY_ACCELERATORS or NVCC environment variables are set, g++-6 or later is required as the runtime host compiler.
Please refer to Installing CuPy from Source for the details on how to install g++.
For installation¶
These environment variables are used during installation (building CuPy from source).
CUDA_PATHSee the description above.
CUTENSOR_PATHPath to the cuTENSOR root directory that contains
libandincludedirectories. (experimental)NVCCDefine the compiler to use when compiling CUDA files.
CUPY_PYTHON_350_FORCEEnforce CuPy to be installed against Python 3.5.0 (not recommended).
CUPY_INSTALL_USE_HIPDefault:
0Build CuPy for AMD ROCm Platform (experimental). For building the ROCm support, see Building CuPy for ROCm for further detail.
CUPY_NVCC_GENERATE_CODEBuild CuPy for a particular CUDA architecture. For example,
CUPY_NVCC_GENERATE_CODE="arch=compute_60,code=sm_60". For specifying multiple archs, concatenate thearch=...strings with semicolons (;). When this is not set, the default is to support all architectures.