detectron2 windows 安裝

detectron2 windows 安裝

https://github.com/facebookresearch/detectron2官方目前暫時沒有提供官方的windows安裝教程,這里記錄使用中碰到的坑

1. 主要參考

https://github.com/conansherry/detectron2

2. 安裝依賴

  1. 安裝已有的包

    conda create -n detectron2 python=3.8
    
    conda activate detectron2
    
    conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
    
    pip install cython pycocotools-windows fvcore pydot future tensorboard tqdm mock matplotlib cloudpickle tabulate yacs Pillow termcolor opencv-python
    
  2. 安裝vs2019或者2017,然后執(zhí)行如下
    2019版本執(zhí)行
    set DISTUTILS_USE_SDK=1 set MAX_JOBS=5 "H:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
    2017版本執(zhí)行
    set DISTUTILS_USE_SDK=1 set MAX_JOBS=5 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"

  3. 修改幾處代碼

    file1: 
       E:\ProgramData\Miniconda3\envs\detectron2\lib\site-packages\torch\include\torch\csrc\jit\argument_spec.h
      example:
      {C:\Miniconda3\envs\py36}\Lib\site-packages\torch\include\torch\csrc\jit\argument_spec.h(190)
        static constexpr size_t DEPTH_LIMIT = 128;
          change to -->
        static const size_t DEPTH_LIMIT = 128;
    
    file2: 
       E:\ProgramData\Miniconda3\envs\detectron2\lib\site-packages\torch\include\pybind11\cast.h
      example:
      {C:\Miniconda3\envs\py36}\Lib\site-packages\torch\include\pybind11\cast.h(1449)
        explicit operator type&() { return *(this->value); }
          change to -->
        explicit operator type&() { return *((type*)this->value); }
    
    file3:
     {detectron2 src path}\detectron2\layers\csrc\cocoeval\cocoeval.cpp
    注釋掉下面幾行 localtime_r只有l(wèi)inux有
    //localtime_r(&rawtime, &local_time);
    //strftime(
    //    buffer.data(), 200, "%Y-%m-%d %H:%num_max_detections:%S", &local_time);
    
    
  4. 下載源碼

    git clone --depth=1 https://hub.fastgit.org/facebookresearch/detectron2.git
    cd detectron2
    python setup.py build develop
    
  5. [選擇執(zhí)行,如果后面運行沒有win32錯誤]重新安裝pywin32

    pip uninstall pywin32
    pip install pywin32==225
    
  6. 安裝成功

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容