{"id":8917,"library":"cuml-cu12","title":"cuML - RAPIDS ML Algorithms","description":"cuML is a suite of GPU-accelerated machine learning algorithms provided by the RAPIDS ecosystem, designed to be API-compatible with scikit-learn for ease of use. It leverages NVIDIA CUDA for high-performance computing on GPUs, significantly speeding up tasks like clustering, regression, classification, and dimensionality reduction. It generally follows a monthly release cadence, aligning with the broader RAPIDS release schedule. The `cuml-cu12` package specifically targets CUDA 12.","status":"active","version":"26.4.0","language":"en","source_language":"en","source_url":"https://github.com/rapidsai/cuml","tags":["machine-learning","gpu","rapids","data-science","scikit-learn-compatible","cuda"],"install":[{"cmd":"pip install cuml-cu12 cupy-cuda12x","lang":"bash","label":"Pip install (requires existing CUDA 12.x environment)"},{"cmd":"conda install -c rapidsai -c conda-forge -c nvidia cuml=26.04 python=3.11 cudatoolkit=12.2","lang":"bash","label":"Conda install (recommended for easier environment management)"}],"dependencies":[{"reason":"Required for execution","package":"python","optional":false},{"reason":"Essential for GPU array operations and data handling.","package":"cupy-cuda12x","optional":false},{"reason":"GPU DataFrames, often used for input/output with cuML algorithms.","package":"cudf-cu12","optional":false},{"reason":"For API compatibility and some utility functions.","package":"scikit-learn","optional":false},{"reason":"For distributed computing capabilities (e.g., cuml.dask module).","package":"dask","optional":true}],"imports":[{"symbol":"KMeans","correct":"from cuml.cluster import KMeans"},{"symbol":"LogisticRegression","correct":"from cuml.linear_model import LogisticRegression"},{"symbol":"RandomForestClassifier","correct":"from cuml.ensemble import RandomForestClassifier"},{"note":"Path changed in v26.04.00","wrong":"from cuml.internals import check_is_fitted","symbol":"check_is_fitted","correct":"from cuml.internals.validation import check_is_fitted"}],"quickstart":{"code":"import cuml\nimport cupy as cp\nimport numpy as np\n\n# For reproducibility\nnp.random.seed(0)\n\n# Generate some random data on the CPU\nn_samples = 1000\nn_features = 2\nn_clusters = 3\nX_host = np.random.rand(n_samples, n_features) * 10\n\n# Simulate clusters\nfor i in range(n_clusters):\n    X_host[i*n_samples//n_clusters:(i+1)*n_samples//n_clusters] += i * 2\n\n# Transfer data to GPU using CuPy\nX_gpu = cp.asarray(X_host, dtype=cp.float32)\n\n# Initialize and train KMeans on the GPU\nkmeans_cuml = cuml.cluster.KMeans(n_clusters=n_clusters, random_state=0)\nkmeans_cuml.fit(X_gpu)\n\n# Get cluster centers and labels (still on GPU)\ncluster_centers_gpu = kmeans_cuml.cluster_centers_\nlabels_gpu = kmeans_cuml.labels_\n\nprint(\"CuML KMeans fitted successfully.\")\nprint(f\"Cluster Centers (on GPU):\\n{cluster_centers_gpu}\")\nprint(f\"First 10 Labels (on GPU): {labels_gpu[:10]}\")\n\n# Transfer results back to CPU if needed\ncluster_centers_cpu = cluster_centers_gpu.get()\nlabels_cpu = labels_gpu.get()\n\nprint(f\"Cluster Centers (on CPU):\\n{cluster_centers_cpu}\")\nprint(f\"First 10 Labels (on CPU): {labels_cpu[:10]}\")","lang":"python","description":"This quickstart demonstrates basic GPU-accelerated K-Means clustering using cuML. It generates sample data on the CPU, transfers it to the GPU using CuPy, performs the clustering, and then retrieves the results back to the CPU. Ensure `cupy-cuda12x` is installed alongside `cuml-cu12`."},"warnings":[{"fix":"Ensure sparse inputs are converted to `cudf.SparseSeries`, `cudf.SparseDataFrame`, or a dense `cudf.DataFrame`/`cupy.ndarray` as required by the specific algorithm, or to a sparse format explicitly supported by the algorithm (e.g., `scipy.sparse.csr_matrix` for some estimators).","message":"Sparse input validation now raises `TypeError` for unsupported types. Algorithms that previously implicitly handled or failed with unsupported sparse formats will now explicitly raise an error.","severity":"breaking","affected_versions":">=26.04.00"},{"fix":"Update import statements from `from cuml.internals import check_is_fitted` to `from cuml.internals.validation import check_is_fitted`.","message":"The `check_is_fitted` utility function has been moved from `cuml.internals` to `cuml.internals.validation` for better organization and adherence to internal validation structures.","severity":"breaking","affected_versions":">=26.04.00"},{"fix":"If you plan to use distributed cuML algorithms, explicitly install `dask` and `distributed` via `pip install dask distributed` or `conda install dask-ml`.","message":"`dask` became an optional dependency. Attempting to use `cuml.dask` modules or distributed functionalities without `dask` installed will result in a `ModuleNotFoundError`.","severity":"gotcha","affected_versions":">=25.12.00"},{"fix":"Review your code for usage of `TotalIters` in SVC/SVR. If it's used, consider alternative ways to manage iteration limits or consult the latest documentation for equivalent parameters, if any.","message":"The `TotalIters` parameter for SVC/SVR estimators has been deprecated. It may be removed in future versions.","severity":"deprecated","affected_versions":">=26.02.00"},{"fix":"Avoid accessing the `handle` attribute directly. This attribute exposed internal CUDA context management and should not be used by end-users. If explicit CUDA stream or resource management is required, refer to advanced RAPIDS documentation for proper techniques.","message":"The `handle` attribute has been deprecated and removed from public cuML APIs. Direct access to `estimator.handle` is no longer supported.","severity":"deprecated","affected_versions":">=26.02.00"},{"fix":"Update calls from `estimator.convert_to_cupy()` to `estimator.as_cupy()`, and similarly for `cudf`.","message":"Deprecated `convert_to_*` methods (e.g., `convert_to_cupy`, `convert_to_cudf`) in `cuml.ensemble` estimators have been removed in favor of `as_*` methods (e.g., `as_cupy`, `as_cudf`).","severity":"breaking","affected_versions":">=25.10.00"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Convert your sparse input to a dense `cupy.ndarray` or `cudf.DataFrame` using `.toarray()` or similar methods, or ensure it's in a sparse format explicitly supported by the algorithm (if any).","cause":"Passing a `scipy.sparse` matrix to a cuML algorithm that expects a dense array or a different sparse format after strict validation was introduced in v26.04.00.","error":"TypeError: Sparse input of type <class 'scipy.sparse.csc.csc_matrix'> is not supported. Please convert your data to cupy.ndarray or cudf.DataFrame."},{"fix":"Install Dask and Distributed: `pip install dask distributed` or `conda install -c conda-forge dask-ml`.","cause":"Attempting to import or use functionality from `cuml.dask` (e.g., `cuml.dask.cluster.KMeans`) when Dask is not installed. Dask became an optional dependency in v25.12.00.","error":"ModuleNotFoundError: No module named 'dask'"},{"fix":"Remove any code directly accessing `estimator.handle`. The `handle` was an internal CUDA context management object not intended for direct user interaction.","cause":"Attempting to access the `handle` attribute on a cuML estimator. This attribute was deprecated and removed from public APIs in v26.02.00.","error":"AttributeError: 'RandomForestClassifier' object has no attribute 'handle'"},{"fix":"Update your import statement to `from cuml.internals.validation import check_is_fitted`.","cause":"The `check_is_fitted` utility function was moved to `cuml.internals.validation` in v26.04.00.","error":"ImportError: cannot import name 'check_is_fitted' from 'cuml.internals' (or similar)"}]}