本文主要是介绍facebook的maskrcnn-benchmark安装出现command '/usr/local/cuda/bin/nvcc' failed with exit status 1,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1. 问题
在安装maskrcnn-benchmark的时候,需要安装apex,但是一直报错。
问题已经解决了,问题没有备份,这是copy的其他人的。
相似问题:Error “void *” is incompatible with parameter of type "long long *
torch.__version__ = 1.2.0
setup.py:43: UserWarning: Option --pyprof not specified. Not installing PyProf dependencies!warnings.warn("Option --pyprof not specified. Not installing PyProf dependencies!")Compiling cuda extensions with
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Tue_Jun_12_23:07:04_CDT_2018
Cuda compilation tools, release 9.2, V9.2.148
from /usr/local/cuda/binrunning install
running bdist_egg
running egg_info
writing apex.egg-info/PKG-INFO
writing dependency_links to apex.egg-info/dependency_links.txt
writing top-level names to apex.egg-info/top_level.txt
reading manifest file 'apex.egg-info/SOURCES.txt'
writing manifest file 'apex.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
building 'amp_C' extension
/home/john/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -fPIC -I/home/john/anaconda3/lib/python3.7/site-packages/torch/include -I/home/john/anaconda3/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/john/anaconda3/lib/python3.7/site-packages/torch/include/TH -I/home/john/anaconda3/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/john/anaconda3/include/python3.7m -c csrc/amp_C_frontend.cpp -o build/temp.linux-x86_64-3.7/csrc/amp_C_frontend.o -O3 -DVERSION_GE_1_1 -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=amp_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
/usr/local/cuda/bin/nvcc -I/home/john/anaconda3/lib/python3.7/site-packages/torch/include -I/home/john/anaconda3/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/john/anaconda3/lib/python3.7/site-packages/torch/include/TH -I/home/john/anaconda3/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/john/anaconda3/include/python3.7m -c csrc/multi_tensor_sgd_kernel.cu -o build/temp.linux-x86_64-3.7/csrc/multi_tensor_sgd_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options '-fPIC' -lineinfo -O3 --use_fast_math -DVERSION_GE_1_1 -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=amp_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512fintrin.h(9220): error: argument of type "const void *" is incompatible with parameter of type "const float *"/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512fintrin.h(9231): error: argument of type "const void *" is incompatible with parameter of type "const float *"/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512fintrin.h(9244): error: argument of type "const void *" is incompatible with parameter of type "const double *"/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512fintrin.h(9255): error: argument of type "const void *" is incompatible with parameter of type "const double *"
2. 官方安装步骤
# first, make sure that your conda is setup properly with the right environment
# for that, check that `which conda`, `which pip` and `which python` points to the
# right path. From a clean conda env, this is what you need to doconda create --name maskrcnn_benchmark -y
conda activate maskrcnn_benchmark# this installs the right pip and dependencies for the fresh python
conda install ipython pip# maskrcnn_benchmark and coco api dependencies
pip install ninja yacs cython matplotlib tqdm opencv-python# follow PyTorch installation in https://pytorch.org/get-started/locally/
# we give the instructions for CUDA 9.0
conda install -c pytorch pytorch-nightly torchvision cudatoolkit=9.0export 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 apex
cd $INSTALL_DIR
git clone https://github.com/NVIDIA/apex.git
cd apex
python setup.py install --cuda_ext --cpp_ext# install PyTorch Detection
cd $INSTALL_DIR
git clone https://github.com/facebookresearch/maskrcnn-benchmark.git
cd maskrcnn-benchmark# the following will install the lib with
# symbolic links, so that you can modify
# the files if you want and won't need to
# re-build it
python setup.py build developunset INSTALL_DIR# or if you are on macOS
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build develop
3. 解决方案
将gcc版本换为5.4之后就可以通过了。ubuntu如何安装gcc5.4可参考:
ubuntu16.04安装gcc5.4
4. 测试
在maskrcnn-benchmark/demo下新建一个py文件,copy如下测试代码:
from maskrcnn_benchmark.config import cfg
from predictor import COCODemo
import cv2
import matplotlib.pyplot as plt
from PIL import Image
import requests
from io import BytesIO
import numpy as np config_file = "./configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml"# update the config options with the config file
cfg.merge_from_file(config_file)
# manual override some options
cfg.merge_from_list(["MODEL.DEVICE", "cpu"])coco_demo = COCODemo(cfg,min_image_size=800,confidence_threshold=0.7,
)
# load image and then run prediction
def load(url):"""Given an url of an image, downloads the image andreturns a PIL image"""response = requests.get(url)pil_image = Image.open(BytesIO(response.content)).convert("RGB")# convert to BGR formatimage = np.array(pil_image)[:, :, [2, 1, 0]]return imagedef imshow(img):plt.imshow(img[:, :, [2, 1, 0]])plt.axis("off")plt.show()image = load("http://farm3.staticflickr.com/2469/3915380994_2e611b1779_z.jpg")
imshow(image)
predictions = coco_demo.run_on_opencv_image(image)
imshow(predictions)
这篇关于facebook的maskrcnn-benchmark安装出现command '/usr/local/cuda/bin/nvcc' failed with exit status 1的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!