rust-bert icon indicating copy to clipboard operation
rust-bert copied to clipboard

trying to run examples on Mac M1

Open raoulg opened this issue 3 years ago • 1 comments

Trying to build some examples on a Mac M1. However, I get errors like this:

Running /rust-bert/target/debug/convert-tensor sentiment_analysis.rs dyld[21044]: symbol not found in flat namespace (__ZN2at4_ops5zeros4callEN3c108ArrayRefIxEENS2_8optionalINS2_10ScalarTypeEEENS5_INS2_6LayoutEEENS5_INS2_6DeviceEEENS5_IbEE) [1] 21044 abort

I downloaded libtorch, and added the environment variables as described. No idea how to fix this...

raoulg avatar Aug 09 '22 14:08 raoulg

For me, use brew-installed python, and add environment to .zprofile

export LIBTORCH="/opt/homebrew/lib/python3.9/site-packages/torch"
export DYLD_LIBRARY_PATH=${LIBTORCH}/lib:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=${LIBTORCH}/lib:$LD_LIBRARY_PATH

garyhai avatar Aug 11 '22 06:08 garyhai

I followed the README:

  • installed libtorch from the PyTorch page
  • The libtorch zip is unpacked. I point the variables to the libtorch folders
  • Added the additional paths like you suggested

export LIBTORCH="/Users/raoulgrouls/code/libtorch" export LD_LIBRARY_PATH=${LIBTORCH}/lib:$LD_LIBRARY_PATH export DYLD_LIBRARY_PATH=${LIBTORCH}/lib:$DYLD_LIBRARY_PATH

reloaded shell, checked if the exports where there. But, still:

Finished dev [unoptimized + debuginfo] target(s) in 0.11s Runningtarget/debug/examples/zero_shot_classificationdyld[63328]: symbol not found in flat namespace (__ZN2at4_ops10_cast_Byte4callERKNS_6TensorEb) [1] 63328 abort cargo run --example zero_shot_classification

One difference could be, you see to point the LIBTORCH to a torch installation inside python? I'll try that too...

raoulg avatar Aug 13 '22 19:08 raoulg

Ah, yes, so that's the problem.

  • I created a venv with python -m venv env
  • pip install torch
  • navigated into the environment, find the lib/python3.9/site-packages/torch location, added the full path of that to the export LIBTORCH in .zprofile
  • restart terminal

This fixed it, model is now downloading! Thanks for the help!

raoulg avatar Aug 13 '22 20:08 raoulg