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

cmake torchvision出现的问题 #2565

Open ts19970816 opened 4 years ago

ts19970816 commented 4 years ago

/home/ts/Downloads/vision-master/torchvision/csrc/ROIAlign.h: In function ‘at::Tensor roi_align(const at::Tensor&, const at::Tensor&, double, int64_t, int64_t, int64_t, bool)’: /home/ts/Downloads/vision-master/torchvision/csrc/ROIAlign.h:29:25: error: ‘class c10::OperatorHandle’ has no member named ‘typed’ .typed<decltype(roi_align)>(); ^~~~~ /home/ts/Downloads/vision-master/torchvision/csrc/ROIAlign.h:29:31: error: expected primary-expression before ‘decltype’ .typed<decltype(roi_align)>(); ^~~~ /home/ts/Downloads/vision-master/torchvision/csrc/ROIAlign.h: In function ‘at::Tensor _roi_align_backward(const at::Tensor&, const at::Tensor&, double, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, bool)’: /home/ts/Downloads/vision-master/torchvision/csrc/ROIAlign.h:77:12: error: ‘class c10::OperatorHandle’ has no member named ‘typed’ .typed<decltype(_roi_align_backward)>(); ^~~~~ /home/ts/Downloads/vision-master/torchvision/csrc/ROIAlign.h:77:18: error: expected primary-expression before ‘decltype’ .typed<decltype(_roi_align_backward)>(); ^~~~ In file included from /home/ts/Downloads/vision-master/torchvision/csrc/vision.cpp:17:0: /home/ts/Downloads/vision-master/torchvision/csrc/nms.h: In function ‘at::Tensor nms(const at::Tensor&, const at::Tensor&, double)’: /home/ts/Downloads/vision-master/torchvision/csrc/nms.h:19:25: error: ‘class c10::OperatorHandle’ has no member named ‘typed’ .typed<decltype(nms)>(); ^~~~~ /home/ts/Downloads/vision-master/torchvision/csrc/nms.h:19:31: error: expected primary-expression before ‘decltype’ .typed<decltype(nms)>(); ^~~~ /home/ts/Downloads/vision-master/torchvision/csrc/vision.cpp: At global scope: /home/ts/Downloads/vision-master/torchvision/csrc/vision.cpp:45:14: error: expected constructor, destructor, or type conversion before ‘(’ token TORCH_LIBRARY(torchvision, m) { ^ /home/ts/Downloads/vision-master/torchvision/csrc/vision.cpp:59:19: error: expected constructor, destructor, or type conversion before ‘(’ token TORCH_LIBRARY_IMPL(torchvision, CPU, m) { ^ /home/ts/Downloads/vision-master/torchvision/csrc/vision.cpp:82:19: error: expected constructor, destructor, or type conversion before ‘(’ token TORCH_LIBRARY_IMPL(torchvision, Autograd, m) { ^ CMakeFiles/torchvision.dir/build.make:518: recipe for target 'CMakeFiles/torchvision.dir/torchvision/csrc/vision.cpp.o' failed make[2]: [CMakeFiles/torchvision.dir/torchvision/csrc/vision.cpp.o] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/torchvision.dir/all' failed make[1]: [CMakeFiles/torchvision.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2

pmeier commented 4 years ago

Hey @ts19970816 could you add a little context about you environment? For example you can download and run our environment collection script and post the output here.

ts19970816 commented 4 years ago

pytorch1.5.0 torchvision0.6.0 python3.6.5 cuda10.2 cudnn7.6.5 g++ 7.5

pmeier commented 4 years ago
  1. What platform (Linux, macOS) and which version are you operating on?
  2. Your error message suggests that you are building from the master branch while in your last comment you said torchvision==0.6.0. Which one is correct?
ts19970816 commented 4 years ago

linux master 在哪里下载torchvision=0.6.0

pmeier commented 4 years ago

Sorry, but I don't speak Chinese, so I'm relying on Google Translator here. Do you have a reason to install from source or could you simply install the pre-compiled binaries? If source is not required you could run

pip install torch==1.5.0 torchvision==0.6.0 -f https://download.pytorch.org/whl/torch_stable.html
ts19970816 commented 4 years ago

thanks,pip install torch-1.5.0-cp36-cp36m-linux_x86_64.whl pip install torchvision-0.6.0-cp36-cp36m-linux_x86_64.whl 这是我的安装方式

pmeier commented 4 years ago

Does this mean, that your problem is resolved or are still facing difficulties of any kind?

ts19970816 commented 4 years ago

没有解决,我还是面临这 1.git clone https://github.com/pytorch/vision.git 2 cd vision 3 mkdir build && cd build 4 cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch -DCMAKE_INSTALL_PREFIX=/where/to/install/torchvision -DCMAKE_BUILD_TYPE=Release .. 5.make 在进行第5步的时候make时候出现错误 ts@ts:~/opt/vision-master/build$ make [ 4%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/vision.cpp.o In file included from /home/ts/opt/vision-master/torchvision/csrc/vision.cpp:14:0: /home/ts/opt/vision-master/torchvision/csrc/ROIAlign.h: In function ‘at::Tensor roi_align(const at::Tensor&, const at::Tensor&, double, int64_t, int64_t, int64_t, bool)’: /home/ts/opt/vision-master/torchvision/csrc/ROIAlign.h:29:25: error: ‘class c10::OperatorHandle’ has no member named ‘typed’ .typed<decltype(roi_align)>(); ^~~~~ /home/ts/opt/vision-master/torchvision/csrc/ROIAlign.h:29:31: error: expected primary-expression before ‘decltype’ .typed<decltype(roi_align)>(); ^~~~ /home/ts/opt/vision-master/torchvision/csrc/ROIAlign.h: In function ‘at::Tensor _roi_align_backward(const at::Tensor&, const at::Tensor&, double, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, bool)’: /home/ts/opt/vision-master/torchvision/csrc/ROIAlign.h:77:12: error: ‘class c10::OperatorHandle’ has no member named ‘typed’ .typed<decltype(_roi_align_backward)>(); ^~~~~ /home/ts/opt/vision-master/torchvision/csrc/ROIAlign.h:77:18: error: expected primary-expression before ‘decltype’ .typed<decltype(_roi_align_backward)>(); ^~~~ In file included from /home/ts/opt/vision-master/torchvision/csrc/vision.cpp:17:0: /home/ts/opt/vision-master/torchvision/csrc/nms.h: In function ‘at::Tensor nms(const at::Tensor&, const at::Tensor&, double)’: /home/ts/opt/vision-master/torchvision/csrc/nms.h:19:25: error: ‘class c10::OperatorHandle’ has no member named ‘typed’ .typed<decltype(nms)>(); ^~~~~ /home/ts/opt/vision-master/torchvision/csrc/nms.h:19:31: error: expected primary-expression before ‘decltype’ .typed<decltype(nms)>(); ^~~~ /home/ts/opt/vision-master/torchvision/csrc/vision.cpp: At global scope: /home/ts/opt/vision-master/torchvision/csrc/vision.cpp:45:14: error: expected constructor, destructor, or type conversion before ‘(’ token TORCH_LIBRARY(torchvision, m) { ^ /home/ts/opt/vision-master/torchvision/csrc/vision.cpp:59:19: error: expected constructor, destructor, or type conversion before ‘(’ token TORCH_LIBRARY_IMPL(torchvision, CPU, m) { ^ /home/ts/opt/vision-master/torchvision/csrc/vision.cpp:82:19: error: expected constructor, destructor, or type conversion before ‘(’ token TORCH_LIBRARY_IMPL(torchvision, Autograd, m) { ^ CMakeFiles/torchvision.dir/build.make:518: recipe for target 'CMakeFiles/torchvision.dir/torchvision/csrc/vision.cpp.o' failed make[2]: [CMakeFiles/torchvision.dir/torchvision/csrc/vision.cpp.o] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/torchvision.dir/all' failed make[1]: [CMakeFiles/torchvision.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2

pmeier commented 4 years ago

@ts19970816 You need to clarify what you want to do:

ts19970816 commented 4 years ago

-- Caffe2: CUDA detected: 10.2 -- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc -- Caffe2: CUDA toolkit directory: /usr/local/cuda -- Caffe2: Header version is: 10.2 -- Found cuDNN: v7.6.5 (include: /usr/local/cuda/include, library: /usr/local/cuda/lib64/libcudnn.so) -- Autodetected CUDA architecture(s): 6.1 -- Added CUDA NVCC flags for: -gencode;arch=compute_61,code=sm_61 CMake Error at CMakeLists.txt:7 (find_package): By not providing "FindTorchVision.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "TorchVision", but CMake did not find one.

Could not find a package configuration file provided by "TorchVision" with any of the following names:

TorchVisionConfig.cmake
torchvision-config.cmake

Add the installation prefix of "TorchVision" to CMAKE_PREFIX_PATH or set "TorchVision_DIR" to a directory containing one of the above files. If "TorchVision" provides a separate development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred! See also "/home/ts/examples/build/CMakeFiles/CMakeOutput.log". See also "/home/ts/examples/build/CMakeFiles/CMakeError.log". 我报这种错误,是不是需要源码安装torchvision

ts19970816 commented 4 years ago

但是我在源码编译安装之前,已经通过pip install torchvision-0.6.0-cp36-cp36m-linux_x86_64.whl这种方式安装过了torchvision

fmassa commented 4 years ago

Hi,

It's very difficult for someone like @pmeier or myself who doesn't speak chinese to understand what you want to achieve.

Do you want to use the C++ API, or just the Python bindings? If it's just the Python bindings, you can install via setup.py.

If you want to use the C++ API, what exactly do you want to do, use an operator in C++, run one of the example models, or something else?

One of the errors you got seemed to be indicating that either you were not using a compatible PyTorch version, or you were not compiling with C++14.

zhangguanheng66 commented 4 years ago

但是我在源码编译安装之前,已经通过pip install torchvision-0.6.0-cp36-cp36m-linux_x86_64.whl这种方式安装过了torchvision

@ts19970816 Could you ask questions in English? For this question, I can translate: Before installed from source code, I have installed torchvision with pip.

ZhaoyangLi-nju commented 4 years ago

I got the same error,when I install c++ API in torchvision, as follows: (py36) root@d48e90e40b2b:/workspace/vision/build# cmake --build . -j 20 Scanning dependencies of target torchvision [ 4%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/alexnet.cpp.o [ 9%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/densenet.cpp.o [ 14%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/googlenet.cpp.o [ 19%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/inception.cpp.o [ 23%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/resnet.cpp.o [ 28%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/mnasnet.cpp.o [ 33%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/squeezenet.cpp.o [ 38%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/shufflenetv2.cpp.o [ 42%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/mobilenet.cpp.o [ 47%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/models/vgg.cpp.o [ 52%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/PSROIAlign_cpu.cpp.o [ 57%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/PSROIPool_cpu.cpp.o [ 61%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/DeformConv_cpu.cpp.o [ 66%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/ROIPool_cpu.cpp.o [ 71%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/ROIAlign_cpu.cpp.o [ 76%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/nms_cpu.cpp.o [ 80%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/image/readpng_cpu.cpp.o [ 85%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/image/image.cpp.o [ 90%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/vision.cpp.o [ 95%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/image/readjpeg_cpu.cpp.o In file included from /workspace/vision/torchvision/csrc/vision.cpp:14:0: /workspace/vision/torchvision/csrc/ROIAlign.h: In function 'at::Tensor roi_align(const at::Tensor&, const at::Tensor&, double, int64_t, int64_t, bool)': /workspace/vision/torchvision/csrc/ROIAlign.h:29:25: error: 'class c10::OperatorHandle' has no member named 'typed' .typed<decltype(roi_align)>(); ^~~~~ /workspace/vision/torchvision/csrc/ROIAlign.h:29:31: error: expected primary-expression before 'decltype' .typed<decltype(roi_align)>(); ^~~~ /workspace/vision/torchvision/csrc/ROIAlign.h: In function 'at::Tensor _roi_align_backward(const at::Tensor&, const at::Tensoe, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, bool)': /workspace/vision/torchvision/csrc/ROIAlign.h:77:12: error: 'class c10::OperatorHandle' has no member named 'typed' .typed<decltype(_roi_align_backward)>(); ^~~~~ /workspace/vision/torchvision/csrc/ROIAlign.h:77:18: error: expected primary-expression before 'decltype' .typed<decltype(_roi_align_backward)>(); ^~~~ In file included from /workspace/vision/torchvision/csrc/vision.cpp:17:0: /workspace/vision/torchvision/csrc/nms.h: In function 'at::Tensor nms(const at::Tensor&, const at::Tensor&, double)': /workspace/vision/torchvision/csrc/nms.h:19:25: error: 'class c10::OperatorHandle' has no member named 'typed' .typed<decltype(nms)>(); ^~~~~ /workspace/vision/torchvision/csrc/nms.h:19:31: error: expected primary-expression before 'decltype' .typed<decltype(nms)>(); ^~~~ /workspace/vision/torchvision/csrc/vision.cpp: At global scope: /workspace/vision/torchvision/csrc/vision.cpp:45:14: error: expected constructor, destructor, or type conversion before '(' t TORCH_LIBRARY(torchvision, m) { ^ /workspace/vision/torchvision/csrc/vision.cpp:59:19: error: expected constructor, destructor, or type conversion before '(' t TORCH_LIBRARY_IMPL(torchvision, CPU, m) { ^ /workspace/vision/torchvision/csrc/vision.cpp:82:19: error: expected constructor, destructor, or type conversion before '(' t TORCH_LIBRARY_IMPL(torchvision, Autograd, m) { ^ CMakeFiles/torchvision.dir/build.make:309: recipe for target 'CMakeFiles/torchvision.dir/torchvision/csrc/vision.cpp.o' faile make[2]: [CMakeFiles/torchvision.dir/torchvision/csrc/vision.cpp.o] Error 1 make[2]: Waiting for unfinished jobs.... CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/torchvision.dir/all' failed make[1]: [CMakeFiles/torchvision.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: [all] Error 2

libtorch=1.5.0-

ts19970816 commented 4 years ago

When i cmake -DCMAKE_PREFIX_PATH="/opt/libtorch-cxx11-abi-shared-with-deps-1.5.0/libtorch;/home/ts/opt/torchvision" -DCMAKE_BUILD_TYPE=Release .., I have this problem CMake Warning at CMakeLists.txt:12 (find_package): By not providing "FindPython3.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Python3", but CMake did not find one.

Could not find a package configuration file provided by "Python3" with any of the following names:

Python3Config.cmake
python3-config.cmake

Add the installation prefix of "Python3" to CMAKE_PREFIX_PATH or set "Python3_DIR" to a directory containing one of the above files. If "Python3" provides a separate development package or SDK, be sure it has been installed.

-- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda (found version "10.2") -- Caffe2: CUDA detected: 10.2 -- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc -- Caffe2: CUDA toolkit directory: /usr/local/cuda -- Caffe2: Header version is: 10.2 -- Found CUDNN: /usr/local/cuda/lib64/libcudnn.so
-- Found cuDNN: v7.6.5 (include: /usr/local/cuda/include, library: /usr/local/cuda/lib64/libcudnn.so) -- Autodetected CUDA architecture(s): 6.1 -- Added CUDA NVCC flags for: -gencode;arch=compute_61,code=sm_61 -- Found torch: /opt/libtorch-cxx11-abi-shared-with-deps-1.5.0/libtorch/lib/libtorch.so
-- Configuring done -- Generating done -- Build files have been written to: /home/ts/project/vision/build

bmanga commented 4 years ago

Last error seems to be due to an old cmake version that doesn't have the Python3 module

fmassa commented 4 years ago

@andfoy is working on adding CMake tests to CI in https://github.com/pytorch/vision/pull/2577, which will hopefully make it easier to catch bugs and will give some hints to user on how to use our CMake.