pytorch / vision

Datasets, Transforms and Models specific to Computer Vision
https://pytorch.org/vision
BSD 3-Clause "New" or "Revised" License
16.2k stars 6.95k forks source link

torchvision c++ api build from source, Build error about C++14 and C++11 #2470

Closed weijian-sun closed 4 years ago

weijian-sun commented 4 years ago

torchvision c++ api build from source, in master branch, Build error about C++14 and C++11

Environment

PyTorch Version: 1.5.1 build from source OS (e.g., Linux): Ubuntu 16 How you installed PyTorch (conda, pip, source): source Build command you used (if compiling from source):

!/bin/bash

WORKSPACE=$(cd $(dirname $0);pwd) export PATH=/opt/protobuf/bin:$PATH mkdir build cd build /opt/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=${WORKSPACE}/output \ -DCMAKE_PREFIX_PATH=/opt/had_deps/libtorch1.5 -DWITH_CUDA=ON .. make -jgetconf _NPROCESSORS_CONF install Python version: 3.5 CUDA/cuDNN version: 10.0

error message:

-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") -- Caffe2: Found protobuf with new-style protobuf targets. -- Caffe2: Protobuf version 3.3.0 -- Found CUDA: /usr/local/cuda (found version "10.0") -- Caffe2: CUDA detected: 10.0 -- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc -- Caffe2: CUDA toolkit directory: /usr/local/cuda -- Caffe2: Header version is: 10.0 -- Found CUDNN: /usr/lib/x86_64-linux-gnu/libcudnn.so -- Found cuDNN: v7.5.0 (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libcudnn.so) -- Autodetected CUDA architecture(s): 7.5 -- Added CUDA NVCC flags for: -gencode;arch=compute_75,code=sm_75 -- Found torch: /opt/had_deps/libtorch1.5/lib/libtorch.so -- Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found version "1.2.54") -- Found JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (found version "80") -- Configuring done -- Generating done -- Build files have been written to: /home/administrator/workspace/vision/build Scanning dependencies of target torchvision [ 3%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/alexnet.cpp.o [ 7%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/densenet.cpp.o [ 10%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/googlenet.cpp.o [ 14%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/inception.cpp.o [ 17%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/mnasnet.cpp.o [ 21%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/mobilenet.cpp.o [ 25%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/resnet.cpp.o [ 28%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/shufflenetv2.cpp.o [ 32%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/squeezenet.cpp.o [ 35%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/vgg.cpp.o [ 39%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/PSROIAlign_cpu.cpp.o [ 42%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/DeformConv_cpu.cpp.o [ 46%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/PSROIPool_cpu.cpp.o [ 50%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/ROIAlign_cpu.cpp.o [ 53%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/ROIPool_cpu.cpp.o [ 57%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/image/image.cpp.o [ 60%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/image/readjpeg_cpu.cpp.o [ 64%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/image/readpng_cpu.cpp.o [ 67%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/nms_cpu.cpp.o [ 71%] Building CUDA object CMakeFiles/torchvision.dir/torchvision/csrc/cuda/DeformConv_cuda.cu.o In file included from /usr/include/c++/5/initializer_list:36:0, from /opt/had_deps/libtorch1.5/include/c10/util/SmallVector.h:31, from /opt/had_deps/libtorch1.5/include/c10/util/ArrayRef.h:18, from /opt/had_deps/libtorch1.5/include/c10/core/MemoryFormat.h:5, from /opt/had_deps/libtorch1.5/include/ATen/core/TensorBody.h:5, from /opt/had_deps/libtorch1.5/include/ATen/Tensor.h:11, from /opt/had_deps/libtorch1.5/include/ATen/Context.h:4, from /opt/had_deps/libtorch1.5/include/ATen/ATen.h:5, from /home/administrator/workspace/vision/torchvision/csrc/cuda/DeformConv_cuda.cu:69: /usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

error This file requires compiler and library support \

^ In file included from /opt/had_deps/libtorch1.5/include/c10/util/ArrayRef.h:19:0, from /opt/had_deps/libtorch1.5/include/c10/core/MemoryFormat.h:5, from /opt/had_deps/libtorch1.5/include/ATen/core/TensorBody.h:5, from /opt/had_deps/libtorch1.5/include/ATen/Tensor.h:11, from /opt/had_deps/libtorch1.5/include/ATen/Context.h:4, from /opt/had_deps/libtorch1.5/include/ATen/ATen.h:5, from /home/administrator/workspace/vision/torchvision/csrc/cuda/DeformConv_cuda.cu:69: /opt/had_deps/libtorch1.5/include/c10/util/C++17.h:24:2: error: #error You need C++14 to compile PyTorch

error You need C++14 to compile PyTorch

pmeier commented 4 years ago

Hi @weijian-sun,

I'm out of my depth for the build process, we'll have to wait for someone else. Still, I noticed one thing while skimming the output: In Environment you stated you have CUDA 10.2, but the build -- Found CUDA: /usr/local/cuda (found version "10.0").

weijian-sun commented 4 years ago

Hi @weijian-sun,

I'm out of my depth for the build process, we'll have to wait for someone else. Still, I noticed one thing while skimming the output: In Environment you stated you have CUDA 10.2, but the build -- Found CUDA: /usr/local/cuda (found version "10.0").

oh, sorry for the typo, it's cuda 10.0, and the driver version is 440.33.01

deweyamer commented 4 years ago

did u solved this problem?

weijian-sun commented 4 years ago

switch to a clean docker image, proglem solved, maybe some environment related issue

deweyamer commented 4 years ago

sorry, do u means use docker to download the vision?

fmassa commented 4 years ago

@Dewey1994 if you are compiling torchvision from source, you need a compiler that supports C++14