Fairseq安装

Posted by Weihao Zeng on April 15, 2021

2021-04-15-fairseq安装

因为最近做抽象对话摘要的任务,需要用脸书家的fairseq。按照脸书自己的说法:

1
Fairseq(-py) is a sequence modeling toolkit that allows researchers and developers to train custom models for translation, summarization, language modeling and other text generation tasks.

安装的方式可以参照:

  • PyTorch version >= 1.5.0
  • Python version >= 3.6
  • For training new models, you’ll also need an NVIDIA GPU and NCCL
  • To install fairseq and develop locally:
1
2
3
4
5
6
7
8
9
git clone https://github.com/pytorch/fairseq
cd fairseq
pip install --editable ./

# on MacOS:
# CFLAGS="-stdlib=libc++" pip install --editable ./

# to install the latest stable release (0.10.x)
# pip install fairseq

在安装过程遇到这样的问题:

1
ERROR: Command errored out with exit status 1: /home/ypd-19-2/anaconda3/envs/fairseq/bin/python3.6 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/ypd-19-2/fairseq/fairseq-master/setup.py'"'"'; __file__='"'"'/home/ypd-19-2/fairseq/fairseq-master/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

经过探究发现,是由于gcc的版本问题,建议新建一个conda环境并在里面装一个conda专属的gcc:

1
conda install llvm gcc libgcc