LaurentMazare / tch-rs

Rust bindings for the C++ api of PyTorch.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

STATUS_DLL_NOT_FOUND when using LIBTORCH_USE_PYTORCH

dvof opened this issue · comments

Please, this is a pain to work with.

I am using version tch = "0.13.0"
Just the normal starting code:

use tch::Tensor;

fn main() {
    let t = Tensor::from_slice(&[3, 1, 4, 1, 5]);
    let t = t * 2;
    t.print();
}

Installed PyTorch within python:

Python 3.11.6 (tags/v3.11.6:8b6ee5b, Oct  2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.__version__)
2.0.0+cpu

I set my enviroment variable LIBTORCH_USE_PYTORCH to 1.

This are all the steps I take, do I miss a step? I see some people talk about setting environment variables, but not which ones.

I build and run:

cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target\debug\test-libtorch.exe`
error: process didn't exit successfully: `target\debug\test-libtorch.exe` (exit code: 0xc0000135, STATUS_DLL_NOT_FOUND)

I tried to install the libtorch zip and set the environment variable and path, even though I thought that shouldn't be necessary. And the only version from libtorch I could find is 2.2.0, not the right one. So I removed this as well.

Maybe useful to use Dependency Walker to determine the exact DLL that's missing.

I'm also experiencing this error on versions 0.13.0 through 0.16.0. Versions 0.12.0 and older do not have this problem.