Last active
July 27, 2018 03:53
-
-
Save pjspillai/1240ddb9548eda1796af794309d059a3 to your computer and use it in GitHub Desktop.
gcc-5.3 installation on Ubuntu 18 (to enable cuda 9.1 + NVIDIA 390)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ================= Removing all gcc/g++ and clean build | |
sudo apt-get remove gcc-7 | |
sudo apt-get remove g++-7 | |
sudo apt-get purge gcc-7* g++-7* | |
sudo apt autoremove | |
# ======================================= | |
Make sure the default displays are running fine. If not: install the following | |
sudo apt-get install ubuntu-desktop xorg xserver-xorg-core xserver-xorg gdm3 libubsan0* ubuntu-desktop | |
x11-session-utils x11-xserver-utils xorg | |
# ====================== | |
# Add gcc-6 (If you do an ap-get install, it will not really work) | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt update | |
sudo apt install --reinstall gcc-6 | |
sudo apt install --reinstall g++-6 | |
sudo update-alternatives --force --all | |
When you get the options for gcc: choose gcc-6 (below example 1) | |
0 /usr/bin/gcc-7 100 auto mode | |
* 1 /usr/bin/gcc-6 60 manual mode | |
2 /usr/bin/gcc-7 100 manual mode | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 | |
Note: Some people have reported that their NVIDIA+CUDA9.1 installation on Ubuntu 18 works perfectly with gcc-6. I wasn't that lucky, so I continue installing gcc-5.3 | |
Give the NVIDIA+CUDA Installation a try. If it fails, then purge nvidia+cuda+clean and repeat all of the above and proceed with gcc-5.3 installation | |
Because the creepy Debian packages tries to sneak in the gcc-7 default compiler with any random package installation. And it gets messing up the cuda installation | |
# ==================== Now install 5.3 | |
Download the gcc tar folder from here https://ftp.gnu.org/gnu/gcc/gcc-5.3.0/ & extract | |
mkdir build | |
cd build | |
You will get errors related to std98 | |
Make the changes to the files as described in the patch here | |
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ec1cc0263f156f70693a62cf17b254a0029f4852 | |
# -------------------------- | |
Change 2: libgcc/config/i386/linux_unwind.h | |
Next, In linux_unwind.h , on line 61, you have to change | |
struct ucontext *uc_ = context->cfa; ==> to struct ucontext_t *uc_ = context->cfa | |
# -------------------------- | |
Change 3: ../libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc | |
error: aggregate ‘sigaltstack handler_stack’ has incomplete type and cannot be defined | |
struct sigaltstack handler_stack; | |
Make the changes below: | |
// Alternate stack for signal handling. | |
InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize); | |
- struct sigaltstack handler_stack; | |
+ stack_t handler_stack; | |
internal_memset(&handler_stack, 0, sizeof(handler_stack)); | |
handler_stack.ss_sp = handler_stack_memory.data(); | |
handler_stack.ss_size = kHandlerStackSize; | |
--- libsanitizer/sanitizer_common/sanitizer_linux.cc 2015-11-23 10:07:18.000000000 +0100 | |
+++ libsanitizer/sanitizer_common/sanitizer_linux.cc 2017-08-05 19:03:06.916498311 +0200 | |
@@ -546,8 +546,7 @@ | |
} | |
#endif | |
-uptr internal_sigaltstack(const struct sigaltstack *ss, | |
- struct sigaltstack *oss) { | |
+uptr internal_sigaltstack(const void *ss, void *oss) { | |
return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss); | |
} | |
# --------- Change 4 ------------ | |
libsanitizer/sanitizer_common/sanitizer_linux.h, Around line 20, make this change | |
struct link_map; // Opaque type returned by dlopen(). | |
namespace __sanitizer { | |
Make this change as well (line 28) | |
// Syscall wrappers. | |
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count); | |
-uptr internal_sigaltstack(const struct sigaltstack* ss, | |
- struct sigaltstack* oss); | |
+uptr internal_sigaltstack(const void* ss, void* oss); | |
uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set, | |
__sanitizer_sigset_t *oldset); | |
void internal_sigfillset(__sanitizer_sigset_t *set); | |
# ----------- | |
libsanitizer/tsan/tsan_platform_linux.cc | |
#if SANITIZER_LINUX | |
int cnt = 0; | |
- __res_state *statp = (__res_state*)state; | |
+ struct __res_state *statp = (struct __res_state*)state; | |
for (int i = 0; i < MAXNS && cnt < nfd; i++) { | |
if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1) | |
fds[cnt++] = statp->_u._ext.nssocks[i]; | |
# ----------- Change 6 ---- | |
In libsanitizer/asan/asan_linux.cc, Add the lin ebelow | |
#include <signal.h> | |
##--------------- That's All !---------------------------- | |
The make process will take a really long long time, Go make coffee(rather grow coffee beans) in the meanwhile :-/ | |
then run | |
sudo make install | |
sudo ldconfig, blah blah blah... | |
sudo apt-get update | |
gcc --version ==> 5.3 | |
sudo reboot now | |
After rebooting, | |
press Ctrl + Alt + F7 to disable the display | |
vim /etc/modprobe.d/blacklist-nvidia-nouveau.conf | |
blacklist nouveau | |
options nouveau modeset=0 | |
sudo update-initramfs -u | |
## ============================================= | |
NVIDIA Driver Installation | |
ubuntu-drivers devices | |
apt-get purge nvidia* && apt-get autoremove | |
Download NVIDIA 390 drivers (.sh) file and install | |
If you are getting the nouveau problems, and unable to install there's an alternate way :-/ | |
Sudo apt-get install nvidia-driver-390 | |
This is gonna freak set gcc7 or gcc6 as default compiler. No Worries | |
cd gcc-5.3 && sudo make install && sudo ldconfig && gcc --version ==> magic | |
# Cuda 9/8/7 Reuirements | |
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev libglfw3-dev libgles2-mesa-dev | |
# Installing Cuda 8 on Ubuntu 18 | |
If outputs error 'Can't locate InstallUtils.pm in @INC' | |
Then do this, | |
Can't locate InstallUtils.pm in @INC | |
sudo cp ./InstallUtils.pm /usr/lib/x86_64-linux-gnu/perl-base/ | |
export $PERL5LIB | |
Download the CUDA 9.1 run file (only upto Ubuntu 17 is available) | |
Say no when it asks if NVIDIA 387 driver needs to be installed | |
Download CUDNN 5, 6, 7 | |
Sudo ln the required library and install them as usual | |
Download NCCL for Cuda 8/9 | |
https://docs.nvidia.com/deeplearning/sdk/nccl-install-guide/index.html | |
Add the PPA && apt update && sudo apt-get install libnccl2=2.2.13-1+cuda8.0 libnccl-dev=2.2.13-1+cuda8.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment