All examples
Machine learning

Run clustering on NVIDIA CUDA

Place Float32 tensors on CUDA explicitly and inspect e-means, o-means and p-means fitting, query scores and labels with a compatible development backend.

clustering_cuda.aner
// Requires Aner 0.0.10-dev.6 built with native CUDA clustering and a supported GPU.
// V100 Float32 correctness is qualified; preparing L40 code is not an L40 result.
import aner.ml
import aner.nn
import aner.tensor
import aner.parallel

let x = nn.to([[0.0], [2.0], [10.0], [12.0]].astype("Float32"), "cuda")
let query = nn.to([[1.0]].astype("Float32"), "cuda")
let execution = parallel.local(workers: 4)
let e = ml.fit_emeans(x, 2, 3.0, 42, execution: execution)
let o = ml.fit_omeans(x, 2, 3.0, 42, execution: execution)
let p = ml.fit_pmeans(x, 2, 3.0, 42, execution: execution)
print(e.summary())
print(o.summary())
print(p.summary())
print(e.score(query, execution: execution))
print(o.score(query, execution: execution))
print(p.score(query, execution: execution))
let e_ids = e.predict(query)
let o_ids = o.predict(query)
let p_ids = p.predict(query)
print(tensor.value(e_ids, 0, 0))
print(tensor.value(o_ids, 0, 0))
print(tensor.value(p_ids, 0, 0))

Make it your experiment.

Use the matching development runtime. Save this program as examples/clustering_cuda.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/clustering_cuda.aner
aner run examples/clustering_cuda.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Requires a separately enabled CUDA clustering build and compatible NVIDIA hardware; portable 0.0.10 defaults exclude CUDA. The supplementary stable Linux CUDA profile is being prepared, and stable L40 qualification remains pending. Retained development V100 and L40 results identify their exact older binaries. Fits e-means, o-means and p-means with complete synthetic Float32 inputs; no network download or output file is needed

Credential setup
aner check examples/clustering_cuda.aner
aner run examples/clustering_cuda.aner

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner