Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with: Internal torch error: can't fopen #857

Open
Anivie opened this issue Mar 18, 2024 · 0 comments
Open

Error with: Internal torch error: can't fopen #857

Anivie opened this issue Mar 18, 2024 · 0 comments

Comments

@Anivie
Copy link

Anivie commented Mar 18, 2024

I am trying this example to use the yolo8 in tch-rs, but I encountered an internal error, that cannot determine the specific cause. I can confirm that all the files exist, and I have also tried running the program in administrator mode, but the error persists. How can I troubleshoot this issue?

fn main() -> anyhow::Result<()> {
    let model = CModule::load(r#"./yolov8x.torchscript"#).unwrap();
    // let image = include_bytes!(r#"C:\Users\anivie\OneDrive\document\desktop\b.jpg"#);//runs ok
    let image = imagenet::load_image_and_resize(r#"C:\Users\anivie\OneDrive\document\desktop\b.jpg"#, 416, 416)?;//error
    let output = model.forward_ts(&[image.unsqueeze(0)])?.softmax(-1, None);
    for (probability, class) in imagenet::top(&output, 5).iter() {
        println!("{:50} {:5.2}%", class, 100.0 * probability)
    }

    Ok(())
}

error message:

Error: Internal torch error: can't fopen

Stack backtrace:
   0: std::backtrace_rs::backtrace::dbghelp::trace
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:131
   1: std::backtrace_rs::backtrace::trace_unsynchronized
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2: std::backtrace::Backtrace::create
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\backtrace.rs:331
   3: std::backtrace::Backtrace::capture
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\backtrace.rs:296
   4: anyhow::error::impl$1::from<enum2$<tch::error::TchError> >
             at D:\SDK\Rust\Cargo\registry\src\index.crates.io-6f17d22bba15001f\anyhow-1.0.81\src\error.rs:565
   5: core::result::impl$27::from_residual<tuple$<>,enum2$<tch::error::TchError>,anyhow::Error>
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\core\src\result.rs:1959
   6: torch_test_win::main
             at .\src\main.rs:19
   7: core::ops::function::FnOnce::call_once<enum2$<core::result::Result<tuple$<>,anyhow::Error> > (*)(),tuple$<> >
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\core\src\ops\function.rs:250
   8: std::sys_common::backtrace::__rust_begin_short_backtrace<enum2$<core::result::Result<tuple$<>,anyhow::Error> > (*)(),enum2$<core::result::Result<tuple$<>,anyhow::Error> > >
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\std\src\sys_common\backtrace.rs:155
   9: std::rt::lang_start::closure$0<enum2$<core::result::Result<tuple$<>,anyhow::Error> > >
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\std\src\rt.rs:166
  10: std::rt::lang_start_internal::closure$2
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\rt.rs:148
  11: std::panicking::try::do_call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:552
  12: std::panicking::try
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:516
  13: std::panic::catch_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panic.rs:142
  14: std::rt::lang_start_internal
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\rt.rs:148
  15: std::rt::lang_start<enum2$<core::result::Result<tuple$<>,anyhow::Error> > >
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\std\src\rt.rs:165
  16: main
  17: invoke_main
             at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  18: __scrt_common_main_seh
             at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  19: BaseThreadInitThunk
  20: RtlUserThreadStart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant