LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Nvidia CUDA req gcc7 but -current provides gcc8 (https://www.linuxquestions.org/questions/slackware-14/nvidia-cuda-req-gcc7-but-current-provides-gcc8-4175644012/)

eduardr 12-10-2018 11:28 AM

Nvidia CUDA req gcc7 but -current provides gcc8
 
I ran into a compilation issue with a tool that uses cuda and problem appears to be that cuda only supports up to gcc7. I modified the cuda source file that implements that restriction but later ran into other build issues that could also be due to gcc8.

I've found some info on running two different versions of gcc side-by-side. I'm unable to download the gcc7 Slackbuilds though, because -current has moved to gcc8. I'm not aware of any repo/archive that stores older versions/snapshots of the -current tree.

I'll probably try to use the gcc8 Slackbuilds with gcc7 source and hopefully that will work.

Thanks in advance for any other suggestions!

orbea 12-10-2018 11:54 AM

Complain to NVIDIA is my suggestion.

eduardr 12-10-2018 11:57 AM

They pick up my calls!
 
Quote:

Originally Posted by orbea (Post 5935558)
Complain to NVIDIA is my suggestion.

Fair point but not going to help - they're historically always behind on gcc support. The only thing that would help is if I were to buy a few thousand of their now unneeded coin mining cards - maybe then they'd listen.

Didier Spaier 12-10-2018 12:32 PM

Be happy. I am stuck with webkit2gtk-2.20.5 for Slint-14.2.1.2 based on Slackware-14.2, because more recent versions need GCC6. It's hard to please everybody...

As an aside this could be a concern as that prevents to benefit of further security fixes. But as long as we ship it only as a (private) dependency of yelp and not of a web browser that's OK, I think.

RadicalDreamer 12-10-2018 02:38 PM

Quote:

Originally Posted by eduardr (Post 5935553)
I'll probably try to use the gcc8 Slackbuilds with gcc7 source and hopefully that will work.

That would be a good start. The program you want to use may have an official binary that has working CUDA built in. For example, Blender's binary has working CUDA.

dugan 12-10-2018 02:56 PM

Can you use clang?

eduardr 12-10-2018 07:21 PM

Thanks for the suggestions.

In the end I did a search for the older gcc 7.3.0 build 3 binary packages and found two sites that store older versions (I neither guarantee nor endorse them but it worked for me :) ).

http://slackmirror.cbpf.br/pub/slackware/
http://ftp.pieskovisko.sk/slackware/

Downloaded and downgraded to these older packages:

gcc-7.3.0-x86_64-3.txz
gcc-brig-7.3.0-x86_64-3.txz
gcc-g++-7.3.0-x86_64-3.txz
gcc-gfortran-7.3.0-x86_64-3.txz
gcc-gnat-7.3.0-x86_64-3.txz
gcc-go-7.3.0-x86_64-3.txz
gcc-objc-7.3.0-x86_64-3.txz

Things seem to work fine for me now as far as the things I need to compile that don't work with gcc8.

After I'm done compiling, I may upgrade back to the gcc 8 packages.

cgorac 12-11-2018 12:08 PM

It may be easier for you to just install GCC 7.3 from source. After downloading the source tarball, there is a script in-there to download prerequisites, and then I build it from source using following commands:
Code:

./configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu \           
    --target=x86_64-linux-gnu --prefix=/opt/gcc-7.3 \               
    --enable-checking=release --enable-languages=c,c++,fortran \   
    --disable-multilib --program-suffix=-7.3

Then you need to point to this version of GCC when compiling CUDA code. For example, if your project is using CMake, then following commands, before CMake run, will do:
Code:

CC=/opt/gcc-7.3/bin/gcc-7.3
CXX=/opt/gcc-7.3/bin/g++-7.3
CUDAHOSTCXX=$CXX
export CC CXX CUDAHOSTCXX

Note that you need to specifically tell CUDA to use this version of GCC as its so-called host compiler (the CUDAHOSTCXX line).

The advantage of this approach is that this way you don't mess with your system-wide GCC installation - you have parallel GCC 7 installation, that you could use only when needed.

NVIDIA is indeed usually slow to enable latest GCC version. Previously, it was typically enough just to comment out corresponding #ifdef in specific CUDA header file to make it possible to use latest version of GCC, but with GCC 7 and GCC 8 things get more complicated. For GCC 7, there was a patch in ciruculation that will make CUDA work, but with GCC 8, there is no such thing, as far as I know, so the only way is to use GCC 7. Alike for LLVM, the highest clang version supported is 6, while Slackware switched to clang version 7. Next CUDA version will certainly fix this, as many important distributions switched to GCC 8, and in particular upcoming RHEL 8 should come with GCC 8 too. I expect new CUDA version certainly at the next GTC conference, in March 2019, and maybe earlier.

eduardr 12-11-2018 09:23 PM

@cgorac Thanks for the detailed guide! That looks like a promising approach. Compiling gcc 7.4.0 right now and will see how the CUDA piece works out once gcc is ready.

I did try downgrading the system gcc to 7.3.0 but that caused issues when I compiled the latest the Nvidia kernel modules (gcc mismatch with gcc 8 used to compile the kernel). So this parallel gcc 7 setup in /opt looks like a better way to go.

eduardr 12-12-2018 10:27 AM

Made good progress so far.

Compiled and installed gcc

Notes:
  • I downloaded the entire gcc source tree (3.4GB). I'm sure there's a better way to get just the v7 branch
  • gcc svn repo wasn't working so used the github gcc mirror.
  • I used -j32 when make'ing for the number of cores/hyperthreads my machine has - much faster build
  • I used the fetch-from-svn-and-prep-tarball.sh script to make sure the tarball is assembled according to the Slackware standard, "just in case"

Code:

# mkdir /usr/local/src/gcc
# cd /usr/local/src/gcc
# git clone https://github.com/gcc-mirror/gcc.git
# ln -s gcc.git gcc
# wget http://slackware.cs.utah.edu/pub/sla...rep-tarball.sh
# chmod a+x fetch-from-svn-and-prep-tarball.sh
# ./fetch-from-svn-and-prep-tarball.sh
# tar xvf gcc-7.4.1_20181211_r267043.tar.lz
# cd gcc-7.4.1_20181211_r267043
# mkdir -p /opt/gcc/gcc-7.4
# ./configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/opt/gcc/gcc-7.4 --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib --program-suffix=-7.4
# make -j32
# make install

Installed latest cuda toolkit

Downloaded latest cuda 9.2 and cudnn packages (Ubuntu->installer runfile):
  • cuda_9.2.148_396.37_linux.run
  • cuda_9.2.148.1_linux.run
  • cudnn-9.2-linux-x64-v7.4.1.5.tgz

Symlink for gcc binary:
Code:

# cd /opt/gcc/gcc-7.4/bin
# ln -s gcc-7.4 gcc

Run cuda toolkit and patch installers (I chose /opt/nvidia/cuda as destination when running installers):
Code:

# PATH="/opt/gcc/gcc-7.4/bin:${PATH}" ./cuda_9.2.148_396.37_linux.run
# PATH="/opt/gcc/gcc-7.4/bin:${PATH}" ./cuda_9.2.148.1_linux.run

Manually extracted files from cudnn-9.2-linux-x64-v7.4.1.5.tgz and moved them to the appropriate directories in /opt/nvidia/cuda/


All times are GMT -5. The time now is 03:05 AM.