Hey!
I try to make vision with CUDA but I get error during make procedure:
My cuda compilation tools: realease 10.0, V10.0.130
Make error output:
[ 25%] Building CUDA object CMakeFiles/torchvision.dir/torchvision/csrc/cuda/ROIAlign_cuda.cu.o
CMakeFiles/torchvision.dir/build.make:296: recipe for target 'CMakeFiles/torchvision.dir/torchvision/csrc/cuda/PSROIPool_cuda.cu.o' failed
make[2]: * [CMakeFiles/torchvision.dir/torchvision/csrc/cuda/PSROIPool_cuda.cu.o] Error 1
make[2]: Waiting for unfinished jobs....
nvcc fatal : Unknown option 'Wall'
nvcc fatal : Unknown option 'Wall'
nvcc fatal : Unknown option 'Wall'
CMakeFiles/torchvision.dir/build.make:270: recipe for target 'CMakeFiles/torchvision.dir/torchvision/csrc/cuda/DeformConv_cuda.cu.o' failed
make[2]: [CMakeFiles/torchvision.dir/torchvision/csrc/cuda/DeformConv_cuda.cu.o] Error 1
CMakeFiles/torchvision.dir/build.make:322: recipe for target 'CMakeFiles/torchvision.dir/torchvision/csrc/cuda/ROIPool_cuda.cu.o' failed
make[2]: [CMakeFiles/torchvision.dir/torchvision/csrc/cuda/ROIPool_cuda.cu.o] Error 1
CMakeFiles/torchvision.dir/build.make:335: recipe for target 'CMakeFiles/torchvision.dir/torchvision/csrc/cuda/nms_cuda.cu.o' failed
make[2]: [CMakeFiles/torchvision.dir/torchvision/csrc/cuda/nms_cuda.cu.o] Error 1
nvcc fatal : Unknown option 'Wall'
CMakeFiles/torchvision.dir/build.make:283: recipe for target 'CMakeFiles/torchvision.dir/torchvision/csrc/cuda/PSROIAlign_cuda.cu.o' failed
make[2]: [CMakeFiles/torchvision.dir/torchvision/csrc/cuda/PSROIAlign_cuda.cu.o] Error 1
nvcc fatal : Unknown option 'Wall'
CMakeFiles/torchvision.dir/build.make:309: recipe for target 'CMakeFiles/torchvision.dir/torchvision/csrc/cuda/ROIAlign_cuda.cu.o' failed
make[2]: [CMakeFiles/torchvision.dir/torchvision/csrc/cuda/ROIAlign_cuda.cu.o] Error 1
CMakeFiles/Makefile2:75: 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
P.S.
I was able to fix this error after remove "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-write-strings -Wno-unknown-pragmas -Wno-missing-braces -fopenmp" params in flags.make
@two-names I met the same problem, how you solved it?
@bmanga could you have a look?
Hi, @Edwardmark !
I just removed the flags -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-write-strings -Wno-unknown-pragmas -Wno-missing-braces -fopenmp from flags.make
The compiler call itself comes from build.make
/usr/local/cuda-10.0/bin/nvcc $(CUDA_DEFINES) $(CUDA_INCLUDES) $(CUDA_FLAGS) -x cu -c
nvcc does not support these parameters. These flags are passed through COMPILER_OPTIONS, these are flags for the c++ compiler.
@two-names is this something that could be fixed in the CMakeLists of torchvision?
@fmassa I suppose we should set this properties like:
if(WITH_CUDA)
set_property(TARGET torch_cuda PROPERTY INTERFACE_COMPILE_OPTIONS "")
endif()
set_property(TARGET torch_cpu PROPERTY INTERFACE_COMPILE_OPTIONS "")
This works for my app that links to TorchVision:
find_package(TorchVision REQUIRED)
Otherwise, non-supported C++ flags are passed to nvcc!
@two-names Can you send a PR fixing this?
Hi @two-names, where is the flags.make file that you are referring to?
I'm wondering whether the fix should be on the torch side...
Hi @bmanga. File flags.make is generated after the command cmake -DWITH CUDA=on ..
build/CMakeFiles/torchvision.dir/flags.make
Hi @fmassa! Actually I don't know if it's possible to solve the problem by editing torchvision CMakeLists.
@two-names can you give me information about the versions of libtorch, nvcc and gcc?
Actually the output of a fresh cmake generation would be good (make sure you delete CMakeCache.txt)
CMakeCache.txt
cmake-3.15.2
gcc -v: gcc 7.4.0
nvcc release 10.0 V10.0.130
pytorch 1.5.0a0
@bmanga
CMakeLists.txt
Works if you add these lines to the end of the CMakeLists.txt
set_property(TARGET torch_cuda PROPERTY INTERFACE_COMPILE_OPTIONS "")
set_property(TARGET torch_cpu PROPERTY INTERFACE_COMPILE_OPTIONS "")
Did you build pytorch yourself or are you using a nightly build? The latest stable is 1.4.
It seems that the only supported prebuilt versions of cuda are 9.2 and 10.1, but you are using 10.0. I have never tried compiling on anything other than 10.1, so maybe try to switch to cuda 10.1.
@two-names The CMakelists works.
@bmanga Yes, 1.4 is stable, but to use torch::index, we have to build nightly build.
Anyway, thanks for your all patience and enthusiasm.
@Edwardmark Which CMakeLists works? Master's or the one posted by @two-names ?
Happy to help :)
@bmanga tow-names works.
just add these lines to the end of the CMakeLists.txt
set_property(TARGET torch_cuda PROPERTY INTERFACE_COMPILE_OPTIONS "")
set_property(TARGET torch_cpu PROPERTY INTERFACE_COMPILE_OPTIONS "")
That is not a proper fix though. I am not sure where those two targets (torch_cuda and torch_cpu) are coming from. Indeed, if I try to add those two lines at the end of my CMakeLists.txt I get the following error:
CMake Error at CMakeLists.txt:80 (set_property):
set_property could not find TARGET torch_cuda. Perhaps it has not yet been
created.
CMake Error at CMakeLists.txt:81 (set_property):
set_property could not find TARGET torch_cpu. Perhaps it has not yet been
created.
It could be that master pytorch is broken, I would try to open an issue there...
@bmanga I am using https://download.pytorch.org/libtorch/nightly/cu92/libtorch-cxx11-abi-shared-with-deps-latest.zip to build vison. You can have a try. Cmake 3.13.2.
Yep. Confirmed also with 1.6.0.dev20200409+cu101
I will open an issue on pytorch.
Hey @two-names and @Edwardmark, I have opened a pr against pytorch: https://github.com/pytorch/pytorch/pull/36945
Could you let me know if that indeed fixes the problem?
I got the same issue too. Is there a PR yet ?
@aviallon Actually I don't know.
I just removed the flags -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-write-strings -Wno-unknown-pragmas -Wno-missing-braces -fopenmp from flags.make
Most helpful comment
@bmanga tow-names works.
just add these lines to the end of the CMakeLists.txt