2

直到昨天,我们正常安装了 fairseq 并执行了它。

今天突然出现一个名为“ModuleNotFoundError: No module named 'fairseq'”的错误。

有谁知道如何解决这个问题?

安装 fairseq...

!git clone https://private_information.../fairseq.git
%cd /content/fairseq/fairseq-master/
!git reset --hard dafault
!pip install --editable ./
%cd /content

安装日志...

Cloning into 'fairseq'...
remote: Enumerating objects: 669, done.
remote: Counting objects: 100% (669/669), done.
remote: Compressing objects: 100% (520/520), done.
remote: Total 669 (delta 164), reused 635 (delta 130), pack-reused 0
Receiving objects: 100% (669/669), 2.95 MiB | 16.17 MiB/s, done.
Resolving deltas: 100% (164/164), done.
/content/fairseq/fairseq-master
HEAD is now at 16bea6e default
Obtaining file:///content/fairseq/fairseq-master
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Collecting sacrebleu
  Downloading https://files.pythonhosted.org/packages/23/d3/be980ad7cda7c4bbfa97ee3de062fb3014fc1a34d6dd5b82d7b92f8d6522/sacrebleu-1.4.13-py3-none-any.whl (43kB)
     |████████████████████████████████| 51kB 2.0MB/s 
Requirement already satisfied: cffi in /usr/local/lib/python3.6/dist-packages (from fairseq==0.9.0) (1.14.2)
Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from fairseq==0.9.0) (4.41.1)
Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from fairseq==0.9.0) (1.18.5)
Requirement already satisfied: torch in /usr/local/lib/python3.6/dist-packages (from fairseq==0.9.0) (1.6.0+cu101)
Requirement already satisfied: regex in /usr/local/lib/python3.6/dist-packages (from fairseq==0.9.0) (2019.12.20)
Requirement already satisfied: cython in /usr/local/lib/python3.6/dist-packages (from fairseq==0.9.0) (0.29.21)
Collecting portalocker
  Downloading https://files.pythonhosted.org/packages/89/a6/3814b7107e0788040870e8825eebf214d72166adf656ba7d4bf14759a06a/portalocker-2.0.0-py2.py3-none-any.whl
Requirement already satisfied: pycparser in /usr/local/lib/python3.6/dist-packages (from cffi->fairseq==0.9.0) (2.20)
Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from torch->fairseq==0.9.0) (0.16.0)
Installing collected packages: portalocker, sacrebleu, fairseq
  Running setup.py develop for fairseq
Successfully installed fairseq portalocker-2.0.0 sacrebleu-1.4.13
/content

跑...

!python /content/fairseq/fairseq-master/fairseq_cli/train.py \
    /data_dir \
    --arch transformer_align --share-all-embeddings \
    --optimizer adam --adam-betas '(0.9, 0.98)' --clip-norm 0.0 --activation-fn relu\
    --lr 0.0007 --lr-scheduler inverse_sqrt --warmup-updates 4000 --warmup-init-lr 1e-07 \
    --dropout 0.3 --attention-dropout 0.1 --weight-decay 0.0\
    --max-tokens 3500 --label-smoothing 0.1 \
    --save-dir /save_dir/ --log-interval 200 --max-epoch 20 \
    --keep-interval-updates -1 --save-interval-updates 0 --criterion label_smoothed_cross_entropy \
    --update-freq 8 \
   

运行日志...

Traceback (most recent call last):
  File "/content/fairseq/fairseq-master/fairseq_cli/train.py", line 20, in <module>
    from fairseq import (
ModuleNotFoundError: No module named 'fairseq'
4

0 回答 0