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

libtorch_c_api not defined in Torch.Wrapper` #68

Closed
kadir-gunel opened this issue Jan 25, 2025 · 8 comments
Closed

libtorch_c_api not defined in Torch.Wrapper` #68

kadir-gunel opened this issue Jan 25, 2025 · 8 comments

Comments

@kadir-gunel
Copy link

kadir-gunel commented Jan 25, 2025

Hello,

I am still unable to install this lib. I have fresh install of Julia v1.11.3.

The main error I am getting is :

 PkgPrecompileError: The following 1 direct dependency failed to precompile:

Torch

Failed to precompile Torch [6a2ea274-3061-11ea-0d63-ff850051a295] to "/home/kguenel/.julia/compiled/v1.11/Torch/jl_c11DHW".
ERROR: LoadError: UndefVarError: `libtorch_c_api` not defined in `Torch.Wrapper`
Stacktrace:
 [1] at_grad_set_enabled(arg1::Base.RefValue{Int32}, arg2::Int64)
   @ Torch.Wrapper ~/.julia/packages/Torch/QTrgw/src/wrapper.jl:15
 [2] top-level scope
   @ ~/.julia/packages/Torch/QTrgw/src/tensor.jl:8
 [3] include(mod::Module, _path::String)
   @ Base ./Base.jl:557
 [4] include(x::String)
   @ Torch ~/.julia/packages/Torch/QTrgw/src/Torch.jl:1
 [5] top-level scope
   @ ~/.julia/packages/Torch/QTrgw/src/Torch.jl:24
 [6] include
   @ ./Base.jl:557 [inlined]
 [7] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
   @ Base ./loading.jl:2881
 [8] top-level scope
   @ stdin:6
in expression starting at /home/kguenel/.julia/packages/Torch/QTrgw/src/tensor.jl:7
in expression starting at /home/kguenel/.julia/packages/Torch/QTrgw/src/Torch.jl:1
in expression starting at stdin:```

What should I do? 


B.R.






@stemann
Copy link
Collaborator

stemann commented Jan 26, 2025

Are you on x86_64 Linux without a CUDA GPU?

If so, then you might be affected by #20 (comment)

@kadir-gunel
Copy link
Author

No, I have CUDA gpus. And the driver is also installed. I can use flux with gpu, or CUDA.jl itself.

@stemann
Copy link
Collaborator

stemann commented Jan 26, 2025

Alright - you likely need to include CUDA_Runtime_jll in your project/environment, and set the CUDA version preference to a supported CUDA version, cf. https://cuda.juliagpu.org/stable/installation/overview/#Specifying-the-CUDA-version

It should definitely work on CUDA 11.3 (but I hope it also works on CUDA 11.8).

@kadir-gunel
Copy link
Author

kadir-gunel commented Jan 26, 2025

Based on your suggestions, I found out that CUDA.jl left support for CUDA 11.3 in version 5. And If I want to continue with 11.8 it gives error. But since Torch.jl works with CUDA 11.3, I gave a shot to [email protected] and [email protected] . I also downgraded julia version to 1.8. With this configuration ([email protected], [email protected] with v11.3 and of course Torch.jl), I still get eror :

[Info: Precompiling Torch [ 6a2ea274-3061-11ea-0d63-ff850051a295]
ERROR: LoadError: InitError: could not load library "/home/kg/.julia/artifacts/df751aad1e240ec7b9143977/lib/libtorch.so/"
libnvToolsExt.so.1 : cannot open shared object file : No such file or directory

@kadir-gunel
Copy link
Author

Ok, now the issue is not related with Torch.jl . It was due to the missing system package inside Rocky Linux. By installing openblas-dev and lapack packages everything seems to be working properly. I can form n-dimensional tensors in gpu with cuda 11.3 and cuda 11.8.

Any julia package above 1.8.x series to the latest version 1.11.x can work with Torch.jl, no worries.

I really missed this package. It is great to see it working again!

B.R.

@stemann
Copy link
Collaborator

stemann commented Jan 26, 2025

Great to hear you got it working!

(though you should not need to adjust any system packages)

@stemann
Copy link
Collaborator

stemann commented Jan 26, 2025

It's interesting that you got the issue with libnvToolsExt, as there is (some level of) explicit handling for this in https://github.com/JuliaPackaging/Yggdrasil/blob/7deefacab0cacfe5ccf7d9e437bdeea554dcf1de/T/Torch/build_tarballs.jl#L249

Can you reproduce this error on Julia 1.10 or 1.11? Or is it just on 1.8?

@kadir-gunel
Copy link
Author

I think it was general, because after I installed those packages, it stopped giving errors.

Additionally, I am facing issues when try to send resnet example to torch. But I think it is better to create a new issue for that.

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

2 participants