# Exporting cuml.accel Models to ONNX

Models trained under `cuml.accel` can be exported to the [ONNX](https://onnx.ai/) format using [sklearn-onnx](https://onnx.ai/sklearn-onnx/). Because `cuml.accel` proxy objects are recognized by `sklearn-onnx` as scikit-learn estimators, you can pass them directly to `convert_sklearn()` without any conversion step.

The resulting `.onnx` file can then be loaded with [ONNX Runtime](https://onnxruntime.ai/) for inference on both CPU and GPU, with no cuML dependency at inference time.

## Supported Estimators

The following `cuml.accel` estimators have been tested with `sklearn-onnx`:

- **Classifiers:** `RandomForestClassifier`, `KNeighborsClassifier`, `LinearSVC`
- **Regressors:** `RandomForestRegressor`, `KNeighborsRegressor`, `LinearSVR`
- **Transformers/Clusterers:** `PCA`, `TruncatedSVD`, `KMeans`

Estimators not listed here (e.g. `SVC`, `SVR`, `DBSCAN`, `TSNE`, `HDBSCAN`, `UMAP`) are **not currently supported** for ONNX export.

```none
[1]:
```

### Training a Model

Train a `RandomForestClassifier` on the Iris dataset. Under `cuml.accel`, this runs on the GPU.

```none
[2]:
```

### Exporting to ONNX

Convert the fitted model to ONNX using `skl2onnx.convert_sklearn()`. The proxy object is passed directly — no `as_sklearn()` call needed.

> Note: due to a known upstream incompatibility in `onnxruntime` version 1.26.0, predictions from a serialized `RandomForestClassifier` will be incorrect (see [microsoft/onnxruntime#28557](https://github.com/microsoft/onnxruntime/issues/28557)). We recommend using version 1.25.1 until the issue is resolved.
```none
[3]:
```

### Inference with ONNX Runtime

The saved `.onnx` file can be loaded on any machine with `onnxruntime` installed — no cuML or `sklearn-onnx` needed. Use `onnxruntime` for CPU inference, or `onnxruntime-gpu` for GPU inference.

> Note: due to a known upstream incompatibility in `onnxruntime` version 1.26.0, predictions from a serialized `RandomForestClassifier` will be incorrect (see [microsoft/onnxruntime#28557](https://github.com/microsoft/onnxruntime/issues/28557)). We recommend using version 1.25.1 until the issue is resolved.
```none
[4]:
```
