Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: parameter packs not expanded with ‘...’ #2

Open
gengdy1545 opened this issue Feb 27, 2024 · 2 comments
Open

error: parameter packs not expanded with ‘...’ #2

gengdy1545 opened this issue Feb 27, 2024 · 2 comments

Comments

@gengdy1545
Copy link

gengdy1545 commented Feb 27, 2024

cuda version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:45:30_PST_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0

g++ version

g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

When I run make in CapelliniSpTRSV/CUDA/SyncFree_csc, I encountered the following problem

nvcc -O3 -w -m64 -Xptxas -dlcm=cg -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_61,code=compute_61 main.cu -o main -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -lcusparse -lcudart
/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:3: main] Error 1

My solution is as follows:

  1. install gcc-10.5.0 (Not tried 10.1/2/3/4 yet)
a) download source code gcc-10.5.0 (https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-10.5.0/)
b) tar -xvf gcc-10.5.0.tar.gz
c) Enter the gcc-10.5.0 directory and execute ./contrib/download_prerequisites 
d) Create a directory in a parallel location, such as gcc10
e) Enter the newly created gcc10 directory and execute ../gcc-10.5.0/configure --prefix=/home/username/.local --enable-checking=release --enable-languages=c,c++ --disable-multilib. prefix set as local for your own user or anywhere you want.
f) Make && make install in the gcc10 directory. Finally, the new version of gcc is installed in /home/username/.local/bin, which is the subdirectory bin under the prefix set previously. (You can use the -j option of the make command, followed by the number of threads you want to use, to achieve multi-threaded compilation.)
  1. write CMakeLists.txt (Remember to modify the gcc path, like /home/username/.local/bin/g++)
cmake_minimum_required(VERSION  3.10)
project(MyCudaProject)

set(CMAKE_CUDA_HOST_COMPILER gcc-10.5.0_path)

enable_language(CUDA)

set(CMAKE_CUDA_FLAGS "-O3 -w -m64 -Xptxas -dlcm=cg -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_61,code=compute_61")

link_directories(/usr/local/cuda/lib64)

include_directories(/usr/local/cuda/include)

add_executable(main main.cu)

target_link_libraries(main cusparse cudart)
  1. cmake
mkdir build
cd build
cmake ..
make

warning: Since we set prefix to ~/.local, it may be used as the default environment variable in the user's .profile file, so if you do not want the locally compiled gcc to affect the global environment, please comment out this in the .profile file part

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi
@panjd123
Copy link

panjd123 commented Mar 10, 2024

If you can modify the C++ header file, a simple solution is to comment out the following two "noexcept" lines in the /usr/include/c++/11/bits/std_function.h file.

Line 433+ (approximate):

  template<typename _Functor,
           typename _Constraints = _Requires<_Callable<_Functor>>>
    function(_Functor&& __f)
    //noexcept(_Handler<_Functor>::template _S_nothrow_init<_Functor>()) // CUDA BOTCHES THIS
    : _Function_base()

Line 529+ (approximate):

  template<typename _Functor>
    _Requires<_Callable<_Functor>, function&>
    operator=(_Functor&& __f)
    //noexcept(_Handler<_Functor>::template _S_nothrow_init<_Functor>()) // CUDA BOTCHES THIS
    {
      function(std::forward<_Functor>(__f)).swap(*this);
      return *this;
    }

Clearly, this typically only affects compiler optimization, but indeed, it can resolve the issue.

ref: NVIDIA/nccl#650 (comment)


In my experience, consolidating an entire project with CUDA into a single .cu file for compilation is not advisable. I have encountered numerous similar issues, and the handling of C++ code by nvcc is not as proficient as that of compilers like g++. It is better to split the code into multiple .cpp and .cu files, and then perform the linking. This approach proves to be a better choice as it helps avoid the majority of such situations.

@gengdy1545
Copy link
Author

If you have root privileges, modifying /usr/include is obviously not a good idea. I'd rather use update-alternatives

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants