From 81cde55b25da858cb4871a33c21d7745844c5ebd Mon Sep 17 00:00:00 2001 From: Ben Standefer Date: Mon, 29 May 2023 08:32:00 -1000 Subject: [PATCH] README - macOS installation, validating installation (#385) * README - macOS installation, validating installation The "manual installation" section of the README only has Linux and Windows examples, and I had to dig through issues to figure out how to get rust-bert working on macOS (Apple Silicon). This adds "macOS + Homebrew" to the manual installation section. Most macOS users building in Rust would consider it fair to call installing pytorch via Homebrew "manual" installation" (trying to avoid pyenv, pip, etc.) * Update README.md --------- Co-authored-by: guillaume-be --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 31977b5f..f02a7712 100644 --- a/README.md +++ b/README.md @@ -93,12 +93,29 @@ $Env:LIBTORCH = "X:\path\to\libtorch" $Env:Path += ";X:\path\to\libtorch\lib" ``` +#### macOS + Homebrew +```bash +brew install pytorch jq +export LIBTORCH=$(brew --cellar pytorch)/$(brew info --json pytorch | jq -r '.[0].installed[0].version') +export LD_LIBRARY_PATH=${LIBTORCH}/lib:$LD_LIBRARY_PATH +``` + ### Automatic installation Alternatively, you can let the `build` script automatically download the `libtorch` library for you. The `download-libtorch` feature flag needs to be enabled. The CPU version of libtorch will be downloaded by default. To download a CUDA version, please set the environment variable `TORCH_CUDA_VERSION` to `cu118`. Note that the libtorch library is large (order of several GBs for the CUDA-enabled version) and the first build may therefore take several minutes to complete. +### Verifying installation + +Verify your installation (and linking with libtorch) by adding the `rust-bert` dependency to your `Cargo.toml` or by cloning the rust-bert source and running an example: + +```bash +git clone git@github.com:guillaume-be/rust-bert.git +cd rust-bert +cargo run --example sentence_embeddings +``` + ## Ready-to-use pipelines Based on Hugging Face's pipelines, ready to use end-to-end NLP pipelines are available as part of this crate. The following capabilities are currently available: