Skip to content

Instantly share code, notes, and snippets.

@goldsborough
Last active January 1, 2025 17:14
Show Gist options
  • Select an option

  • Save goldsborough/d466f43e8ffc948ff92de7486c5216d6 to your computer and use it in GitHub Desktop.

Select an option

Save goldsborough/d466f43e8ffc948ff92de7486c5216d6 to your computer and use it in GitHub Desktop.
Instructions for installing GCC >= 4.9 for PyTorch Extensions
# Instructions for installing GCC 4.9 on various platforms.
# The commands show instructions for GCC 4.9, but any higher version will also work!
# Ubuntu (https://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu/581497#581497)
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
# CentOS (https://www.softwarecollections.org/en/scls/rhscl/devtoolset-3/)
sudo yum install centos-release-scl
sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
sudo yum install devtoolset-3
scl enable devtoolset-3 bash
@ternaus

ternaus commented Jul 31, 2018

Copy link
Copy Markdown

Does not work in Ubuntu 18.04

sudo apt-get install gcc-4.9 g++-4.9
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package gcc-4.9 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package g++-4.9 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'gcc-4.9' has no installation candidate
E: Package 'g++-4.9' has no installation candidate

@goldsborough

Copy link
Copy Markdown
Author

@ternaus gcc-4.9 may not be available on Ubuntu 18.04 anymore. But the message does note

The commands show instructions for GCC 4.9, but any higher version will also work!

So replacing "4.9" for e.g. "5" or "7" should work :)

@pyaf

pyaf commented Nov 17, 2018

Copy link
Copy Markdown

For those who don't have root access and are in a conda environment, do this:
conda install -c psi4 gcc-5

@yuyijie1995

Copy link
Copy Markdown

This command delete my gpu driver and other driver softweres

@yuyijie1995

Copy link
Copy Markdown

At the same time I can't use the setting options

@maxsenh

maxsenh commented Feb 8, 2019

Copy link
Copy Markdown

For those who don't have root access and are in a conda environment, do this:
conda install -c psi4 gcc-5

One can also follow the instructions on GCC's homepage https://gcc.gnu.org/wiki/InstallingGCC after downloading the desired version

tar xzf gcc-VERSION.tar.gz
cd gcc-VERSION
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-VERSION/configure --prefix=$HOME/GCC-VERSION --enable-languages=c,c++,fortran,go
make
make install

@MKowal2

MKowal2 commented Oct 19, 2019

Copy link
Copy Markdown

@maxsenh Thank you!!!

@craftsliu

Copy link
Copy Markdown

For those who don't have root access and are in a conda environment, do this:
conda install -c psi4 gcc-5

it work for me ,thanks!

@TianxiangMa

Copy link
Copy Markdown

For those who don't have root access and are in a conda environment, do this:
conda install -c psi4 gcc-5

Thank you so much, it works for me.

@avijit-thawani

Copy link
Copy Markdown

For those who don't have root access and are in a conda environment, do this:
conda install -c psi4 gcc-5

works for me too, thanks!

@yekeren

yekeren commented May 2, 2020

Copy link
Copy Markdown

For those who don't have root access and are in a conda environment, do this:
conda install -c psi4 gcc-5

It works.

@moha23

moha23 commented May 30, 2020

Copy link
Copy Markdown

For those who don't have root access and are in a conda environment, do this:
conda install -c psi4 gcc-5

Does not work for gcc-7, or gcc-7.5, gives PackagesNotFoundError

@Marwen-Bhj

Copy link
Copy Markdown

Pyaf solution gives me this error while executing :
RROR conda.core.link:_execute(502): An error occurred while installing package 'psi4::gcc-5-5.2.0-1'. LinkError: post-link script failed for package psi4::gcc-5-5.2.0-1 running your command again with -vwill provide additional information location of failed script: /home/neox/anaconda3/envs/yolact-env/bin/.gcc-5-post-link.sh

@BambooPalace

Copy link
Copy Markdown

For those who don't have root access and are in a conda environment, do this:
conda install -c psi4 gcc-5

It worked! Thanks

@xuChenSJTU

Copy link
Copy Markdown

Pyaf solution gives me this error while executing :
RROR conda.core.link:_execute(502): An error occurred while installing package 'psi4::gcc-5-5.2.0-1'. LinkError: post-link script failed for package psi4::gcc-5-5.2.0-1 running your command again with -vwill provide additional information location of failed script: /home/neox/anaconda3/envs/yolact-env/bin/.gcc-5-post-link.sh

Hi, I met the same problem. Have you solved it?

@brando90

brando90 commented Mar 5, 2021

Copy link
Copy Markdown

that worked for me, gcc updated apex installed

@DawnyWu

DawnyWu commented Mar 21, 2021

Copy link
Copy Markdown
# CentOS 7
sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash
which gcc
gcc --version

@jiaminglei-lei

Copy link
Copy Markdown

For those who don't have root access and are in a conda environment, do this:
conda install -c psi4 gcc-5

it works!!!!! Thank you!!!!

@ZihaoChen0319

Copy link
Copy Markdown

For those who don't have root access and are in a conda environment, do this:
conda install -c psi4 gcc-5

It works for me!!! Thanks!

@xiahaoyun

Copy link
Copy Markdown
# CentOS 7
sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash
which gcc
gcc --version

It works for me!!! Thanks!
CentOs 7.8

@hansen7

hansen7 commented Apr 10, 2022

Copy link
Copy Markdown

I've tried with:

conda https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2

to install GCC-5.4.0

Hope it helps.

@annawoodard

Copy link
Copy Markdown
conda https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2

That worked for me-- thanks!!

@milad621

milad621 commented Oct 5, 2022

Copy link
Copy Markdown
conda https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2

to install GCC-5.4.0

I get:

$ conda https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2
usage: conda [-h] [-V] command ...
conda: error: argument command: invalid choice: 'https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2' (choose from 'clean', 'compare', 'config', 'create', 'info', 'init', 'install', 'list', 'package', 'remove', 'rename', 'run', 'search', 'uninstall', 'update', 'upgrade', 'notices')

@ShaowenJ

ShaowenJ commented Nov 4, 2022

Copy link
Copy Markdown

For those who don't have root access and are in a conda environment, do this: conda install -c psi4 gcc-5

No working for our school HPC

@zhulifengsheng

Copy link
Copy Markdown
conda https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2

to install GCC-5.4.0

I get:

$ conda https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2
usage: conda [-h] [-V] command ...
conda: error: argument command: invalid choice: 'https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2' (choose from 'clean', 'compare', 'config', 'create', 'info', 'init', 'install', 'list', 'package', 'remove', 'rename', 'run', 'search', 'uninstall', 'update', 'upgrade', 'notices')

conda install https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2

@prabinrath

Copy link
Copy Markdown

This is the correct command and it works! If you are on remote system and you do not have sudo access then this command should help.
conda install https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2

@RodolpheCalvet

Copy link
Copy Markdown

This command delete my gpu driver and other driver softweres

Just when i thought "i don know this channel tho..."

@pinecho

pinecho commented Aug 2, 2023

Copy link
Copy Markdown

This is the correct command and it works! If you are on remote system and you do not have sudo access then this command should help. conda install https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2

It works for me, thank!

@kanseaveg

Copy link
Copy Markdown

@ShivamThakker

Copy link
Copy Markdown

This is the correct command and it works! If you are on remote system and you do not have sudo access then this command should help. conda install https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2

This worked for me. Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment