安裝 CUDA 10.0 時出現問題

安裝 CUDA 10.0 時出現問題

上週電腦重新啟動後,我的 Ubuntu 18.04 LTS 系統突然忘記了有關顯示器的所有內容,只為「未知」顯示器產生了映像,因此我刪除了與 NVIDIA 相關的所有內容,包括 CUDA 和 cuDNN(我需要在GPU 上執行TensorFlow),並嘗試從頭開始重新安裝所有內容。我成功地重新安裝了 GPU 驅動程式並保留了我的顯示器設定。

但是,我在安裝 CUDA 時遇到問題。當我跑步時

sudo apt-get install cuda-toolkit-10-0

我明白了

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package cuda-toolkit-10-0 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 'cuda-toolkit-10-0' has no installation candidate

這很奇怪,因為我認為這是我之前安裝 CUDA 時使用的命令(儘管我不記得上次最終使 CUDA 工作的是什麼)。所以我嘗試找到包包這是指cuda-toolkit-10-0透過運行

apt-cache search cuda-toolkit-10-0

但這不會輸出任何內容(如果連結問題中所述的內容是正確的,這也很奇怪)。

我還嘗試從 NVIDIA 的 CUDA Toolkit 存檔頁面開始,並按照以下說明進行操作安裝本地 deb 文件

$ sudo dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
[sudo] password for kristofer: 
(Reading database ... 249237 files and directories currently installed.)
Preparing to unpack cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb ...
Unpacking cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48 (1.0-1) over (1.0-1) ...
Setting up cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48 (1.0-1) ...
$ sudo apt-key add /var/cuda-repo-10-0-local-10.0.130-410.48/7fa2af80.pub
OK
$ sudo apt-get update
Hit:1 http://se.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://linux.teamviewer.com/deb stable InRelease                                                                                       
Hit:3 http://se.archive.ubuntu.com/ubuntu bionic-updates InRelease                                                                           
Hit:4 http://se.archive.ubuntu.com/ubuntu bionic-backports InRelease                                                                         
Hit:5 http://security.ubuntu.com/ubuntu bionic-security InRelease                                                                            
Hit:6 http://ppa.launchpad.net/jonathonf/gcc-7.3/ubuntu bionic InRelease                                                                     
Hit:7 http://archive.ubuntu.com/ubuntu bionic InRelease                                                                                      
Hit:8 http://repository.spotify.com stable InRelease                                                                                         
Hit:9 http://archive.canonical.com/ubuntu bionic InRelease                                                                                   
Hit:10 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease                                             
Reading package lists... Done
$ sudo apt-get install cuda
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package cuda

所以apt-get找不到cuda包。

那麼,如何安裝CUDA 10.0呢?

答案1

我設法解決了這個問題,這對我有用:

  1. 跟著安裝前操作
  2. 請按照以下說明進行操作安裝本地運行文件
  3. 跟著安裝後操作

就我而言,我已經添加了

export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64\
                         ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

到我的 bashrc。然而,我並沒有意識到這個路徑名稱包含錯誤的 CUDA 版本號,因為我沒有使用最新的 CUDA 版本。這就是 TensorFlow 無法在我的系統上找到 CUDA 的原因。

相關內容