Paddle与AFFormer环境配置

本次重新记录一下paddle的安装过程,主要是因为在进行服务器环境初始化时没有进行正确的环境安装。

基础环境

在这里插入图片描述

云硬盘部署

在这里插入图片描述

conda安装

Anaconda安装
首先是下载相关包命令:

 sudo wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh

下载完成后执行

bash Anaconda3-2020.02-Linux-x86_64.sh

进行Anaconda的安装
进入安装程序,提示输入“ENTER”继续(Please, press ENTER to continue):如下图

随后一直 enter ,实际上是下划操作,这里出现的都是一下许可条例,直到最后提示是否接受,输入 yes 即可

在这里插入图片描述

随后提示Anaconda3 will now be installed into this location:
/root/anaconda3,即默认安装在该位置,我们选择默认即可,直接回车

在这里插入图片描述

随后便开始安装了,然后提示是否需要初始化,输入yes即可

在这里插入图片描述

最终便安装成功了,最后执行

source ~/.bashrc

然后我们可以像先前一样创建环境,激活环境,安装相应包。

paddle安装

创建conda环境

conda create  -n paddle python=3.7
conda activate paddle

pytorch安装

pip install torch==1.10.1+cu111 torchvision==0.11.2+cu111 torchaudio==0.10.1 -f https://download.pytorch.org/whl/cu111/torch_stable.html

paddle安装

python -m pip install paddlepaddle-gpu==2.4.2 -f https://www.paddlepaddle.org.cn/whl/windows/mkl/avx/stable.html

其他依赖包安装

pip install -r requirements.txt --index-url https://pypi.douban.com/simple

报错:

ImportError: libcudart.so.10.2: cannot open shared object file: No
such file or directory

解决方案:
从别的地方下载该文件然后传上去

在这里插入图片描述
再运行下面命令即可

sudo ldconfig /usr/local/cuda-11.2/lib64

Paddle环境的配置本身不难,但由于先前预装系统出现问题导致了一系列的错误。
训练过程:

在这里插入图片描述
注意:一定要与这个文件。

在这里插入图片描述

ArtFormer环境配置

环境:CUDA11.2

安装pytorch

pip install torch==1.10.0+cu111 torchvision==0.11.0+cu111 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html

安装MMCV

MMCV安装

pip install mmcv==2.0.0rc4 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.10/index.html

在这里插入图片描述

安装MMCV-full

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.10.0/index.html

在这里插入图片描述

其他依赖

pip install timm
pip install opencv-python
pip install einops

报错

报错1:

ModuleNotFoundError: No module named ‘mmseg‘

解决1:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple mmsegmentation

但这个还是会报错:

from mmseg.apis import init_random_seed, set_random_seed,
train_segmentor ImportError: cannot import name ‘init_random_seed’
from ‘mmseg.apis’

其实是版本不对,解决:

pip install mmsegmentation==0.30.0

报错2:

File “/home/ubuntu/anaconda3/envs/afformer/lib/python3.7/site-packages/mmseg/init.py”,line 62, in
f’MMCV=={mmcv.version} is used but incompatible. ’ \ AssertionError: MMCV==1.7.1 is used but incompatible. Please install mmcv>=2.0.0rc4.

解决2:修改/home/ubuntu/anaconda3/envs/afformer/lib/python3.7/site-packages/mmseg/init.py文件中:

在这里插入图片描述
报错3:

AttributeError: module 'torch.nn' has no attribute 'SiLU'

解决3:方法缺失,一般是由于torch版本导致,果断换torch版本

运行

切换到tools下,执行python train.py
报错:

raise type(e)(f'{
      
      obj_cls.__name__}: {
      
      e}')
KeyError: "EncoderDecoder: 'CLS is not in the models registry'"

这是由于源码中已经有一个mmseg了,而我们的安装包中也有一个与之重名了,将安装包删掉即可。
随后运行:

python setup.py develop

最终安装后的环境为:

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/pengxiang1998/article/details/131095575