fairseq2 icon indicating copy to clipboard operation
fairseq2 copied to clipboard

OSError: fairseq2 requires libsndfile. Since you are in a Conda environment, use `conda install -c conda-forge libsndfile==1.0.31` to install it.

Open ZhaoningYu1996 opened this issue 8 months ago • 1 comments

Hi, I have an error when try to run tutorial of end_to_end_fine_tuning.

The commend I am running:

fairseq2 lm instruction_finetune $OUTPUT_DIR --config-file configs/sft.yaml

The error message is below:

Traceback (most recent call last):
  File "/home/yu/projects/RLHF/rlhf/bin/fairseq2", line 5, in <module>
    from fairseq2.cli import main
  File "/home/yu/projects/RLHF/rlhf/lib/python3.10/site-packages/fairseq2/__init__.py", line 11, in <module>
    import fairseq2n  # Report any fairseq2n initialization error eagerly.
  File "/home/yu/projects/RLHF/rlhf/lib/python3.10/site-packages/fairseq2n/__init__.py", line 169, in <module>
    _load_shared_libraries()
  File "/home/yu/projects/RLHF/rlhf/lib/python3.10/site-packages/fairseq2n/__init__.py", line 88, in _load_shared_libraries
    _load_sndfile()
  File "/home/yu/projects/RLHF/rlhf/lib/python3.10/site-packages/fairseq2n/__init__.py", line 115, in _load_sndfile
    raise OSError(
OSError: fairseq2 requires libsndfile. Since you are in a Conda environment, use `conda install -c conda-forge libsndfile==1.0.31` to install it.

I installed the libsndfile through:

sudo apt install libsndfile1

And installed the pytorch and fairseq2 in a venv environment through:

pip3 install torch torchvision torchaudio
pip install fairseq2\
  --extra-index-url https://fair.pkg.atmeta.com/fairseq2/whl/pt2.6.0/cu124

Following issue #10, I disabled conda by comment out related code in ~/.bashrc:

## >>> conda initialize >>>
## !! Contents within this block are managed by 'conda init' !!
#__conda_setup="$('/home/yu/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
#if [ $? -eq 0 ]; then
#    eval "$__conda_setup"
#else
#    if [ -f "/home/yu/anaconda3/etc/profile.d/conda.sh" ]; then
#        . "/home/yu/anaconda3/etc/profile.d/conda.sh"
#    else
#        export PATH="/home/yu/anaconda3/bin:$PATH"
#    fi
#fi
#unset __conda_setup
## <<< conda initialize <<<

But it does not work for me, and I still face this error.

ZhaoningYu1996 avatar Mar 07 '25 18:03 ZhaoningYu1996

Same error in miniconda OSX, python versions 3.10, 3.11 and 3.12.

stuta avatar Apr 26 '25 15:04 stuta

ln -s /usr/lib/x86_64-linux-gnu/libsndfile.so.1 /usr/lib/x86_64-linux-gnu/libsndfile.so works for me on Linux.

LoganLiu66 avatar Nov 17 '25 09:11 LoganLiu66