参考的官方代码:
GitHub - aimagelab/meshed-memory-transformer: Meshed-Memory Transformer for Image Captioning. CVPR 2020
克隆存储库并m2release
使用文件创建 conda 环境environment.yml
:
conda env create -f environment.yml
conda activate m2release
运行程序报错:
Collecting package metadata (repodata.json): done
Solving environment: failed
ResolvePackageNotFound:
- intel-openmp==2019.5=281
- openssl==1.1.1=h7b6447c_0
参考链接中贴出的环境
将源代码中
- openssl==1.1.1=h7b6447c_0
加g,改为
- openssl=1.1.1g=h7b6447c_0
然后参考博客将intel-openmp=2019.5=281注掉:
#- intel-openmp=2019.5=281
重新create,产生各种冲突
The following specifications were found to be incompatible with your system:
- feature:/linux-64::__glibc==2.27=0
- feature:|@/linux-64::__glibc==2.27=0
- cffi==1.13.2=py36h2e261b9_0 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- cryptography==2.8=py36h1ba5d50_0 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- cython==0.29.14=py36he6710b0_0 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- libedit==3.1.20181209=hc058e9b_0 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- libffi==3.2.1=hd88cf55_4 -> libgcc-ng[version='>=7.2.0'] -> __glibc[version='>=2.17']
- mkl-service==2.3.0=py36he904b0f_0 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- mkl_fft==1.0.15=py36ha843d7b_0 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- mkl_random==1.1.0=py36hd6b4f25_0 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- msgpack-python==0.5.6=py36h6bb024c_1 -> libgcc-ng[version='>=7.2.0'] -> __glibc[version='>=2.17']
- ncurses==6.1=he6710b0_1 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- openssl==1.1.1g=h7b6447c_0 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- python==3.6.9=h265db76_0 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- readline==7.0=h7b6447c_5 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- spacy==2.0.11=py36h04863e7_2 -> libgcc-ng[version='>=7.2.0'] -> __glibc[version='>=2.17']
- sqlite==3.30.1=h7b6447c_0 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- thinc==6.11.2=py36hedc7406_1 -> libgcc-ng[version='>=7.2.0'] -> __glibc[version='>=2.17']
- tk==8.6.8=hbc83047_0 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
- xz==5.2.4=h14c3975_4 -> libgcc-ng[version='>=7.2.0'] -> __glibc[version='>=2.17']
- zlib==1.2.11=h7b6447c_3 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17']
Your installed version is: 2.27
经百度,冲突原因是别人电脑和你的电脑的细节不一样,所以把所有第二个等号的内容删掉
dependencies:
- _libgcc_mutex=0.1=main
- asn1crypto=1.2.0=py36_0
- blas=1.0=mkl
- ca-certificates=2019.10.16=0
- certifi=2019.9.11=py36_0
- cffi=1.13.2=py36h2e261b9_0
- chardet=3.0.4=py36_1003
- cryptography=2.8=py36h1ba5d50_0
- cython=0.29.14=py36he6710b0_0
- dill=0.2.9=py36_0
- idna=2.8=py36_0
- intel-openmp=2019.5=281
- libedit=3.1.20181209=hc058e9b_0
- libffi=3.2.1=hd88cf55_4
- libgcc-ng=9.1.0=hdf63c60_0
- libgfortran-ng=7.3.0=hdf63c60_0
- libstdcxx-ng=9.1.0=hdf63c60_0
- mkl=2019.5=281
- mkl-service=2.3.0=py36he904b0f_0
- mkl_fft=1.0.15=py36ha843d7b_0
- mkl_random=1.1.0=py36hd6b4f25_0
- msgpack-numpy=0.4.4.3=py_0
- msgpack-python=0.5.6=py36h6bb024c_1
- ncurses=6.1=he6710b0_1
- openjdk=8.0.152=h46b5887_1
- openssl=1.1.1=h7b6447c_0
- pip=19.3.1=py36_0
- pycparser=2.19=py_0
- pyopenssl=19.1.0=py36_0
- pysocks=1.7.1=py36_0
- python=3.6.9=h265db76_0
- readline=7.0=h7b6447c_5
- requests=2.22.0=py36_0
- setuptools=41.6.0=py36_0
- six=1.13.0=py36_0
- spacy=2.0.11=py36h04863e7_2
- sqlite=3.30.1=h7b6447c_0
- termcolor=1.1.0=py36_1
- thinc=6.11.2=py36hedc7406_1
- tk=8.6.8=hbc83047_0
- toolz=0.10.0=py_0
- urllib3=1.24.2=py36_0
- wheel=0.33.6=py36_0
- xz=5.2.4=h14c3975_4
- zlib=1.2.11=h7b6447c_3
改为
dependencies:
- _libgcc_mutex=0.1
- asn1crypto=1.2.0
- blas=1.0
- ca-certificates=2019.10.16
- certifi=2019.9.11
- cffi=1.13.2
- chardet=3.0.4
- cryptography=2.8
- cython=0.29.14
- dill=0.2.9
- idna=2.8
#- intel-openmp=2019.5=281
- libedit=3.1.20181209
- libffi=3.2.1
- libgcc-ng=9.1.0
- libgfortran-ng=7.3.0
- libstdcxx-ng=9.1.0
- mkl=2019.5
- mkl-service=2.3.0
- mkl_fft=1.0.15
- mkl_random=1.1.0
- msgpack-numpy=0.4.4.3
- msgpack-python=0.5.6
- ncurses=6.1
- openjdk=8.0.152
- openssl=1.1.1
- pip=19.3.1
- pycparser=2.19
- pyopenssl=19.1.0
- pysocks=1.7.1
- python=3.6.9
- readline=7.0
- requests=2.22.
- setuptools=41.6.0
- six=1.13.0
- spacy=2.0.11
- sqlite=3.30.1
- termcolor=1.1.0
- thinc=6.11.2
- tk=8.6.8
- toolz=0.10.0
- urllib3=1.24.2
- wheel=0.33.6
- xz=5.2.4
- zlib=1.2.11
继续create,又报错:
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
failed
CondaEnvException: Pip failed
分析原因是pip的镜像问题,参考博客将镜像设置默认
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
继续create,终于成功啦!!!!结果如下:
Successfully installed absl-py-0.8.1 cycler-0.10.0 cytoolz-0.9.0.1 dill-0.3.4 future-0.17.1 grpcio-1.25.0 h5py-2.8.0 kiwisolver-1.1.0 markdown-3.1.1 matplotlib-2.2.3 msgpack-0.6.2 multiprocess-0.70.9 numpy-1.16.4 pathlib-1.0.1 pathos-0.2.3 pillow-6.2.1 pox-0.2.7 ppft-1.6.6.1 protobuf-3.10.0 pycocotools-2.0.0 pyparsing-2.4.5 python-dateutil-2.8.1 pytz-2019.3 regex-2017.4.5 tensorboard-1.14.0 torch-1.1.0 torchvision-0.3.0 tqdm-4.32.2 ujson-1.35 werkzeug-0.16.0
done
#
# To activate this environment, use
#
# $ conda activate m2release
#
# To deactivate an active environment, use
#
# $ conda deactivate
激活环境,因为用的是miniconda,所以不要听上面建议的,而要用:
source activate m2release
成功激活!然后下载spacy文件,按照建议命令:
python -m spacy download en
安装成功!
Successfully built en-core-web-sm
Installing collected packages: en-core-web-sm
Successfully installed en-core-web-sm-2.0.0
Linking successful
/home/sui/.conda/envs/m2release/lib/python3.6/site-packages/en_core_web_sm
-->
/home/sui/.conda/envs/m2release/lib/python3.6/site-packages/spacy/data/en
You can now load the model via spacy.load('en')
测试一下,成功!如下:
python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import spacy
>>> spacy.load('en')
python train.py --exp_name m2_transformer --batch_size 50 --m 40 --head 8 --warmup 10000 --features_path /path/to/features --annotation_folder annotations