Skip to main content
CUTLASS Python provides various utility functions for device management, logging, memory management, and type conversion.

Device Management

device_cc()

Returns the compute capability of the current CUDA device. Returns: int - Compute capability (e.g., 70, 75, 80, 86, 89, 90, 100) Use cases:
  • Auto-detecting device capabilities
  • Selecting appropriate kernel implementations
  • Validating feature support

device_id()

Returns the CUDA device ID being used by CUTLASS. Returns: int - CUDA device ID (default: 0) Environment variable: Set CUTLASS_CUDA_DEVICE_ID to override default device.

initialize_cuda_context()

Explicitly initializes the CUDA context. This is called automatically by most CUTLASS operations, but can be called manually for early initialization. Side effects:
  • Creates CUDA context if not already created
  • Initializes RMM memory pool if enabled
  • Validates CUDA and NVCC versions match

Logging

set_log_level()

Sets the logging level for CUTLASS operations.
int
required
Python logging level constant from the logging module.
Available levels:
  • logging.DEBUG (10) - Detailed diagnostic information
  • logging.INFO (20) - General informational messages
  • logging.WARNING (30) - Warning messages (default)
  • logging.ERROR (40) - Error messages only
  • logging.CRITICAL (50) - Critical errors only
Example output:

Memory Management

get_memory_pool()

Returns the RMM (RAPIDS Memory Manager) memory pool if enabled, otherwise returns None. Requirements:
  • Python 3.9+
  • RMM package installed
Returns: RMM memory pool or None Note: The memory pool is created on first access with default settings:
  • Initial pool size: 1 GB (2^30 bytes)
  • Maximum pool size: 4 GB (2^32 bytes)

create_memory_pool()

Creates a custom RMM memory pool with specified sizes.
int
default:"2**30"
Initial memory pool size in bytes.
int
default:"2**32"
Maximum memory pool size in bytes.
Returns: RMM memory pool object

Type Utilities

library_type()

Converts native Python/framework data types to CUTLASS DataType enum values. Supported input types:
  • PyTorch dtypes: torch.float16, torch.float32, torch.float64, torch.bfloat16, torch.int8, torch.int32
  • NumPy dtypes: numpy.float16, numpy.float32, numpy.float64, numpy.int8, numpy.int32
  • CUTLASS DataType: passed through unchanged
Returns: cutlass.DataType enum value

Compiler Configuration

nvcc_version()

Returns the version of NVCC (NVIDIA CUDA Compiler) being used. Returns: str - NVCC version string

cuda_install_path()

Returns the path to the CUDA installation. Returns: str - Path to CUDA installation directory Detection order:
  1. CUDA_INSTALL_PATH environment variable
  2. Path derived from nvcc location

Environment Variables

CUTLASS_PATH

Overrides the CUTLASS source code location. Default: Auto-detected based on package installation

CUDA_INSTALL_PATH

Overrides the CUDA installation path. Default: Derived from nvcc location

CUTLASS_CUDA_DEVICE_ID

Sets the CUDA device to use. Default: 0 (first GPU)

Version Information

version

Returns the CUTLASS Python package version string.

Cache Management

CUTLASS caches compiled kernels to disk to avoid recompilation.

Cache Location

Compiled kernels are cached in:

Clearing Cache

To force recompilation, delete the cache file:
Or programmatically:

Error Checking

check()

Utility functions for error checking and validation.

Constants

SharedMemPerCC

Dictionary mapping compute capability to maximum shared memory in bytes.

Complete Example

Source Code

  • Main module: cutlass/python/cutlass_cppgen/init.py
  • Device utilities: cutlass/python/cutlass_cppgen/backend/utils/device.py
  • Type utilities: cutlass/python/cutlass_cppgen/utils/datatypes.py

See Also