- Fork cudarc locally (vendor/cudarc): add CudaContext::load_cubin() that calls cuModuleLoadData directly — zero nvrtc dependency - Remove "nvrtc" feature from ml-core, ml-dqn, ml-ppo Cargo.toml - Replace all 89 Ptx::from_binary + load_module calls with load_cubin - ml-core cuda_autograd: wire 9 stub constructors to precompiled cubins (activation, elementwise, linear, loss, reduction, dropout, layer_norm, optimizer) - ml-core build.rs: compile 8 BF16-native CUDA kernels via nvcc - cubin_loader.rs: thin wrapper around CudaContext::load_cubin() - Fix size_of::<f32> in gpu_tensor.rs, stream_ops.rs, layer_norm.rs - Fix test data: Vec<f32> → Vec<half::bf16> for memcpy_htod - Stub ml-ppo/ml-dqn runtime compile_ptx calls (dead code) - backtest_metrics_kernel.cu: full native BF16 rewrite (no float) - backtest_env_kernel.cu: shared memory → __nv_bfloat16 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
35 lines
963 B
Rust
35 lines
963 B
Rust
#[cfg(all(feature = "std", feature = "cufile"))]
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
use std::fs;
|
|
|
|
use cudarc::{cufile::safe::Cufile, driver::CudaContext};
|
|
|
|
const N: usize = 100000;
|
|
let data: Vec<u8> = (0..N).flat_map(|x| (x as f32).to_le_bytes()).collect();
|
|
let data_sz = data.len();
|
|
let src_file = "/tmp/cufile_test.bin";
|
|
fs::write(src_file, &data)?;
|
|
|
|
let cufile = Cufile::new()?;
|
|
println!("{:?}", cufile.get_properties()?);
|
|
|
|
let file = fs::File::open(src_file)?;
|
|
let handle = cufile.register(file)?;
|
|
|
|
let ctx = CudaContext::new(0)?;
|
|
let stream = ctx.default_stream();
|
|
let mut buf = stream.alloc_zeros::<u8>(data_sz)?;
|
|
|
|
handle.sync_read(0, &mut buf)?;
|
|
|
|
let verify_dst = stream.clone_dtoh(&buf)?;
|
|
assert_eq!(verify_dst, data);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(not(all(feature = "std", feature = "cufile")))]
|
|
fn main() {
|
|
println!("This example requires `std` and `cufile` features")
|
|
}
|