CUDA 8.0 with cutorch and GCC 5.4

I successfully installed CUDA 8.0 RC on my machine (ThinkPad W550s with dual-boot Ubuntu 16.04 LTS and Windows 10) for Ubuntu. I want to use CUDA and cutorch to run an RNN on my GPU, but whenever I try to install cutorch via the following:

luarocks install cutorch

it gives the error “unsupported GNU version! gcc versons later than 5.3 are not supported”.
However, when I type

gcc -v


g++ -v

into the terminal, they both return 4.9.3. I tried using

sudo apt-get remove gcc-5.4

and it works, but it also seems to remove my CUDA installation as well. How can I get around this and use cutorch with CUDA 8.0?

After removing gcc-5.4, reinstall CUDA.

I tried that once but it looks like it just reinstalled gcc-5.4 after that. Anyway, I edited the header file that returned the error and changed it to give an error if it detects gcc-5.4 and up rather than gcc-5.3, but it returned an error at the end saying “No rule to make target ‘/usr/lib/’, needed by ‘lib/THC/’”

installing cuda won’t reinstall gcc-5.4

If gcc-5.4 is getting reinstalled, you might want to discover the actual reason for that, and disable it. Alternatively, you can configure CUDA to use a particular version of gcc on your machine (if you have multiple versions installed) but since this depends on environmental setup, it’s possible for it to be broken after environmental changes, as you’re discovering.

I don’t recommend changing the header file.

The no rule to make target for libopenblas error appears to be unrelated to CUDA.

Thank you, what you said helped me realize the issue. For some reason, in the /usr/bin directory, gcc-5.4.0 was being saved as gcc-5 so when I tried to remove gcc-5.4 from the terminal, it couldn’t find it to remove. Ultimately what I did was set the environment variables CC and CXX to the older versions of GCC and that got it to recognize GCC version as 4.9. Thanks for all of your help!