Git Product home page Git Product logo

Comments (9)

eonm-pro avatar eonm-pro commented on May 20, 2024 1

Hello,

Here's the content of my LIBTORCH env var :

echo $LIBTORCH
/home/mathis/Téléchargements/libtorch

And here's what I exactly did :

wget -P ~/Téléchargements https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-1.7.1%2Bcpu.zip
unzip ~/Téléchargements/libtorch-shared-with-deps-1.7.1+cpu.zip
echo 'export LIBTORCH=/home/mathis/Téléchargements/libtorch' >> ~/.zshrc
source ~/.zshrc

cargo clean
cargo run --example generation

I also tried with other patch versions of libtorch 1.7.* without success.

For testing purposes, I also tried to run example from the tch-rs crate with my current installation. It failed even after downloading libtorch 1.8. When I'm using a local version of libtorch the compilation gives me cc error.

So I tried the solution of this comment LaurentMazare/tch-rs#329 (comment): I unset the LIBTORCH env variable and I installed the python-pytorch-cuda package. I was able to run cargo run --example basics. Unfortunately, this solution doesn't work with rust-bert.

from rust-bert.

guillaume-be avatar guillaume-be commented on May 20, 2024

Hello @eonm-abes ,

These indeed look like errors happening at linking phase, possibly because the tch-sys dependency was built with a different version of libtorch. What I would recommend is a "clean install" of the library:

  1. Delete the target folder in rust-bert
  2. Ensure you have downloaded the version of libtorch compatible with your system (I assume CPU-Linux-1.7.1 in your case)
  3. Ensure the environment variable LIBTORCH is set to the correct folder. If you downloaded a CUDA-enabled version of Libtorch, set the TORCH_CUDA_VERSION environment variable to cu111 or cu101 depending on the version you installed.

Can you please try these steps and let me know if the error persists?

from rust-bert.

eonm-pro avatar eonm-pro commented on May 20, 2024

@guillaume-be sorry for the late reply,

No it didn't work. I have the same error again. I'm suspecting that the problem is related to my Linux distribution (manjaro), and the python packages I installed with my package manager. Installing packages both with pip and my package manager seems to create version conflict. I don't have time to test this hypothesis with a fresh install of manjaro so I used a workaround that involves Docker :

docker run --rm --user "$(id -u)":"$(id -g)" -e RUSTBERT_CACHE=/usr/src/myapp/cache -v "$PWD":/usr/src/myapp -w /usr/src/myapp rust:latest cargo run --example generation

and Hooray 🎉 :

Downloading https://huggingface.co/gpt2-medium/resolve/main/config.json [718B]... ✓ Done! Finished in 0 seconds
Downloading https://huggingface.co/gpt2-medium/resolve/main/vocab.json [1017.87KB]... ✓ Done! Finished in 0 seconds
Downloading https://huggingface.co/gpt2-medium/resolve/main/merges.txt [445.62KB]... ✓ Done! Finished in 0 seconds
Downloading https://huggingface.co/gpt2-medium/resolve/main/rust_model.ot [1.61GB].................... ✓ Done! Finished in 3 minutes
"The dog\'s name is androgyny, and it\'s also the name of the species in which it lives.\n\nIt doesn\'t"
"The dog has also been diagnosed with a rare type of cancer known as multiple myeloma, which is spread from the bone marrow to the lymph"
"The dog\'s owner, whose name has not been released, told police that the dog had been barking for at least an hour.\n\nThe"
"The cat was caught by one of the dogs and was taken to a vet where it was found to be in good health.\n\nIt was taken"
"The cat was lying on its back on the floor of the kitchen with its eyes closed.\n\n\"What\'s going on?\" I asked.\n"
"The cat was taken to a vet, who determined it was suffering from a rare form of cancer.\n\nThe cat\'s owner, the Daily Mail"

Don't forget to create the cache folder inside the repo !

from rust-bert.

guillaume-be avatar guillaume-be commented on May 20, 2024

Hello @eonm-abes ,

This is surprising, the python package should not influence the behaviour of this crate since it does not rely on Python. Could you please check the value of your environment variable LIBTORCH?

My guess is that it points to a libtorch location that is incompatible with the compiled tch crate.

from rust-bert.

paulbricman avatar paulbricman commented on May 20, 2024

@guillaume-be, I had some similar experiences on Ubuntu using a dummy example:

  • if $LIBTORCH is set to nothing then:
    • cargo run works
    • cargo build works
    • BUT in order to be able to run the resulting binary, I have to set $LIBTORCH to a path from the resulting target folder which houses a libtorch copy.
  • if $LIBTORCH is set to a local libtorch copy
    • nothing works

When $LIBTORCH is set to nothing, cargo is probably downloading a fresh copy there and then? But then it's still not packaging that as part of the binary, you have to set an env variable to point to the one which showed up in the target folder. Is there a way this could be avoided? As in, a fresh copy of libtorch could be fetched and also integrated in the (chunky) binary so that you don't need to set env variables before running it?

from rust-bert.

guillaume-be avatar guillaume-be commented on May 20, 2024

Hello @eonm-abes , @paulbricman ,

I was able to reproduce the issue on my Ubuntu installation, and found a fix for my local setup.
I see you are downloading the Pre-cxx11 ABI version of Libtorch (https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-1.7.1%2Bcpu.zip).

Could you please try to download the cxx11 ABI version of Libtorch? (https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.8.1%2Bcpu.zip) and let me know if this works for you? This is the default version downloaded when the LIBTORCH environment variable is not set, and would explain why the libraries build when the download proceed automatically but does not work with your manual installation.

from rust-bert.

eonm-pro avatar eonm-pro commented on May 20, 2024

@guillaume-be 👏 👏,

I cleaned my project with cargo clean to be sure, and it works !

This is awesome.
Thank you so much.

from rust-bert.

paulbricman avatar paulbricman commented on May 20, 2024

Works like a charm. Thank you so much for the effort you're putting into this package, @guillaume-be!

from rust-bert.

guillaume-be avatar guillaume-be commented on May 20, 2024

Great - glad this is working!

from rust-bert.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.