小白maskrcnn环境配置(pytorch版)及报错大全集锦(遇到超级多报错,有超多经验)

一.maskrcnn配置环境

1.前提:

虚拟环境anaconda+pytorch1.0 nightly(就是最新版,但是2024年的最新版pytorch已经不适配了,我这里用的是1.7.0)

1.1anaconda下载安装 链接:

是我们导师给的链接

pycharm、anaconda、pytorch安装以及环境配置(超详细教程)_pycharm配置anaconda运行环境-CSDN博客

1.2maskrcnn官网链接:

facebookresearch/maskrcnn-benchmark:PyTorch 中实例分割和对象检测算法的快速模块化参考实现。 (github.com)

1.3pytorch1.7.0 CUDA版本为11.0,CUDNN版本为8.9.2

1.安装多个cuda的教程我看的这个:https://blog.csdn.net/weixin_39450145/article/details/125630585?spm=1001.2014.3001.5506

2.cuda11.0 cuDNN的安装我看的这个:

Windows10系统pytorch、cuda11.0、cuDNN安装_cudnn11-CSDN博客

注:1.这步主要安装对应的cuda环境,不要安装pytorch

     2.只有NVIDIA的显卡能安装cuda

     3.cuda最高能安装到什么版本要看自己的显卡  

        在终端输入:nvidia-smi可以看到

2.按照官网一步一步配置环境

1.Requirements:

  • PyTorch 1.0 from a nightly release. It will not work with 1.0 nor 1.0.1. Installation instructions can be found in Start Locally | PyTorch
  • torchvision from master
  • cocoapi
  • yacs
  • matplotlib
  • GCC >= 4.9
  • OpenCV
  • CUDA >= 9.0

2.Install

github项目官方install链接

2.1创建虚拟环境
conda create --name maskrcnn_benchmark python==3.7 -y
conda activate maskrcnn_benchmark
2.2 为新python安装正确的pip和依赖项
conda install ipython pip
2.3安装依赖(opencv建议安装低版本):
pip install ninja yacs cython matplotlib tqdm -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install opencv-python==3.4.10.35 -i https://pypi.tuna.tsinghua.edu.cn/simple
2.4安装Pytorch(这里建议安装1.7.0版本)
conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=11.0 -c pytorch
2.5正式安装(官方步骤):

首先保证你下载了vs2019,因为这个项目只支持2015-2019的版本!!!!!!!!!!!!!!!!!很重要因为这一步不对我后续报超级多错

下载vs2019链接:Visual Studio 2019 下载安装_vs2019下载-CSDN博客

我也建议咱们在下一个Microsoft Visual C++ Build Tools14.0(但是报错后先下载了vstools14.0 和我原有的visual stdio2022运行的,到最后一步vs版本还是不对,我又下的vs2019,所以Tools14.0我不确定是否必须下载,感兴趣的可以先不下14.0看看报不报错)

2.5.1pycocotools,cityscapesScripts
export INSTALL_DIR=$PWD

# install pycocotools
cd $INSTALL_DIR
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
python setup.py build_ext install
 
# install cityscapesScripts
cd $INSTALL_DIR
git clone https://github.com/mcordts/cityscapesScripts.git
cd cityscapesScripts/
python setup.py build_ext install
需要注意的以及可能会出现的报错:

        1.这里要用到git下载项目,我用的下载教程:


Git下载安装及环境配置,解决安装包下载慢问题(详细版)-CSDN博客

git安装详细过程及常见错误解决过程_安装git网络问题-CSDN博客

        2.Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ Tools"

error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ Tools":

因为我没安装Visual Studio,就出了这个错
解决方法(不用下Visual Studio,下一个Microsoft Visual C++ Build Tools安装就行)
安装方法:visual c++ build tools的安装与使用 

 我下载的是这个链接的vs14.0:maskrcnn-benchmark win10安装报错及解决方案_attrs==21.2.0-CSDN博客

下载 visualcppbuildtools_full.exe. 目前从网上找到的不是无法安装就是损坏,可从百度网盘下载。
链接:百度网盘 请输入提取码
提取码:1234
解压后直接点击安装即可 

安装后要配置变量,就跟这个链接一步一步做就行

        3.Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件.warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))     代表找不到cl.exe这个文件->配置环境变量就行

 如果报这个错可以看这个链接:小白跑deep snake(巨详细)_thcnumerics.cuh(196): error : more than one operat-CSDN博客

E:\Python\Lib\site-packages\torch\utils\cpp_extension.py:189: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。
 warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))

这是我所有配置的环境变量可以借鉴一下.

        4.''Your compiler (cl 19.00.24210) may be ABI-incompatible with PyTorch!
        Please use a compiler that is ABI-compatible with GCC 4.9 and above.
        See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html.''

E:\Python\lib\site-packages\torch(utils\cpp_extension.py:191: UserWarning:
                     !! WARNING !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Your compiler (cl 19.00.24210) may be ABI-incompatible with PyTorch!
Please use a compiler that is ABI-compatible with GCC 4.9 and above.
See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html.

See https://gist.github.com/goldsborough/d466f43e8ffc948ff92de7486c5216d6
for instructions on how to install GCC 4.9 or higher.

编译器cl跟PyTorch不兼容,不用管,只是个WARING   我们主要解决ERROR就行

2.5.2安装apex:

建议用git克隆完整的apex包,然后再退回老版本的apex

cd $INSTALL_DIR
 
git clone https://github.com/NVIDIA/apex.git #git克隆,不要用网页下载压缩包
cd apex
git checkout f3a960f80244cf9e80558ab30f7f7e8cbf03c0a0 # 回退到老版本
python setup.py install --cuda_ext --cpp_ext
2.5.3安装maskrcnn:
cd $INSTALL_DIR
git clone https://github.com/facebookresearch/maskrcnn-benchmark.git
cd maskrcnn-benchmark
# 添加路径
cuda_dir="maskrcnn_benchmark/csrc/cuda"
perl -i -pe 's/AT_CHECK/TORCH_CHECK/' $cuda_dir/deform_pool_cuda.cu $cuda_dir/deform_conv_cuda.cu
# You can then run the regular setup command
# 编译
python setup.py build develop

2.6其余我遇到的报错:

1.编译错误:error: identifier “AT_CHECK“ is undefined

编译错误:error: identifier “AT_CHECK“ is undefined_atcheck torchcheck-CSDN博客

2.计算机丢失mspdb60.dll6,VC++6.0提示找不到mspdb60.dll之解决办法

计算机丢失mspdb60.dll6,VC++6.0提示找不到mspdb60.dll之解决办法-CSDN博客

3.error: command ‘C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin\nvcc.exe’ failed with exit status 1

maskrcnn-benchmark win10安装报错及解决方案_attrs==21.2.0-CSDN博客

4.windows环境下cuda报错:nvcc fatal : Unsupported gpu architecture ‘compute_86‘       !!!!!!!!!找了很久的一个错

windows环境下cuda报错:nvcc fatal : Unsupported gpu architecture ‘compute_86‘_peft cuda 报错-CSDN博客

5.“subprocess.CalledProcessError: Command ‘[‘ninja‘, ‘-v‘]‘ returned non-zero exit status 1”解决方法

出现错误“subprocess.CalledProcessError: Command ‘[‘ninja‘, ‘-v‘]‘ returned non-zero exit status 1”解决方法_subprocess.calledprocesserror: command '['ninja', -CSDN博客

6.讲解cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp” 和 cl: 命令行 error D8021 :无效的数值参数“/Wno-unused-function”

讲解cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp” 和 cl: 命令行 error D8021 :无效的数值参数“/Wno-unused-function”_visual studio no-unused-function-CSDN博客

3.总体环境+版本pip list +conda list

(maskrcnn_benchmark) C:\Users\86189>pip list
Package             Version     Editable project location
------------------- ----------- -------------------------------
aiohttp             3.8.6
aiosignal           1.3.1
apex                0.1
appdirs             1.4.4
async-timeout       4.0.3
asyncio             3.4.3
asynctest           0.13.0
attrs               23.2.0
Automat             22.10.0
backcall            0.2.0
beautifulsoup4      4.12.3
bs4                 0.0.2
certifi             2024.2.2
cffi                1.15.1
charset-normalizer  3.3.2
cityscapesScripts   2.2.3
colorama            0.4.6
coloredlogs         15.0.1
constantly          15.1.0
cryptography        42.0.8
cssselect           1.2.0
curl-cffi           0.5.10
cycler              0.11.0
Cython              3.0.10
decorator           4.4.2
dnspython           2.3.0
exceptiongroup      1.2.1
filelock            3.12.2
flit_core           3.6.0
fonttools           4.38.0
frozenlist          1.3.3
gevent              22.10.2
greenlet            3.0.3
h11                 0.14.0
humanfriendly       10.0
hyperlink           21.0.0
idna                3.7
imageio             2.31.2
imageio-ffmpeg      0.4.9
importlib-metadata  6.7.0
incremental         22.10.0
ipython             7.31.1
itemadapter         0.8.0
itemloaders         1.1.0
jedi                0.18.1
jmespath            1.0.1
jsonpath            0.82.2
kiwisolver          1.4.5
lxml                5.2.2
lxml-stubs          0.5.1
maskrcnn-benchmark  0.1         e:\pytorch__\maskrcnn-benchmark
matplotlib          3.5.3
matplotlib-inline   0.1.6
mkl-fft             1.3.1
mkl-random          1.2.2
mkl-service         2.4.0
moviepy             1.0.3
multidict           6.0.5
ninja               1.11.1.1
numpy               1.21.6
opencv-python       3.4.10.35
outcome             1.3.0.post0
packaging           24.0
parsel              1.8.1
parso               0.8.3
pickleshare         0.7.5
Pillow              9.5.0
pip                 24.0
proglog             0.1.10
prompt-toolkit      3.0.36
Protego             0.3.0
py                  1.11.0
pyasn1              0.5.1
pyasn1-modules      0.3.0
pycocotools         2.0
pycparser           2.21
PyDispatcher        2.0.7
PyExecJS            1.5.1
Pygments            2.11.2
pymongo             4.7.2
pyOpenSSL           24.1.0
pyparsing           3.1.2
pyquaternion        0.9.9
pyquery             2.0.0
pyreadline          2.1
PySocks             1.7.1
python-dateutil     2.9.0.post0
PyYAML              6.0.1
queuelib            1.6.2
requests            2.31.0
requests-file       2.1.0
retry               0.9.2
retrying            1.3.4
Scrapy              2.9.0
selenium            4.11.2
service-identity    21.1.0
setuptools          59.6.0
six                 1.16.0
sniffio             1.3.1
sortedcontainers    2.4.0
soupsieve           2.4.1
tldextract          4.0.0
torch               1.7.0
torchaudio          0.7.0
torchvision         0.8.0
tqdm                4.66.4
traitlets           5.7.1
trio                0.22.2
trio-websocket      0.11.1
Twisted             22.10.0
twisted-iocpsupport 1.0.4
typing              3.10.0.0
typing_extensions   4.7.1
urllib3             2.0.7
w3lib               2.1.2
wcwidth             0.2.5
wheel               0.38.4
wincertstore        0.2
wsproto             1.2.0
yacs                0.1.8
yarl                1.9.4
zipp                3.15.0
zope.event          5.0
zope.interface      6.4.post2
(maskrcnn_benchmark) C:\Users\86189>conda list
# packages in environment at E:\Python37\anaconda3\envs\maskrcnn_benchmark:
#
# Name                    Version                   Build  Channel
apex                      0.1                      pypi_0    pypi
appdirs                   1.4.4                    pypi_0    pypi
backcall                  0.2.0              pyhd3eb1b0_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
blas                      1.0                         mkl    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
certifi                   2022.12.7        py37haa95532_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cityscapesscripts         2.2.3                    pypi_0    pypi
colorama                  0.4.6            py37haa95532_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
coloredlogs               15.0.1                   pypi_0    pypi
cudatoolkit               11.0.221             h74a9793_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cycler                    0.11.0                   pypi_0    pypi
cython                    3.0.10                   pypi_0    pypi
decorator                 5.1.1              pyhd3eb1b0_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
flit-core                 3.6.0              pyhd3eb1b0_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
freetype                  2.12.1               ha860e81_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
giflib                    5.2.1                h8cc25b3_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
humanfriendly             10.0                     pypi_0    pypi
intel-openmp              2021.4.0          haa95532_3556    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ipython                   7.31.1           py37haa95532_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
jedi                      0.18.1           py37haa95532_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
jpeg                      9e                   h2bbff1b_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
kiwisolver                1.4.5                    pypi_0    pypi
lerc                      3.0                  hd77b12b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libdeflate                1.17                 h2bbff1b_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libpng                    1.6.39               h8cc25b3_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libtiff                   4.5.1                hd77b12b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libuv                     1.44.2               h2bbff1b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libwebp                   1.2.4                hbc33d0d_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libwebp-base              1.2.4                h2bbff1b_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
lz4-c                     1.9.4                h2bbff1b_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
maskrcnn-benchmark        0.1                       dev_0    <develop>
matplotlib                3.5.3                    pypi_0    pypi
matplotlib-inline         0.1.6            py37haa95532_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl                       2021.4.0           haa95532_640    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl-service               2.4.0            py37h2bbff1b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_fft                   1.3.1            py37h277e83a_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_random                1.2.2            py37hf11a4ad_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ninja                     1.11.1.1                 pypi_0    pypi
ninja-base                1.10.2               h6d14046_5    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy                     1.21.5           py37h7a0a035_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy-base                1.21.5           py37hca35cd5_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
opencv-python             3.4.10.35                pypi_0    pypi
parso                     0.8.3              pyhd3eb1b0_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pickleshare               0.7.5           pyhd3eb1b0_1003    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pillow                    9.4.0            py37hd77b12b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pip                       22.3.1           py37haa95532_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
prompt-toolkit            3.0.36           py37haa95532_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pycocotools               2.0                      pypi_0    pypi
pygments                  2.11.2             pyhd3eb1b0_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pyparsing                 3.1.2                    pypi_0    pypi
pyquaternion              0.9.9                    pypi_0    pypi
python                    3.7.0                hea74fb7_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
python-dateutil           2.9.0.post0              pypi_0    pypi
pytorch                   1.7.0           py3.7_cuda110_cudnn8_0    pytorch
pyyaml                    6.0.1                    pypi_0    pypi
setuptools                59.6.0                   pypi_0    pypi
six                       1.16.0             pyhd3eb1b0_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tk                        8.6.14               h0416ee5_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
torchaudio                0.7.0                      py37    pytorch
torchvision               0.8.0                py37_cu110    pytorch
traitlets                 5.7.1            py37haa95532_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
typing                    3.10.0.0                 pypi_0    pypi
typing_extensions         4.4.0            py37haa95532_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
vc                        14.2                 h2eaa2aa_4    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
vs2015_runtime            14.29.30133          h43f2093_4    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
wcwidth                   0.2.5              pyhd3eb1b0_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
wheel                     0.38.4           py37haa95532_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
wincertstore              0.2              py37haa95532_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
xz                        5.4.6                h8cc25b3_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
yacs                      0.1.8                    pypi_0    pypi
zlib                      1.2.13               h8cc25b3_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zstd                      1.5.5                hd43e919_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

二.maskrcnn小demo运行

我用的pycharm,直接打开项目maskrcnn_benchmark,环境要设置成刚配置的虚拟环境

Readme里面有一个实时摄像头的小demo可以运行试试

Webcam and Jupyter notebook demo

We provide a simple webcam demo that illustrates how you can use maskrcnn_benchmark for inference:

cd demo

点小绿箭头然后等待下载一个包就可以运行了

相关推荐

  1. jenkins 自动下载 环境依赖包,下载超时

    2024-07-15 02:30:01       39 阅读
  2. M芯片 mac配置Vulkan环境 Xcode

    2024-07-15 02:30:01       33 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-15 02:30:01       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-15 02:30:01       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-15 02:30:01       58 阅读
  4. Python语言-面向对象

    2024-07-15 02:30:01       69 阅读

热门阅读

  1. 昇思第19天

    2024-07-15 02:30:01       20 阅读
  2. MSYS2快速安装和使用

    2024-07-15 02:30:01       22 阅读
  3. 分布式服务基于Zookeeper的分布式锁的实现

    2024-07-15 02:30:01       19 阅读
  4. C++ 入门10:继承和派生类

    2024-07-15 02:30:01       16 阅读
  5. IDC脚本

    IDC脚本

    2024-07-15 02:30:01      18 阅读
  6. 注册sublime text右键打开

    2024-07-15 02:30:01       22 阅读
  7. LC53最大子数组和、lc5最长回文子串、lc283移动零

    2024-07-15 02:30:01       23 阅读
  8. Vue3 defineProps的使用

    2024-07-15 02:30:01       21 阅读