论文名称:E2EC:An End-to-End Contour-based Method for High-quality High-Speed Instance Segmentation
代码地址:https://github.com/zhang-tao-whu/e2ec
因为是新发布的文章,在代码上存在一些问题,本文记录本人在运行过程中所遇到的难题及解决措施
问题描述
问题1:本人使用的服务器显卡为2080ti,CUDA版本为10.2,因此不能跟原作者一样安装pytorch1.7.1+cuda11.0的版本,下为作者原步骤
# Set up the python environment
conda create -n e2ec python=3.7
conda activate e2ec
# install pytorch, the cuda version is 11.1
# You can also install other versions of cuda and pytorch, but please make sure # that the pytorch cuda is consistent with the system cuda
pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
pip install Cython==0.28.2
pip install -r requirements.txt
问题2:安装好虚拟环境以及相应的库之后,需要Compile cuda extensions,也在INSTALL.md中,这个步骤可能出现一堆问题,作者也有提到
ROOT=/path/to/e2ec
cd $ROOT/network/backbone/DCNv2-master
# please check your cuda version and modify the cuda version in the command
export CUDA_HOME="/usr/local/cuda-11.1"
bash ./make.sh
# Maybe you will encounter some build errors. You can choose a plan :
# 1、You can look for another implementation of DCN-V2 and compiled successfully.
# 2、You can set cfg.model.use_dcn as False. This may result in a slight drop in accuracy.
# 3、You can install mmcv, and replace 352 line of network/backbone/dla.py as from mmcv.ops import ModulatedDeformConv2dPack as DCN, replace the deformable_groups in 353 line as deform_groups.
问题3:/home/ubuntu/anaconda3/envs/e2ec/lib/python3.6/site-packages/torch/nn/functional.py:3226: UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details. warnings.warn("Default grid_sample and affine_grid behavior has changed"
问题4:UserWarning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead
问题5:UserWarning: Integer division of tensors using div or / is deprecated, and in a future release div will perform true division as in Python 3. Use true_divide or floor_divide (// in Python) instead.
解决方案:
针对问题1
conda create -n e2ec python=3.6.5
conda activate e2ec
conda install pytorch==1.5.1 torchvision==0.6.1 cudatoolkit=10.2 -c pytorch
pip3 install Cython==0.28.2
pip3 install -r requirements.txt
针对问题2
首先按照问题1的解决步骤去做,然后再按照下述步骤去做
cd /path/DCNv2-master
export CUDA_HOME="/usr/local/cuda-10.2"
bash ./make.sh
/path/就是DCNv2-master所在的路径,每个人都不同,例如我的
如果成功编译CUDA扩展,则会显示如下结果,否则其他情况,可尝试作者提供的思路去做
针对问题3
根据错误提示的路径找到相应的文件,比如我的是/home/ubuntu/anaconda3/envs/e2ec/lib/python3.6/site-packages/torch/nn/functional.py
,找到3226
行,上下翻动找到def grid_sample
函数和 def affine_grid
函数,将align_corners
由False
改为True
,如下所示
针对问题4
属于警告类错误,不理也没事,或者在训练时,往 train_net.py 中添加以下内容(用于忽略警告):
import warnings
warnings.filterwarnings("ignore", category = UserWarning)
针对问题5
“今天把pytorch升级到1.6.0,发现tensor和int之间的除法不能直接用’ / ',明明1.5.0都是可以用的”
这是网上找到的说法,当然,我试了1.5.0,还是报这个错误…无语,不过这也属于警告类错误
解决方法也是有的,不过要找出全部tensor和int相除的代码,再按如下所示去做
result = A / n # not supported in torch 1.6.0
result = torch.floor_divide(A, n) # 方法1得到的结果为整型
result = torch.true_divide(A, n) # 方法2得到带小数点的数值
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)