Compilation Issues with CUDA 11.5 and GCC 11 on Ubuntu 22.04 - Need help

Hello, CUDA developers!

I’ve been facing some challenges with compiling my CUDA project that utilizes OpenCV. My development environment consists of CUDA 11.5, GCC 9, and Ubuntu 22.04 LTS. I’m getting a series of errors related to the C++ standard library when trying to compile my .cu file which uses C++17 features.

Here are the key details of my setup:

  • OS: Ubuntu 22.04 LTS
  • Kernel: 5.15
  • GCC: Version 11.4.0 (also tried using GCC 9 with update-alternatives)
  • NVCC: Release 11.5, V11.5.119 (from nvcc --version)
  • OpenCV: Compiled with CUDA support

The specific errors start with issues in the <tuple> header and similar messages from other standard library headers, like <array> and <functional>, indicating something like “argument list for class template is missing”.

I’ve tried the following:

  • Ensuring GCC 9 is set as the default compiler
  • Updating the CUDA Toolkit to the latest version
  • Simplifying my Makefile and ensuring proper flag ordering
  • Isolating CUDA code from C++ standard library code

However, I’m still stuck with the errors during compilation, and they all point towards compatibility issues between NVCC and the GCC 9 standard library headers.

I would really appreciate any advice on resolving these compilation errors. Have any of you encountered something similar or have insights that might assist me?

Here’s the Makefile snippet for reference:

makefile

NVCCFLAGS=-ccbin g++-9 -I/usr/local/include/opencv4 -Xcompiler "-std=c++17"
LDFLAGS=-lcudart -L/usr/local/lib $(shell pkg-config --libs opencv4)
...

And the compilation command that’s causing the issue:

sh

nvcc imageprocessing.cu -o ocr_app $(NVCCFLAGS) $(LDFLAGS)

Thank you in advance for your time and help!

I suggest showing the exact command and exact output. My guess would be that you have an inconsistent gcc setup (e.g. gcc 9 with gcc 11 headers, or similar). It’s also curious that your title refers to gcc 11 but you refer to gcc 9 in the message.

That mixup was because i also tried checking with gcc 9 as i had issues compiling with gcc 11.

Below is my makefile, using gcc 11.

`CC=g+±11
NVCC=nvcc

OPENCV_CFLAGS=$(shell pkg-config --cflags opencv4)
OPENCV_LIBS=$(shell pkg-config --libs opencv4)

CUDA runtime library and C++ standard

LIBS=-lcudart $(OPENCV_LIBS)
CXXFLAGS=-std=c++17
NVCCFLAGS=-ccbin $(CC) $(OPENCV_CFLAGS) -Xcompiler “$(CXXFLAGS)”

LDFLAGS=$(LIBS)

TARGET=app

SRC = imageprocessing.cu

$(TARGET):
$(NVCC) $(SRC) -o $(TARGET) $(NVCCFLAGS) $(LDFLAGS)

clean:
rm -f $(TARGET)
`

headers used in my .cu file:

#include <opencv2/opencv.hpp> #include <opencv2/core/cuda.hpp> #include <iostream>

output when i run make:

`nvcc imageprocessing.cu -o app -ccbin g+±11 -I/usr/local/include/opencv4 -Xcompiler “-std=c++17” -lcudart -L/usr/local/lib -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core
/usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp(235): warning #611-D: overloaded virtual function “cv::detail::PlaneWarper::buildMaps” is only partially overridden in class “cv::detail::AffineWarper”

/usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp(235): warning #611-D: overloaded virtual function “cv::detail::PlaneWarper::warp” is only partially overridden in class “cv::detail::AffineWarper”

/usr/local/include/opencv4/opencv2/stitching/detail/matchers.hpp(182): warning #611-D: overloaded virtual function “cv::detail::FeaturesMatcher::match” is only partially overridden in class “cv::detail::BestOf2NearestMatcher”

/usr/local/include/opencv4/opencv2/stitching/detail/matchers.hpp(236): warning #611-D: overloaded virtual function “cv::detail::FeaturesMatcher::match” is only partially overridden in class “cv::detail::AffineBestOf2NearestMatcher”

/usr/local/include/opencv4/opencv2/stitching/detail/blenders.hpp(100): warning #611-D: overloaded virtual function “cv::detail::Blender::prepare” is only partially overridden in class “cv::detail::FeatherBlender”

/usr/local/include/opencv4/opencv2/stitching/detail/blenders.hpp(127): warning #611-D: overloaded virtual function “cv::detail::Blender::prepare” is only partially overridden in class “cv::detail::MultiBandBlender”

/usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp(235): warning #611-D: overloaded virtual function “cv::detail::PlaneWarper::buildMaps” is only partially overridden in class “cv::detail::AffineWarper”

/usr/local/include/opencv4/opencv2/stitching/detail/warpers.hpp(235): warning #611-D: overloaded virtual function “cv::detail::PlaneWarper::warp” is only partially overridden in class “cv::detail::AffineWarper”

/usr/local/include/opencv4/opencv2/stitching/detail/matchers.hpp(182): warning #611-D: overloaded virtual function “cv::detail::FeaturesMatcher::match” is only partially overridden in class “cv::detail::BestOf2NearestMatcher”

/usr/local/include/opencv4/opencv2/stitching/detail/matchers.hpp(236): warning #611-D: overloaded virtual function “cv::detail::FeaturesMatcher::match” is only partially overridden in class “cv::detail::AffineBestOf2NearestMatcher”

/usr/local/include/opencv4/opencv2/stitching/detail/blenders.hpp(100): warning #611-D: overloaded virtual function “cv::detail::Blender::prepare” is only partially overridden in class “cv::detail::FeatherBlender”

/usr/local/include/opencv4/opencv2/stitching/detail/blenders.hpp(127): warning #611-D: overloaded virtual function “cv::detail::Blender::prepare” is only partially overridden in class “cv::detail::MultiBandBlender”

/usr/include/c++/11/bits/std_function.h:435:145: error: parameter packs not expanded with ‘…’:
435 | function(_Functor&& __f)
| ^
/usr/include/c++/11/bits/std_function.h:435:145: note: ‘_ArgTypes’
/usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘…’:
530 | operator=(_Functor&& __f)
| ^
/usr/include/c++/11/bits/std_function.h:530:146: note: ‘_ArgTypes’
make: *** [makefile:24: app] Error 1`

most of those appear to be OpenCV compilation issues. I won’t be able to help with those, and OpenCV is not a NVIDIA product.

regarding:

This seems to be a similar report. You could try downgrading to gcc 10, upgrading to CUDA 11.6, or one of the other solutions listed there.

1 Like

thanks for the suggestions, i will check them!