Closed arthur19q3 closed 1 year ago
fixed by changing Device and Option parameters.
fn gradient_descent() {
let vs = nn::VarStore::new(Device::Cuda(0));
let my_module = my_module(vs.root(), 7);
let mut opt = nn::Sgd::default().build(&vs, 1e-2).unwrap();
for _idx in 1..50 {
// Dummy mini-batches made of zeros.
let xs = Tensor::zeros(&[7], kind::FLOAT_CUDA);
let ys = Tensor::zeros(&[7], kind::FLOAT_CUDA);
let loss = (my_module.forward(&xs) - ys).pow_tensor_scalar(2).sum(kind::Kind::Float);
opt.backward_step(&loss);
}
}
fn main() {
gradient_descent();
}
i am trying to run this Gradient Descent test,
but somehow failed:
i am using cuda 12.1 (only thing available in archlinux repo at the moment) and installed cudann.
LD_LIBRARY_PATH is also set according to where cuda and libtorch is installed:
LD_LIBRARY_PATH=/usr/lib/libtorch/lib:/opt/cuda/targets/x86_64-linux/lib/:$LD_LIBRARY_PATH;