nvccでerror: attribute __malloc__ does not take argumentsとなる場合の対処法
POSTED BY
2021-11-26
2021-11-26




表題のエラーは、Ubuntu等Linux環境でNVIDIA nvccを走らせると起こる。
これは、nvccが呼んでいるgcc/g++のバージョンが高すぎるために起こっているので、複数バージョンのgcc/g++をインストールして使い分けることで解決する。
現バージョンのnvccはgcc10以下でないと表題のエラーになることから、10を入れてalternativisでリンクを10に向けて管理すれば、あとで簡単に11に戻せる。
インストール可能なバージョンの確認
sudo -s apt search '^gcc-[0-9]+$' Sorting... Done Full Text Search... Done gcc-11/impish,now 11.2.0-7ubuntu2 amd64 [installed] GNU C compiler gcc-10/impish,now 10.3.0-11ubuntu1 amd64 GNU C compiler gcc-8/impish 8.5.0-0ubuntu4 amd64 GNU C compiler gcc-9/impish 9.4.0-3ubuntu1 amd64 GNU C compiler
11がインストールされているので、エラーを解決するためまず普通に10を入れる。
apt install gcc-10 apt install g++-10
update-alternativesで、10と11をリンク登録し、切り替えられるようにする。
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10 update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11
登録したらconfigで、バージョンを選ぶ。
update-alternatives --config gcc There are 2 choices for the alternative gcc (providing /usr/bin/gcc). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/gcc-11 11 auto mode 1 /usr/bin/gcc-10 10 manual mode 2 /usr/bin/gcc-11 11 manual mode Press <enter> to keep the current choice[*], or type selection number: 1 update-alternatives: using /usr/bin/gcc-10 to provide /usr/bin/gcc (gcc) in manual mode update-alternatives --config gcc There are 2 choices for the alternative gcc (providing /usr/bin/gcc). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/gcc-11 11 auto mode * 1 /usr/bin/gcc-10 10 manual mode 2 /usr/bin/gcc-11 11 manual mode update-alternatives --config g++ There are 2 choices for the alternative g++ (providing /usr/bin/g++). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/g++-11 11 auto mode 1 /usr/bin/g++-10 10 manual mode 2 /usr/bin/g++-11 11 manual mode Press <enter> to keep the current choice[*], or type selection number: 1 update-alternatives: using /usr/bin/g++-10 to provide /usr/bin/g++ (g++) in manual mode update-alternatives --config g++ There are 2 choices for the alternative g++ (providing /usr/bin/g++). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/g++-11 11 auto mode * 1 /usr/bin/g++-10 10 manual mode 2 /usr/bin/g++-11 11 manual mode
gcc, g++それぞれで行って、デフォルトでは最新11にリンクが向けられているので、1をタイプして、10を選べば、コンパイラバージョンは10で動く。簡単に11に戻せるし、超便利!さすLinux!
gcc --version gcc (Ubuntu 10.3.0-11ubuntu1) 10.3.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. g++ --version g++ (Ubuntu 10.3.0-11ubuntu1) 10.3.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
写真1枚で作る年賀状・ポストカード★送料無料・税込み30枚500円〜【TOLOT Card】

★☆驚きの価格!ポストカード・年賀状印刷の価格破壊★
◆会員数280万人のフォトブックサービス『TOLOT』...【READ MORE】
Android
iPhone/iPad
Flutter
MacOS
Windows
Debian
Ubuntu
CentOS
FreeBSD
RaspberryPI
C/C++
PHP
Java
JavaScript
Node.js
Swift
Python
Amazon/AWS
CORESERVER
Google
仮想通貨
LINE
IBM Watson
Microsoft Azure
Xcode
VMware
MySQL
PostgreSQL
Redis
Groonga
Git/GitHub
Apache
nginx
Postfix
SendGrid
Hackintosh
Hardware
Fate/Grand Order
ウマ娘
将棋
※本記事は当サイト管理人の個人的な備忘録です。本記事の参照又は付随ソースコード利用後にいかなる損害が発生しても当サイト及び管理人は一切責任を負いません。
※本記事内容の無断転載を禁じます。
※本記事内容の無断転載を禁じます。
【キーワード検索】
【最近の記事】【全部の記事】
最新版のApache2でCGIが実行できずソースやバイナリが表示される場合bitcoinjs-lib、bip32、bip39を使ってビットコインアドレスを生成する
Cannot read property makeRandom of undefinedと言われた場合
web3.jsとwindow.ethereumでコントラクト関数を引数つきでコールしプロパティを取得する
JavaScriptで外部URLのファイルをダウンロードしてデータを取得する
【MetaMask】window.ethereumのeth_callで任意のコントラクト関数を呼ぶ
window.ethereum.requestに渡すdataフィールドをABIエンコードで作成する
【Solidity】Remix IDEを使用してサーバー不要のコントラクト開発&デバッグ【Ethereum】
【Windows】Googleフォトからダウンロードした動画が音声のみで映像が再生されない場合
PostgreSQLをソースコードからインストールしてsystemdのサービスとして動かす
【人気の記事】【全部の記事】
進研ゼミチャレンジタッチをAndroid端末化する5chブラウザJane Styleの板一覧にゲーム板等が表示されない場合
Windows版Google Driveが使用中と言われアンインストールできない場合
【Windows10】リモートデスクトップ間のコピー&ペーストができなくなった場合の対処法
Googleスプレッドシートを編集したら自動で更新日時を入れる
【Javascript】JSON配列内にある特定要素の取得法【Node.js】
Ubuntuで固定IPアドレスを使う設定をする
Googleファミリーリンクで子供の端末の現在地がエラーで取得できない場合
【Hackintosh】組立PCにWindowsとmacOSを同居させる場合の注意点
Google ColaboratoryのTensorFlowバージョンを変更する(1.X←→2.X)
【カテゴリーリンク】
Android
iPhone/iPad
Flutter
MacOS
Windows
Debian
Ubuntu
CentOS
FreeBSD
RaspberryPI
C/C++
PHP
Java
JavaScript
Node.js
Swift
Python
Amazon/AWS
CORESERVER
Google
仮想通貨
LINE
IBM Watson
Microsoft Azure
Xcode
VMware
MySQL
PostgreSQL
Redis
Groonga
Git/GitHub
Apache
nginx
Postfix
SendGrid
Hackintosh
Hardware
Fate/Grand Order
ウマ娘
将棋