当前位置:   article > 正文

Win10 slowfast实现记录_slowfast安装

slowfast安装

Win10 slowfast安装记录


  • ###重要!!!想要按照这个配置环境的同学请先看此文最后一行!!!###

slow fast教程运行后报错

AttributeError: module 'torch.distributed' has no attribute 'is_initialized'
  • 1

可能是pytorch版本问题,需要升级到1.7。
注意不要用官网的方法,用这个方法在虚拟环境下升级link

  • 卸载当前版本的pytorch

进入虚拟环境,用pip卸载pytorch和torchvision

pip uninstall torch
pip uninstall torchvision
  • 1
  • 2
  • 用conda安装新版本

cuda版本改成对应版本,我的是10.2

conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=10.2 -c pytorch
  • 1

如果conda换过源去掉-c

conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=10.2 pytorch
  • 1
  • 可能遇到的报错总结

  1. 换过源的可能会报如下的错
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
  • 1
  • 2

只需反复执行安装指令,系统就会从中断处继续下载安装包。

  1. 安装下载到100%后可能会报。
InvalidArchiveError('Error with archive your-path\\pkgs\\pytorch-1.7.0-py3.8_cuda102_cudnn7_0.tar.bz2.  You probably need to delete and re-download or re-create this file.  Message from libarchive was:\n\nCould not unlink')
  • 1

此时再执行一次安装指令直到命令行刷新显示结果done。

然后按照这篇博客修改DETECTRON2部分对应文件内容。

修改处1)注释掉your-path\Lib\site-packages\torch\include\torch\csrc\jit\runtime\argument_spec.h的159行,并添加

namespace {
//static constexpr size_t ARG_SPEC_DEPTH_LIMIT = 128; (line159)
static const size_t ARG_SPEC_DEPTH_LIMIT = 128;
}
  • 1
  • 2
  • 3
  • 4

修改处2)注释掉your-env-path\Lib\site-packages\torch\include\pybind11\cast.h的1449行并添加

    //explicit operator type&() { return *(this->value); }
    explicit operator type&() { return ((type)this->value); }
  • 1
  • 2

修改处3)将detectron2\detectron2\layers\csrc\deformable 文件夹下三个文件中全部的AT_CHECK全部替换为TORCH_CHECK

重新调试detectron2
重新设置vc2019配置

SET MSSdk=1
SET DISTUTILS_USE_SDK=1
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 -vcvars_ver=14.27
  • 1
  • 2
  • 3

成功后显示

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.7.6
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
  • 1
  • 2
  • 3
  • 4
  • 5

进入detectron2目录,输入指令

#detectron2安装指令
报extention相关的错
  • 1
  • 2

通过github的issue查找是因为1.7版本pytorch不支持windows上的detectron2.
换1.5版本可以支持detectron2但是不支持slowfast.
还是会报一开始的AttributeError: module 'torch.distributed' has no attribute 'is_initialized'
如果你也遇到和我一样的问题,别浪费时间了,尽早换linux系统吧。
至此放弃win10+torch1.7环境下的slowfast,转为ubuntu20,过程见我另一篇文章

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/864003
推荐阅读
相关标签
  

闽ICP备14008679号