今日のひとこと Challange IT For Future

nvccでgccのバージョンエラー

Linux 読了 2分

この記事は最終更新から 6 年以上たっています。内容が現在の状況と異なる可能性があります。現在の情報は最新の記事、Fess の記事をご覧ください。

nvccがgccのバージョンに依存しているので、新しいgccを使っていたりすると、cudaのバージョンによっては以下のような感じのエラーになる。

$ nvcc -o add_cuda add.cu
In file included from /usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:83,
from :
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!

この場合だと、

$ sudo apt install g++-8

として、gcc 8をインストールして、nvccコマンドを以下のように実行すればコンパイルできる。

$ nvcc -o add_cuda add.cu -ccbin g++-8