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

Fix compilation on Pop!_OS 22.04 LTS CUDA #10835

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mika314
Copy link

@mika314 mika314 commented Dec 15, 2024

Downgrade the C++ version from 17 to 14, and also update the code to remove compilation warnings.

Without that fix the build fails with the following error.

/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’
gmake[2]: *** [ggml/src/ggml-cuda/CMakeFiles/ggml-cuda.dir/build.make:107: ggml/src/ggml-cuda/CMakeFiles/ggml-cuda.dir/argmax.cu.o] Error 1

Make sure to read the contributing guidelines before submitting a PR

Downgrade the C++ version from 17 to 14, and also update the code to remove compilation warnings.
@github-actions github-actions bot added Nvidia GPU Issues specific to Nvidia GPUs ggml changes relating to the ggml tensor library for machine learning labels Dec 15, 2024
@max-krasnyansky
Copy link
Collaborator

Making C++ standard conditional on some backend is not a good idea.
We recently decided to go C++17 by default.

PopOS is based on Ubuntu.
Why don't you just get new llvm-18 or -19 stack installed and build with llvm/clang.

wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18

Then build llama.cpp with

CC=clang-18 CXX=clang++-18 cmake ...

@mika314
Copy link
Author

mika314 commented Dec 16, 2024

I did not know I can build it with clang. Clang should work with C++17 no problem. I'll try to rebuild it with clang.

Before I try, one question. I suspect the problem might be with CUDA because it is failing to build .cu file?

@mika314
Copy link
Author

mika314 commented Dec 16, 2024

I played around with nvcc a bit and reprod the issue.

#include <iostream>
#include <functional>

__global__ void hello() {
    if constexpr (true) {
        printf("C++17 is supported!\n");
    }
}

int main() {
    hello<<<1, 1>>>();
    cudaDeviceSynchronize();
    return 0;
}

$ nvcc -std=c++17 -o main main.cu
/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’

I suspect using clang would not help. I need to upgrade nvcc.

$ nvcc --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

Maybe there is a way build nvcc on C++14 and rest on C++17. I am not expert in cmake.

@max-krasnyansky
Copy link
Collaborator

Ah. Yeah, sorry, my bad. You need newer CUDA toolkit. CUDA 12 should work (it does on Ubuntu 24.04).
https://toranbillups.com/blog/archive/2023/08/19/install-cuda-12-on-popos/

Technically you can explicitly specify the host compiler to use (NVCC_PREPEND_FLAGS) but it seems to be picky about the specific compiler versions it supports.

@mika314
Copy link
Author

mika314 commented Dec 19, 2024

Thanks for the suggestion. I'll try to update to CUDA 12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ggml changes relating to the ggml tensor library for machine learning Nvidia GPU Issues specific to Nvidia GPUs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants