During my installation of torch on Ubuntu 17.04, I ran into a few problems.

The first report after trying to compile torch was something similar to https://stackoverflow.com/questions/6622454/cuda-incompatible-with-my-gcc-version

giving me something like

error -- unsupported GNU version! gcc >5 are not supported!

After I fixed this I got another error similar to here:


Gcc error: gcc: error trying to exec 'cc1': execvp: No such file or directory

Want to also add here that this is in conjunction with my cuda setup.

  • 1
    Please include the actual steps you performed.
    – muru
    Jun 8, 2017 at 9:38
  • you're too fast for my typing! 2 minutes ahead of me, but answer is now posted.
    – piie
    Jun 8, 2017 at 9:46
  • Additionally, I have had to upgrade my Ubuntu from 17.04 to 17.10 via sudo do-release-upgrade as 17.04 is reached end of life as of January 13, 2018
    – piie
    Jan 19, 2018 at 22:30

2 Answers 2


I fixed the first error by installing gcc-5:

sudo apt-get install gcc-5

next, it said it couldnt find cc1, so i did

which cc1

which returned a blank. This was because I didn't install g++-5

sudo apt-get install gcc-5 g++-5

we next want to make this our default gcc, so

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 1

and finally


in the torch directory works. This is similar to the approach here: https://gist.github.com/beci/2a2091f282042ed20cda

torch getting started that started it all: http://torch.ch/docs/getting-started.html

hope this helps someone

  • which cc1 still returns blank. But this works!
    – Dmitry
    Sep 13, 2017 at 10:20

I had almost the same error messag:

gcc: error trying to exec 'cc1': execvp: No such file or directory

I googled and arrived here. So for the sake of helping people with my same problem... My error was in a different context: trying to compile a go program importing the go-sqlite3 driver...

in my case (ubuntu 16.10 yakkety yak) sudo find /usr/ -name cc1 showed me that cc1 was installed, even several versions:


I did run which gcc and could see that gcc was pointing to my nvidia cuda driver bin directory, which was including gcc...

In my case this was some residual stuff I didn't uninstall properly, so I had to manually remove that directory from my $PATH in my .bashrc. The I closed my terminal (I've could have run source ~/.bashrc), verified with which gcc that it was pointing to the proper one (/usr/bin/gcc) tried to recompile my go program and it worked without any errors this time.

I know this may not be the perfect answer, but it may point a perso having the same error message to investigate further this kind of stuff.

Of course check which version of gcc you are using, and install the "companion" g++ you need. In my case it was: g++-4.9 (already installed).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .