candle
candle copied to clipboard
Compare 0-dimension tensor got CUDA_ERROR_INVALID_VALUE
I got error CUDA_ERROR_INVALID_VALUE when running the code on cuda device. But the same code is running fine in cpu device.
use candle_core::{Device, DType, Tensor};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// let device = Device::Cpu;
let device = Device::new_cuda(0)?;
let a = Tensor::zeros((2, 1, 1, 0), DType::F32, &device)?;
let b = Tensor::zeros((2, 1, 1, 0), DType::F32, &device)?;
let diff = a.eq(&b)?;
println!("{diff}");
Ok(())
}
Error message:
Error: WithBacktrace { inner: Cuda(Cuda(DriverError(CUDA_ERROR_INVALID_VALUE, "invalid argument"))), backtrace: Backtrace [{ fn: "candle_core::error::Error::bt", file: "/root/.cargo/git/checkouts/candle-0c2b4fa9e5801351/a226a97/candle-core/src/error.rs", line: 231 }, { fn: "<core::result::Result<O,E> as candle_core::cuda_backend::error::WrapErr<O>>::w::{{closure}}", file: "/root/.cargo/git/checkouts/candle-0c2b4fa9e5801351/a226a97/candle-core/src/cuda_backend/error.rs", line: 60 }, { fn: "core::result::Result<T,E>::map_err", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/result.rs", line: 829 }, { fn: "<core::result::Result<O,E> as candle_core::cuda_backend::error::WrapErr<O>>::w", file: "/root/.cargo/git/checkouts/candle-0c2b4fa9e5801351/a226a97/candle-core/src/cuda_backend/error.rs", line: 60 }, { fn: "<candle_core::cuda_backend::Cmp as candle_core::cuda_backend::utils::Map2Any>::f", file: "/root/.cargo/git/checkouts/candle-0c2b4fa9e5801351/a226a97/candle-core/src/cuda_backend/mod.rs", line: 968 }, { fn: "candle_core::cuda_backend::utils::Map2Any::map", file: "/root/.cargo/git/checkouts/candle-0c2b4fa9e5801351/a226a97/candle-core/src/cuda_backend/utils.rs", line: 166 }, { fn: "<candle_core::cuda_backend::CudaStorage as candle_core::backend::BackendStorage>::cmp", file: "/root/.cargo/git/checkouts/candle-0c2b4fa9e5801351/a226a97/candle-core/src/cuda_backend/mod.rs", line: 1261 }, { fn: "candle_core::storage::Storage::cmp", file: "/root/.cargo/git/checkouts/candle-0c2b4fa9e5801351/a226a97/candle-core/src/storage.rs", line: 142 }, { fn: "candle_core::tensor::Tensor::cmp", file: "/root/.cargo/git/checkouts/candle-0c2b4fa9e5801351/a226a97/candle-core/src/tensor.rs", line: 991 }, { fn: "candle_core::tensor::Tensor::eq", file: "/root/.cargo/git/checkouts/candle-0c2b4fa9e5801351/a226a97/candle-core/src/tensor.rs", line: 1000 }, { fn: "myapp::main", file: "./src/main.rs", line: 10 }, { fn: "core::ops::function::FnOnce::call_once", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs", line: 250 }, { fn: "std::sys_common::backtrace::__rust_begin_short_backtrace", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs", line: 155 }, { fn: "std::rt::lang_start::{{closure}}", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs", line: 159 }, { fn: "core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs", line: 284 }, { fn: "std::panicking::try::do_call", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs", line: 559 }, { fn: "std::panicking::try", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs", line: 523 }, { fn: "std::panic::catch_unwind", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs", line: 149 }, { fn: "std::rt::lang_start_internal::{{closure}}", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs", line: 141 }, { fn: "std::panicking::try::do_call", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs", line: 559 }, { fn: "std::panicking::try", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs", line: 523 }, { fn: "std::panic::catch_unwind", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs", line: 149 }, { fn: "std::rt::lang_start_internal", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs", line: 141 }, { fn: "std::rt::lang_start", file: "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs", line: 158 }, { fn: "main" }, { fn: "__libc_start_main" }, { fn: "_start" }] }