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

Linux build fails with GCC 10.3.0 (compiler bug) #138

Open
f-fusco opened this issue Nov 23, 2021 · 9 comments
Open

Linux build fails with GCC 10.3.0 (compiler bug) #138

f-fusco opened this issue Nov 23, 2021 · 9 comments

Comments

@f-fusco
Copy link

f-fusco commented Nov 23, 2021

Not related to xmrig-cuda per se but it's worth pointing out for people like me that have to go through the error-prone process of building from source.

A workaround is to compile with GCC 9:

cmake -DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9 -DCUDA_TOOLKIT_ROOT_DIR="/usr/lib/cuda" .
cmake --build .

Same issue in another repo: kokkos/kokkos#4334

@Craftit7
Copy link

That didn't work for me though.
Err:-

CMake Error at CMakeLists.txt:2 (project):
  The CMAKE_C_COMPILER:

    gcc-9

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:2 (project):
  The CMAKE_CXX_COMPILER:

    g++-9

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

@f-fusco
Copy link
Author

f-fusco commented Nov 24, 2021

Of course you need to have gcc 9 installed in your system for this to work.
You can also try clang alternatively.

@Spudz76
Copy link
Contributor

Spudz76 commented Nov 24, 2021

@TeamRazen you have to have g++-9 package installed for it to be available...

CUDA Toolkit always has specific compiler requirements, which is the whole reason it's a plugin. So you can use the old garbage CUDA requires for the CUDA parts, while also compiling the main miner with a legitimate current compiler.

CUDA Toolkits before 11.4.1 did not support newer than gcc-9.

You can find the supported maximum gcc version listed in the Installation Guide for Linux within the versioned documentation of each release. That is how I just went back and found where the docs said gcc-9 and then at 11.4.1 it jumps ahead to gcc-11. If you are using an older CUDA due to an older GPU family (Fermi/Kepler) being unsupported in newer toolkits then you are limited by what the maximum compiler was "back then". CUDA 8.0GA2 requires gcc-5 for example.

@Craftit7
Copy link

Craftit7 commented Nov 24, 2021

Thanks for the help, anyways, I fixed my install with just adding #include <cstddef> to the Algorithms.h

@Spudz76
Copy link
Contributor

Spudz76 commented Nov 24, 2021

That is also pending merge in #120

@DeeDeeRanged
Copy link

DeeDeeRanged commented Sep 22, 2022

I am running Debian testing (bookworm) and is already gcc 12 although I have gcc 9/10/11 also still installed, so I was able to compile with -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
Is this already merged in the dev branch for gcc 11?

Never mind I see #include is already added

@metal3d
Copy link

metal3d commented Jun 7, 2023

For those who have the same problem, there is a solution to install (non-destructive) older versions of tools like GCC.

The solution I use is "Spack".

# install spack in local directory
mkdir -p ~/.local/share
git clone -c feature.manyFiles=true https://github.com/spack/spack.git ~/.local/share/spack

# type this, you can also add this in your bashrc or bashrc.d 
source ~/.local/share/spack/share/spack/setup-env.sh

# now, spack command exists, install gcc@11
# because the build is a bit heavy, change your TMPDIR to not fill your RAM
TMPDIR=/var/tmp spack install gcc@11

# it takes a long time...

# then, when you need to use gcc v11, you can type (session)
spack load gcc@11

# Then build the plugin
git clone git@github.com:xmrig/xmrig-cuda.git
cd xmrig-cuda
mkdir build
cd build
cmake .. && make

This works on Fedora 38.

@xmg333
Copy link

xmg333 commented Dec 9, 2023

Due to the Kepler arch's support are dropped in CUDA 12.x (which is compute_35 I believe), just remove these flags in cmake file. Following is what I did to my /cmake/CUDA.cmake file. And it do work.

set(DEFAULT_CUDA_ARCH "75")

# Fermi GPUs are only supported with CUDA < 9.0
#if (CUDA_VERSION VERSION_LESS 9.0)
        #    list(APPEND DEFAULT_CUDA_ARCH "20;21")
    #endif()
    
# Kepler GPUs are only supported with CUDA < 11.0
#if (CUDA_VERSION VERSION_LESS 11.0)
        #list(APPEND DEFAULT_CUDA_ARCH "30")
    #else()
        #list(APPEND DEFAULT_CUDA_ARCH "35")
    #endif()

# add Pascal support for CUDA >= 8.0
#if (NOT CUDA_VERSION VERSION_LESS 8.0)
#    list(APPEND DEFAULT_CUDA_ARCH "60")
#endif()

# add Volta support for CUDA >= 9.0
#if (NOT CUDA_VERSION VERSION_LESS 9.0)
#    list(APPEND DEFAULT_CUDA_ARCH "70")
#endif()

# add Turing support for CUDA >= 10.0
if (NOT CUDA_VERSION VERSION_LESS 10.0)
    list(APPEND DEFAULT_CUDA_ARCH "75")
endif()

# add Ampere support for CUDA >= 11.0
if (NOT CUDA_VERSION VERSION_LESS 11.0)
    list(APPEND DEFAULT_CUDA_ARCH "80")
endif()
list(SORT DEFAULT_CUDA_ARCH)

BTW, I'm using fedora39, and it has gcc13 by default which is not supported by nvcc. I added set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}" -allow-unsupported-compiler) in the same file to by pass the error.

@yhilgjff
Copy link

For those who have the same problem, there is a solution to install (non-destructive) older versions of tools like GCC.

The solution I use is "Spack".

# install spack in local directory
mkdir -p ~/.local/share
git clone -c feature.manyFiles=true https://github.com/spack/spack.git ~/.local/share/spack

# type this, you can also add this in your bashrc or bashrc.d 
source ~/.local/share/spack/share/spack/setup-env.sh

# now, spack command exists, install gcc@11
# because the build is a bit heavy, change your TMPDIR to not fill your RAM
TMPDIR=/var/tmp spack install gcc@11

# it takes a long time...

# then, when you need to use gcc v11, you can type (session)
spack load gcc@11

# Then build the plugin
git clone git@github.com:xmrig/xmrig-cuda.git
cd xmrig-cuda
mkdir build
cd build
cmake .. && make

This works on Fedora 38.

After following all of this, it ended up not working with debian bookworm. Rest is in xmrig/xmrig-nvidia#348

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

7 participants