Environment variables

Here are the environment variables CuPy uses.


Path to the directory containing CUDA. The parent of the directory containing nvcc is used as default. When nvcc is not found, /usr/local/cuda is used. See Working with Custom CUDA Installation for details.


Path to the directory to store kernel cache. ${HOME}/.cupy/kernel_cache is used by default. See Overview for details.


If set to 1, CUDA source file will be saved along with compiled binary in the cache directory for debug purpose. It is disabled by default. Note: source file will not be saved if the compiled binary is already stored in the cache.


If set to 1, when CUDA kernel compilation fails, CuPy dumps CUDA kernel code to standard error. It is disabled by default.


If set to 1, CUDA kernel will be compiled with debug information (--device-debug and --generate-line-info). It is disabled by default.


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. 0 (unlimited) is used by default.


Set the seed for random number generators. For historical reasons CHAINER_SEED is used if CUPY_SEED is unspecified.


If set to 1, the following syntax is enabled: cupy_ndarray[:] = numpy_ndarray.

Moreover, as in any CUDA programs, all of the CUDA environment variables listed in the CUDA Toolkit Documentation will also be honored.

For installation

These environment variables are used during installation (building CuPy from source).


See the description above.


Path to the cuTENSOR root directory that contains lib and include directories. (experimental)


Path to the CUB root directory that contains the folders cub, examples, etc.


Define the compiler to use when compiling CUDA files.


Enforce CuPy to be installed against Python 3.5.0 (not recommended).


For building the ROCm support, see Install CuPy from Source for further detail.


To build CuPy for a particular CUDA architecture. For example, CUPY_NVCC_GENERATE_CODE="arch=compute_60,code=sm_60". For specifying multiple archs, concatenate the arch=... strings with semicolons (;). When this is not set, the default is to support all architectures.