Ubuntu18.04で1080Tiから3090にアップグレードする

1.1。元のグラフィックドライバをアンインストールします

sudo apt-get purge nvidia*
或者 
sudo apt-get remove --purge nvidia*

2.2。利用可能なドライバーを表示する:ubuntu-driversデバイス

(base) jack@JACK429:~$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00002204sv00001B4Csd00001454bc03sc00i00
vendor   : NVIDIA Corporation
manual_install: True
driver   : nvidia-driver-460-server - distro non-free recommended
driver   : nvidia-driver-460 - third-party free
driver   : xserver-xorg-video-nouveau - distro free builtin

3.3。ドライバを自動的にインストールします

sudo ubuntu-drivers autoinstall

4.4。インストールが成功したかどうかを確認します:nvidia-smi

(base) jack@JACK429:~$ nvidia-smi
Sat Mar  6 06:28:29 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.27.04    Driver Version: 460.27.04    CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce RTX 3090    Off  | 00000000:01:00.0  On |                  N/A |
| 81%   68C    P2   307W / 350W |  23591MiB / 24265MiB |     62%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A       941      G   /usr/lib/xorg/Xorg                351MiB |
|    0   N/A  N/A      2014      G   ...mviewer/tv_bin/TeamViewer        4MiB |
|    0   N/A  N/A      2373      G   /usr/bin/compiz                    55MiB |
|    0   N/A  N/A      2635      G   fcitx-qimpanel                     11MiB |
|    0   N/A  N/A     18121      G   ...gAAAAAAAAA --shared-files       98MiB |
|    0   N/A  N/A     22951      C   ...nda3/envs/Jack/bin/python    23063MiB |
+-----------------------------------------------------------------------------+

 5. cudaとcudnnをインストールします(ステップ4の完了後にcuda 11.2がインストールされているようですが、手動で再度インストールできます)

https://developer.nvidia.com/cuda-toolkit-archive または https://developer.nvidia.com/cuda-11.2.0-download-archive
https://developer.nvidia.com/cudnn  (登録が必要)これら3つのlibcudnn8-dev_8.1.1.33-1 + cuda11.2_amd64.deb libcudnn8_8.1.1.33-1 + cuda11.2_amd64.debおよびlibcudnn8-samples_8.1.1.33-1 + cuda11.2_amd64.debをダウンロードしてインストールします

6.6。インストールが成功したかどうかを確認します:nvcc --version

(base) jack@JACK429:~$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Nov_30_19:08:53_PST_2020
Cuda compilation tools, release 11.2, V11.2.67
Build cuda_11.2.r11.2/compiler.29373293_0

 ここで半分完了しました

7.通常、私はcondaを使用して仮想環境を作成します。これは、3090ではcuda> = 11およびcudnn> = 8が必要なため、次のcondaコマンドを使用して新しい環境を作成します。

conda create -n Jack python=3.8 cudatoolkit=11.0  cudnn=8.0

8.8。cudatoolkit11.0およびcudnn8.0が見つからないという問題を解決します

condaに新しいミラーソースを追加します:vim〜 / .condarc

sudo vim ~/.condarc

編集内容は以下のとおりです。

show_channel_urls: true
channels:
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - defaults

9.9。conda create -n Jack python = 3.8 cudatoolkit = 11.0 cudnn = 8.0を再度実行すると、インストールが成功します。

conda create -n Jack python=3.8 cudatoolkit=11.0  cudnn=8.0

10. tensorflow-gpu 2.5.0をインストールします。このバージョンは非公式バージョンです。直接インストールすると、対応する2.5.0バージョンが見つかりません次のコマンドを使用して、作成したconda仮想環境にインストールします

pip install tf-nightly-gpu==2.5.0.dev20210305

tf-nightly-gpuホームページhttps://libraries.io/pypi/tf-nightly-gpu

 

この時点で、プロジェクトは正常に実行できるはずです。

 

 

おすすめ

転載: blog.csdn.net/deephacking/article/details/114432191