安装fairseq: pip install –editable 始终卡进度条 installing build dependencies…|解决办法

安装fairseq: pip install –editable 始终卡进度条 installing build dependencies…|解决办法

更新03.08

倘若git clone -release 分支而不是main 分支,pip install –editable大概也不会报错了…
我遇到的问题,有可能是由于main分支尚存在bug,install时遇到bug不得不卡住。
(暴风哭泣 心疼我的时间)

在Linux上创建了个虚拟环境,Fairseq安装指导说,只需要简单的 三步 即可完成…然后我用了三天。

Fairseq给出的安装方法:

# To install fairseq and develop locally
git clone https://github.com/pytorch/fairseq
cd fairseq
pip install --editable ./

问题

运行pip install --editable ./时,卡在installing build dependencies…|,没有报错和提示。

卡在进度条

首先排除了镜像源(网络问题连不上pypi服务器)的可能;然后试图换conda install --use-local fairseq也没用。

我的安装环境是:

解决

第一步,改用pip install --editable ./ --no-build-isolation。方法参考自fairseq issue

The idea is that a package can be built more consistently if it’s not affected by the packages in your working environment. h5py normally says it requires numpy & Cython, but setting H5PY_SETUP_REQUIRES=0 disables that, so pip tries to build it without them. The –no-build-isolation flag for pip install tells pip that you have already installed the build dependencies and want to build with whatever packages are in the environment where pip itself is installed.

所以查阅github issues真的很重要!(为什么我没有早一点看到它…虽然并不懂这一步的作用。

第二步,创建虚拟环境 –> 安装正确版本的torch –> 安装fairseq。(顺序很重要)

我安装fairseq-main的时候(2023/02/12),只能用torch 1.13;我试了用1.12安装fairseq,它会自动删除1.12,然后更新下载1.13,而且安装后会报错:OSError: …/site-packages/nvidia/cublas/lib/libcublas.so.11: symbol cublasLtGetStatusString version libcublasLt.so.11 not defined in file libcublasLt.so.11 with link time reference。

上具体代码:

# 创建虚拟环境
conda create -n pure38 python=3.8 

# 安装torch 1.13
# 可以在官网查询:https://pytorch.org/get-started/locally/
conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia

# 下载fairseq-main
git clone https://github.com/pytorch/fairseq
cd fairseq
pip install --editable ./ --no-build-isolation 

安装后,我还遇到了一个报错:找不到sentencepiece包
于是,

pip install sentencepiece

然后成功了!!隐去了个人信息 😃

安装fairseq: pip install --editable 始终卡进度条 installing build dependencies...|解决办法

祝大家好运!!

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
乘风的头像乘风管理团队
上一篇 2023年3月29日
下一篇 2023年3月29日

相关推荐