Open Jaroslove opened 1 week ago
same on Ubuntu enviroment, is there any way to solve it?
exactly the same issue on Windows 11
Ensure that you have a build.rs
script in your repo that goes along the lines of the ones in tch-rs here, this ensures that the proper flags are used when linking the binary.
Also good if you can checkin the tch-rs repro and run cargo run --example basics -r
this should print whether or not the cuda bits are found in this case.
Ensure that you have a
build.rs
script in your repo that goes along the lines of the ones in tch-rs here, this ensures that the proper flags are used when linking the binary. Also good if you can checkin the tch-rs repro and runcargo run --example basics -r
this should print whether or not the cuda bits are found in this case.
Thanks! I tried your suggestion, but unfortunately, the problem still persists.
I checked the contents of target/debug/build/torch-sys-xxx/output
and saw that it is already trying to link torch_cuda
, but tch::Cuda::is_available
is still false.
...
cargo:rustc-link-lib=stdc++
cargo:rustc-link-lib=static=tch
cargo:rustc-link-lib=torch_cuda
cargo:rustc-link-lib=torch_cpu
cargo:rustc-link-lib=torch
cargo:rustc-link-lib=c10
cargo:rustc-link-lib=gomp
Well, I'm not sure if this can be the final solution, even I am still can't sure what the problem is, but it seems to have solved my problem for now.
The answer in this link worked for me.
use std::ffi::CString;
use libc::dlopen;
fn main() {
let path = CString::new("/root/libtorch/lib/libtorch_cuda.so").unwrap();
unsafe {
dlopen(path.into_raw(), 1);
}
println!("cuda: {}", tch::Cuda::is_available());
println!("cudnn: {}", tch::Cuda::cudnn_is_available());
}
I use tch = "0.18.0" on windows 11 Downloaded libtorch-win-shared-with-deps-2.5.0+cu118
My env vars are: LIBTORCH=D:\softwares\Libtorch\libtorch-win-shared-with-deps-2.5.0+cu118\libtorch TORCH_CUDA_VERSION=11.8 TORCH_VERSION=cu118
Could anybody help me, what I need to do to have cuda?