use cudarc::driver::{CudaDevice, CudaSlice, DriverError}; fn main() -> Result<(), DriverError> { let dev = CudaDevice::new(0)?; // unsafe initialization of unset memory let _: CudaSlice = unsafe { dev.alloc::(10) }?; // this will have memory initialized as 0 let _: CudaSlice = dev.alloc_zeros::(10)?; // initialize with a rust vec let _: CudaSlice = dev.htod_copy(vec![0; 10])?; // or finially, initialize with a slice. this is synchronous though. let _: CudaSlice = dev.htod_sync_copy(&[1, 2, 3])?; Ok(()) }