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

FR: Mention need for setting runtime paths for libtorch #1

Open
n8henrie opened this issue Jul 27, 2023 · 8 comments
Open

FR: Mention need for setting runtime paths for libtorch #1

n8henrie opened this issue Jul 27, 2023 · 8 comments

Comments

@n8henrie
Copy link

I ran into some errors due to missing a system install of libtorch at the expected path. I was able to trace these errors back to: https://github.com/LaurentMazare/tch-rs#libtorch-manual-install and the need to set some environment variables like LIBTORCH or LIBTORCH_USE_PYTORCH.

I'm trying to get this working with nix (on aarch64-darwin) but not having luck so far.

@Gadersd
Copy link
Owner

Gadersd commented Jul 28, 2023

Torch is such a painful dependency to work with so I switched the backend from tch to wgpu. Try and see if it works for you now.

@n8henrie
Copy link
Author

I'd like to get torch working if I can. Looks like there is some issues with tch and MPS support though: LaurentMazare/tch-rs#777

@antimora
Copy link

@n8henrie, I am the burn team and I worked on getting torch working on Mac.

Normally, tch-rs will download the library and save it under the target directory. tch-rs gives a few option to reference libtorch, for burn by default we picked download.

I would recommend you remove all environment variables LIBTORCH and LIBTORCH_USE_PYTORCH first. This will use the downloaded version. Make sure you do not have this in your .cargo/config.toml as well. Afterwards, you can move forward using the system installed version if you'd like

If you're still having trouble, you can ping the team on Discord or file an issue ticket with Burn. We will prioritize it.

@n8henrie
Copy link
Author

n8henrie commented Aug 4, 2023

Thanks for the suggestion. Clearing the env and rebuilding seems to work if I run as per the example:

$ cargo run --release audio.wav tiny_en
...
Transcribed text: <|0.00|> Hello, I am the whisper machine learning model. If you see this as text then I am working properly.

but curiously the binary fails if I try to run directly:

$ target/release/whisper audio.wav tiny_en
dyld[47393]: Library not loaded: @rpath/libtorch_cpu.dylib
  Referenced from: <4C4C4450-5555-3144-A167-13D0CD0B6346> /Users/n8henrie/git/whisper-burn/target/release/whisper
  Reason: tried: '/usr/local/lib/libtorch_cpu.dylib' (no such file), '/usr/lib/libtorch_cpu.dylib' (no such file, not in dyld cache)
Abort trap: 6

Should this be a new / separate issue? Seems like it's still on the same theme of finding the libtorch bindings.

@antimora
Copy link

antimora commented Aug 4, 2023

huh that's interesting bug. Let me try to replicate it and we probably file a ticket with tch-rs team if it's an upstream problem.

@antimora
Copy link

antimora commented Aug 4, 2023

What I will do is to file a ticket with Burn and fix the situation with Torch dependency. We should have good documents to troubleshoot and correct tools. It's far to often people struggle (including myself with Mac installation in the past). So expect a ticket link here and we will collect issue there, including running the binary as standalone (did not test myself yet) like @n8henrie found out.

@antimora
Copy link

antimora commented Aug 4, 2023

I have created an issue ticket with Burn: tracel-ai/burn#587 so that we can improve Libtorch set up.

@n8henrie
Copy link
Author

n8henrie commented Aug 4, 2023

Thanks for your attention to the matter!

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

3 participants