Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fastkmeans-rs"
version = "1.0.2"
version = "1.0.3"
edition = "2021"
description = "A fast and efficient k-means clustering implementation in Rust, compatible with ndarray"
license = "Apache-2.0"
Expand Down
12 changes: 10 additions & 2 deletions src/cuda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use cudarc::cublas::{CudaBlas, Gemm, GemmConfig};
use cudarc::driver::{
CudaContext as CudarcContext, CudaFunction, CudaSlice, CudaStream, LaunchConfig, PushKernelArg,
};
use cudarc::nvrtc::compile_ptx;
use cudarc::nvrtc::{compile_ptx_with_opts, CompileOptions};
use ndarray::{Array1, Array2, ArrayView2};
use rand::seq::SliceRandom;
use rand::SeedableRng;
Expand Down Expand Up @@ -241,7 +241,15 @@ impl FastKMeansCuda {
})?;
let stream = device.default_stream();

let ptx = compile_ptx(CUDA_KERNELS).map_err(|e| {
let opts = match device.compute_capability() {
Ok((major, minor)) => CompileOptions {
options: vec![format!("--gpu-architecture=sm_{}{}", major, minor)],
..Default::default()
},
Err(_) => CompileOptions::default(),
};

let ptx = compile_ptx_with_opts(CUDA_KERNELS, opts).map_err(|e| {
KMeansError::InvalidK(format!("Failed to compile CUDA kernels: {:?}", e))
})?;

Expand Down
Loading