Install CUDA#
公式ページが最強#
CUDA のアーカイブでインストールしたいバージョンを選択
https://developer.nvidia.com/cuda-toolkit-archive
Platform の選択
指示通り,コマンドを実行する.
dev をダウンロードするので,temp フォルダなどを作るとファイル整理しやすい
(推奨)バージョン指定する(指定しない場合は最新のCUDAになる)
- $ sudo apt-get -y install cuda
+ $ sudo apt install cuda-12-1
再起動
$ reboot
PATHを通す
$ echo "export PATH=/usr/local/cuda/bin:$PATH" >> ~/.bashrc
$ echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH" >> ~/.bashrc
Terminalの再起動か設定ファイルのリロード
$ source ~/.bashrc
インストールの確認
$ nvcc -V
Troubleshooting#
1.apt install cuda
で以下のエラー
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nvidia-kernel-common-535 : Conflicts: nvidia-kernel-common
nvidia-kernel-common-545 : Conflicts: nvidia-kernel-common
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
apt install nvidia-kernel-common-535
をしても以下のエラー
Unpacking nvidia-kernel-common-535 (535.129.03-0ubuntu1) over (535.129.03-0ubuntu0.22.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/nvidia-kernel-common-535_535.129.03-0ubuntu1_amd64.deb (--unpack):
trying to overwrite '/lib/firmware/nvidia/535.129.03/gsp_ga10x.bin', which is also in package nvidia-firmware-535-535.129.03 535.129.03-0ubuntu0.22.04.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/nvidia-kernel-common-535_535.129.03-0ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
解決方法
エラーメッセージ通り,dev パッケージを上書きする
$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/nvidia-kernel-common-535_535.129.03-0ubuntu1_amd64.deb
$ sudo apt -f install
$ sudo apt update