相关文章推荐
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am running Arch Linux and trying to build a project in Qt however, Qt spits the following error:

/opt/cuda/include/crt/host_config.h:129: error: #error -- unsupported GNU version! gcc versions later than 7 are not supported!

I have already tried a suggestion from a previous Stack Overflow post found here:

CUDA incompatible with my gcc version

I did not use the exact command as my cuda is located in /opt/cuda/bin/gcc. I did the same command for g++. However, the terminal outputs that these files are already linked. I did confirm this by going to the actual file and looking at it's properties.

Can someone please suggest a solution to my issue?

I have tried installing this package: archlinux.org/packages/community/x86_64/gcc7 but it says its already installed and just overwrites what is there. user3230539 Nov 18, 2018 at 19:19

I managed to do so usung this two lines, this will update the symbolic links of cuda to gcc7

ln -s /usr/bin/gcc-7 /usr/local/cuda/bin/gcc
ln -s /usr/bin/g++-7 /usr/local/cuda/bin/g++
                Note that if you have several cuda installations your cuda folder may be different. In my case it was  ``` sudo ln -s /usr/bin/g++-7 /usr/local/cuda-10.0/bin/g++ sudo ln -s /usr/bin/gcc-7 /usr/local/cuda-10.0/bin/gcc ```
– guillefix
                Feb 18, 2021 at 23:02

The issue comes from cuda-10.0/targets/x86_64-linux/include/crt/host_config.h in the main CUDA-10 directory tree. The target for your architecture was placed in /opt.

Some posts recommend faking the inequality

    if __GNUC__ > 7

to say

    if __GNUC__ > 8

but that is a bad idea. Using

    make 'NVCCFLAGS=-m64 -D__GNUC__=7' -k

is permissible in some trivial cases, but still fundamentally the same bad hack.

You probably have alternates on your system which has constructed symbolic links pointing to the version 8 gnu tool chain files. That's why you get an indication version 7 is already installed.

You can learn how to modify your alternates for just your developer users BUT NOT for root or any system admin accounts. You may want to remember how to switch back and forth between 7 and 8 so you only use 7 when actually needed, since many other things may be tested only with 8.

If that doesn't work for you, you can build gcc-7 from source. The preparatory system admin work includes a dnf install, a build from source, an install of 7.4 gnu compiler, and a set up of paths for CUDA development only. If you have gnu gcc and g++ version 8 installed with the appropriate standard libraries and it works, the version 7 compiler can be installed with relative ease.

Browse and find the nearest mirror listed on https://gcc.gnu.org/mirrors.html and then copy the link location for gcc-7.4.0.tar.xz and place it in the shell variable u like this example.

    u="http://mirrors.concertpass.com/gcc/releases/gcc-7.4.0/gcc-7.4.0.tar.xz"

Then you can do the rest as commands.

    sudo dnf install libmpc-devel
    mkdir -p scratch
    cd scratch
    wget -O - "$u" |tar Jxf -
    cd gcc-7.4.0
    mkdir build
    cd build
    ../configure --prefix=/usr/local/gcc-7
    sudo bash -c "cd \"`pwd`\"; make install"

Then you execute this in the shells and tools you develop with. Do NOT put this in the system login apparatus or in .bashrc or .bash_profile, for the same reason as above. Other things may be tested with version 8 only. Instead place them in your development environment where they belong.

    LD_LIBRARY_PATH=/usr/local/gcc-7/lib64:$LD_LIBRARY_PATH
    LD_LIBRARY_PATH=/usr/local/gcc-7/lib:$LD_LIBRARY_PATH
    LD_LIBRARY_PATH=/usr/local/cuda-10.0/NsightCompute-1.0/host/linux-desktop-glibc_2_11_3-glx-x64/Plugins:$LD_LIBRARY_PATH
    LD_LIBRARY_PATH=/usr/local/cuda-10.0/NsightCompute-1.0/target/linux-desktop-glibc_2_11_3-glx-x64:$LD_LIBRARY_PATH
    LD_LIBRARY_PATH=/usr/local/cuda-10.0/targets/x86_64-linux/lib/stubs:$LD_LIBRARY_PATH
    PATH=/usr/local/gcc-7/bin:$PATH
    PATH=/usr/local/cuda-10.0/bin:$PATH
    PATH=$HOME/big/cuda.samples/NVIDIA_CUDA-10.0_Samples/bin/x86_64/linux/release:$PATH
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

 
推荐文章