You are not logged in.

#1 2024-10-12 13:46:18

greg19
Member
Registered: 2024-04-05
Posts: 4

[Solved] Can't compile cuda code

I followed the https://wiki.archlinux.org/title/GPGPU#CUDA for installing CUDA, and tried to compile some of samples from https://github.com/nvidia/cuda-samples, as recommended in the wiki article. I can compile and run the 1_Utilities/deviceQuery sample, but trying to compile the 1_Utilities/bandwidthTest results in the following error:

$ make
/opt/cuda/bin/nvcc -ccbin g++ -I../../../Common -m64 --threads 0 --std=c++11 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_89,code=sm_89 -gencode arch=compute_90,code=sm_90 -gencode arch=compute_90,code=compute_90 -o bandwidthTest.o -c bandwidthTest.cu
/usr/include/c++/14.2.1/x86_64-pc-linux-gnu/bits/c++config.h(827): error: user-defined literal operator not found
    typedef __decltype(0.0bf16) __bfloat16_t;
                       ^

/usr/include/c++/14.2.1/type_traits(529): error: type name is not allowed
      : public __bool_constant<__is_array(_Tp)>
                                          ^

/usr/include/c++/14.2.1/type_traits(529): error: identifier "__is_array" is undefined
      : public __bool_constant<__is_array(_Tp)>
                               ^

/usr/include/c++/14.2.1/type_traits(581): error: type name is not allowed
      : public __bool_constant<__is_member_object_pointer(_Tp)>
                                                          ^

/usr/include/c++/14.2.1/type_traits(581): error: identifier "__is_member_object_pointer" is undefined
      : public __bool_constant<__is_member_object_pointer(_Tp)>
                               ^

/usr/include/c++/14.2.1/type_traits(603): error: type name is not allowed
      : public __bool_constant<__is_member_function_pointer(_Tp)>
                                                            ^

/usr/include/c++/14.2.1/type_traits(603): error: identifier "__is_member_function_pointer" is undefined
      : public __bool_constant<__is_member_function_pointer(_Tp)>
                               ^

/usr/include/c++/14.2.1/type_traits(695): error: type name is not allowed
      : public __bool_constant<__is_reference(_Tp)>
                                              ^

/usr/include/c++/14.2.1/type_traits(695): error: identifier "__is_reference" is undefined
      : public __bool_constant<__is_reference(_Tp)>
                               ^

/usr/include/c++/14.2.1/type_traits(731): error: type name is not allowed
      : public __bool_constant<__is_object(_Tp)>
                                           ^

/usr/include/c++/14.2.1/type_traits(731): error: identifier "__is_object" is undefined
      : public __bool_constant<__is_object(_Tp)>
                               ^

/usr/include/c++/14.2.1/type_traits(760): error: type name is not allowed
      : public __bool_constant<__is_member_pointer(_Tp)>
                                                   ^

/usr/include/c++/14.2.1/type_traits(760): error: identifier "__is_member_pointer" is undefined
      : public __bool_constant<__is_member_pointer(_Tp)>
                               ^

/usr/include/c++/14.2.1/bits/utility.h(237): error: __type_pack_element is not a template
      { using type = __type_pack_element<_Np, _Types...>; };
                     ^

/usr/include/c++/14.2.1/type_traits(138): error: class "std::enable_if<<error-constant>, void>" has no member "type"
      using __enable_if_t = typename enable_if<_Cond, _Tp>::type;
                                                            ^
          detected during:
            instantiation of type "std::__enable_if_t<<error-constant>, void>" at line 176
            instantiation of "std::__detail::__or_fn" based on template arguments <std::is_reference<std::allocator<char>>, std::is_function<std::allocator<char>>, std::is_void<std::allocator<char>>, std::__is_array_unknown_bounds<std::allocator<char>>> at line 194
            instantiation of class "std::__or_<_Bn...> [with _Bn=<std::is_reference<std::allocator<char>>, std::is_function<std::allocator<char>>, std::is_void<std::allocator<char>>, std::__is_array_unknown_bounds<std::allocator<char>>>]" at line 1195
            instantiation of class "std::is_nothrow_default_constructible<_Tp> [with _Tp=std::allocator<char>]" at line 528 of /usr/include/c++/14.2.1/bits/basic_string.h
            instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" at line 4248 of /usr/include/c++/14.2.1/bits/basic_string.h

15 errors detected in the compilation of "bandwidthTest.cu".
make: *** [Makefile:341: bandwidthTest.o] Error 255

I have the following packages installed:

$ pacman -Qi nvidia opencl-nvidia cuda
Name            : nvidia
Version         : 560.35.03-12
Description     : NVIDIA drivers for linux
Architecture    : x86_64
URL             : https://www.nvidia.com/
Licenses        : custom
Groups          : None
Provides        : NVIDIA-MODULE
Depends On      : linux  nvidia-utils=560.35.03  libglvnd
Optional Deps   : None
Required By     : python-cuda
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 51,27 MiB
Packager        : Jan Alexander Steffens (heftig) <heftig@archlinux.org>
Build Date      : czw, 10 paź 2024, 22:33:41
Install Date    : pią, 11 paź 2024, 11:16:04
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

Name            : opencl-nvidia
Version         : 560.35.03-5
Description     : OpenCL implemention for NVIDIA
Architecture    : x86_64
URL             : http://www.nvidia.com/
Licenses        : custom
Groups          : None
Provides        : opencl-driver
Depends On      : zlib
Optional Deps   : opencl-headers: headers necessary for OpenCL development
Required By     : cuda
Optional For    : nvidia-utils  ocl-icd
Conflicts With  : None
Replaces        : None
Installed Size  : 28,10 MiB
Packager        : Sven-Hendrik Haase <svenstaro@archlinux.org>
Build Date      : czw, 3 paź 2024, 06:30:41
Install Date    : pią, 11 paź 2024, 16:05:54
Install Reason  : Installed as a dependency for another package
Install Script  : No
Validated By    : Signature

Name            : cuda
Version         : 12.6.1-1
Description     : NVIDIA's GPU programming toolkit
Architecture    : x86_64
URL             : https://developer.nvidia.com/cuda-zone
Licenses        : LicenseRef-NVIDIA-CUDA
Groups          : None
Provides        : cuda-toolkit  cuda-sdk  libcudart.so=12-64  libcublas.so=12-64  libcublas.so=12-64  libcusolver.so=11-64  libcusolver.so=11-64  libcusparse.so=12-64  libcusparse.so=12-64
Depends On      : opencl-nvidia  python  gcc13
Optional Deps   : gdb: for cuda-gdb [installed]
                  glu: required for some profiling tools in CUPTI [installed]
                  nvidia-utils: for NVIDIA drivers (not needed in CDI containers) [installed]
                  rdma-core: for GPUDirect Storage (libcufile_rdma.so)
Required By     : cusparselt  libcutensor  python-cuda  python-cupy-bin
Optional For    : blender  openmp  openmpi  openucx
Conflicts With  : None
Replaces        : cuda-toolkit  cuda-sdk  cuda-static
Installed Size  : 4,72 GiB
Packager        : Jakub Klinkovský <lahwaacz@archlinux.org>
Build Date      : pią, 30 sie 2024, 18:39:20
Install Date    : pią, 11 paź 2024, 16:06:01
Install Reason  : Installed as a dependency for another package
Install Script  : Yes
Validated By    : Signature

Last edited by greg19 (2024-10-12 16:46:34)

Offline

#2 2024-10-12 14:16:54

loqs
Member
Registered: 2014-03-06
Posts: 18,087

Re: [Solved] Can't compile cuda code

What if you try using:

make HOST_COMPILER="$NVCC_CCBIN"

Which should set the host compiler to the older gcc13 using the variable NVCC_CCBIN provided by the cuda package.

Offline

#3 2024-10-12 16:43:37

greg19
Member
Registered: 2024-04-05
Posts: 4

Re: [Solved] Can't compile cuda code

This works, thanks!

Offline

Board footer

Powered by FluxBB