genn
genn copied to clipboard
NVCC needs to be invoked with -fPIC on Debian Stretch system
More research required as to why but, adding -Xcompiler -fPIC
to the generated Makefile solves the problem. The system in question is:
- x86_64
- Debian Stretch (current stable)
- NVIDIA driver installed 384.130-1 (from https://packages.debian.org/stretch/nvidia-kernel-dkms)
- CUDA 8.0.44-3
- GCC 6.3.0
Problem seems related to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=861878 - should we simply ALWAYS pass -fPIC to NVCC? Need to test on other Linuxes and Mac and investigate
-fPIE also works - not clear which we should use
@tnowotny - I did a bit more investigation into Mikael's issue and it appears that GCC can be configured to have -fPIE set by default (it enables position-indendendent executables which helps security by allowing your programs to be randomly placed in memory). The problem is that, on Mikael's Debian system, this doesn't get passed on to NVCC so it ends up building incompatible code. This is a bug somewhere in Debian as my Ubuntu 18 laptop also has GCC configured this way and it works fine. As far as I can tell there's 3 potential fixes:
- Build everything with
-fPIE
- simple but requires changing a whole load of make files. - Add
-fPIE
to theNVCCFLAGS
in the GeNN-generated-makefile if--enable-default-pie
is listed in the output ofg++ -v
. - Add
-fPIE
to theNVCCFLAGS
in the GeNN-generated-makefile based on#if defined __PIC__ || defined __pic__ || defined PIC || defined pic
ingenerateRunner.cc
I feel 2 is probably a bad idea because it's unclear if the output is the same on all GCCs, let alone clang and my attempts at bash-magic tend to fail on Mac but I'm undecided between the other two.
@mdjurfeldt - after figuring out a range of hacks we could add to GeNN to fix your issue, I realised your combination of GCC 6 and CUDA 8 isn't actually officially supported by NVIDIA. I then dug somewhat deeper and it seems CUDA 8 on Stretch is problematic in general due to this (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=835940). I honestly think the best solution is for you to install CUDA 9.1 from backports (https://packages.debian.org/stretch-backports/nvidia-cuda-toolkit) and we'll add something to the readme about Debian.
OK, thanks! I'll try that.
Great! I'm keen not add too many workarounds for OS issues...