Ubuntu 21.04使用開始(1日目)

Ryzen+NVIDIAのノートが欲しい。データベースと機械学習の全部入りラーメンだ

 前々から、図書館などでもガッツリ使い倒せるLinuxノートが欲しいと思っていました。具体的には、PostgreSQLがselect文で4スレッドくらい並列処理してくれて、TensorFlow/KerasでGPU SUGEEEE出来る程度のスペックです。

 Amazonの年末セールで『ASUS ゲーミングノートパソコン TUF Gaming A15 FA506IH (AMD Ryzen5 4600H/8GB・SSD 512GB/GTX 1650/1,920×1,080ドット (フルHD) (144Hz)/15.6インチ/フォートレス・グレイ)』が¥82,800と安かったので衝動買い。メモリは即32GBに増設しました。

「AMDが7nmで作ったワットパフォーマンスが良いRenoirが載ったノートにディープラーニングで使えるGTX 1650が付いて8万ちょい。買うしかない……」

 4600Hは6コア12スレッドのノートPC向けCPUで、AMD Renoirシリーズの廉価版です。『最強』ではありませんが、実売10万円以下のノートでこの性能は魅力的です。SSDは内蔵で別途2TBくらい欲しいですが、金欠なので追い詰まってから考えることにします。

AMD Ryzen 5 4600Hは7nm世代の廉価版モバイルCPU

 なお現在の最新モデルは「Ryzen PRO 5000シリーズ モバイル プロセッサ(5850U/5650U/5450U)」、及び「Ryzen 5000シリーズ モバイル プロセッサ(5800U/5700U/5600U/5500U/5400U/5300U)」で7nm世代のままです。5nmのZen4世代は2022年に登場予定です。

ゲーミングPCへのUbuntu 21.04のインストール

 Ubuntuのインストールが終わると、沢山の有名で楽しそうなアプリをリコメンドされます。「SSDの残りが300GBくらいしかないのに片っ端から入れちゃダメダ」と思いつつも入れられるうちはつい入れてしまいます。

日本語フォルダ名を英語化

 lsなどでパス指定するときにフォルダ名が日本語だとIMEの切り替えや入力が面倒なので、英語に変えてしまいます。

masaru@ASUS-TUF-Gaming:~$ LANG=C xdg-user-dirs-gtk-update

導入直後に入れたアプリ

 初心者でも導入に困らなさそうなものは名前だけ……。

NVIDIA driver metapackageNVIDIA独自のグラフィックドライバ。『ソフトウェアとアップデート』 – 『追加のドライバー』でプロプライエタリ版を指定してインストールする必要がある
Ubuntu Live Patchパッケージの自動更新サービス。実際は手動でapt updateを続けることが多いですが、念のため導入
Shutter画面キャプチャソフト。不具合のため現在使用できず
Krita定番の画像ソフト。Shutterが使えなかったので最優先で導入。個人的にも好きなソフト
Google Chrome, ChromiumWebブラウザ。SSOの誘惑と逃げたい気持ちでサンドイッチに
dbeaver-ceJDBCの汎用データベースクライアント
Anaconda言わずと知れたPython機械学習系のフレームワーク。PATHを汚染するので好きではないのですが、楽なので結局入れてしまいます
jupyter-notebookAnacondaに同梱のPython実行環境
Visual Studio Codeプログラム開発環境のデファクトスタンダード。Pythonなどのインタプリタを配下に置いてしまうAnacondaとの共存が課題
RAnacondaのパッケージとしてcondaでインストール
RStudioRの開発環境。PATHの問題を避けるためAnacondaからインストール
tracerouteサーバーまでのネットワーク経路を確認するツール
OpenJDK 11各種データベース用のJava開発環境

NDIVIAドライバの基本設定

 Ubuntu 21.04は、素の状態でNVIDIAの独自ドライバを使ってくれません。チューニングの観点から独自ドライバを入れるのが良さそうです。

masaru@ASUS-TUF-Gaming:~$ lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation TU117M (rev ff)
01:00.1 Audio device: NVIDIA Corporation Device 10fa (rev ff)

 続いて、aptのレポジトリに最新のドライバが降ってくるように設定します。

masaru@ASUS-TUF-Gaming:~$ sudo add-apt-repository -y -n ppa:graphics-drivers/ppaPPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'deb http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu/ hirsute main'
Description:
Fresh drivers from upstream, currently shipping Nvidia.

## Current Status

Current long-lived branch release: `nvidia-430` (430.40)
Dropped support for Fermi series (https://nvidia.custhelp.com/app/answers/detail/a_id/4656)

Old long-lived branch release: `nvidia-390` (390.129)

For GF1xx GPUs use `nvidia-390` (390.129)
For G8x, G9x and GT2xx GPUs use `nvidia-340` (340.107)
For NV4x and G7x GPUs use `nvidia-304` (304.137) End-Of-Life!

Support timeframes for Unix legacy GPU releases:
https://nvidia.custhelp.com/app/answers/detail/a_id/3142

## What we're working on right now:

- Normal driver updates
- Help Wanted: Mesa Updates for Intel/AMD users, ping us if you want to help do this work, we're shorthanded.

## WARNINGS:

This PPA is currently in testing, you should be experienced with packaging before you dive in here:

Volunteers welcome!

### How you can help:

## Install PTS and benchmark your gear:

    sudo apt-get install phoronix-test-suite

Run the benchmark:

    phoronix-test-suite default-benchmark openarena xonotic tesseract gputest unigine-valley

and then say yes when it asks you to submit your results to openbechmarking.org. Then grab a cup of coffee, it takes a bit for the benchmarks to run. Depending on the version of Ubuntu you're using it might preferable for you to grabs PTS from upstream directly: http://www.phoronix-test-suite.com/?k=downloads

## Share your results with the community:

Post a link to your results (or any other feedback to): https://launchpad.net/~graphics-drivers-testers

Remember to rerun and resubmit the benchmarks after driver upgrades, this will allow us to gather a bunch of data on performance that we can share with everybody.

If you run into old documentation referring to other PPAs, you can help us by consolidating references to this PPA.

If someone wants to go ahead and start prototyping on `software-properties-gtk` on what the GUI should look like, please start hacking!

## Help us Help You!

We use the donation funds to get the developers hardware to test and upload these drivers, please consider donating to the "community" slider on the donation page if you're loving this PPA:

http://www.ubuntu.com/download/desktop/contribute
More info: https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa
Adding repository.
Adding deb entry to /etc/apt/sources.list.d/graphics-drivers-ubuntu-ppa-hirsute.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/graphics-drivers-ubuntu-ppa-hirsute.list
Adding key to /etc/apt/trusted.gpg.d/graphics-drivers-ubuntu-ppa.gpg with fingerprint 2388FF3BE10A76F638F80723FCAE110B1118213C

Linux版のAnacondaはシェルから導入

 Anacondaはパスなど各種設定をOSから乗っ取る『お行儀が悪いフレームワーク』なためか、Ubuntuでもストアアプリには入っていません。シェルスクリプトを落としてbashで実行します。

masaru@ASUS-TUF-Gaming:~/Downloads$ bash ./Anaconda3-2020.11-Linux-x86_64.sh 

Welcome to Anaconda3 2020.11

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
...
masaru@ASUS-TUF-Gaming:~/anaconda3/bin$ ./conda init
no change     /home/masaru/anaconda3/condabin/conda
no change     /home/masaru/anaconda3/bin/conda
no change     /home/masaru/anaconda3/bin/conda-env
no change     /home/masaru/anaconda3/bin/activate
no change     /home/masaru/anaconda3/bin/deactivate
no change     /home/masaru/anaconda3/etc/profile.d/conda.sh
no change     /home/masaru/anaconda3/etc/fish/conf.d/conda.fish
no change     /home/masaru/anaconda3/shell/condabin/Conda.psm1
no change     /home/masaru/anaconda3/shell/condabin/conda-hook.ps1
no change     /home/masaru/anaconda3/lib/python3.8/site-packages/xontrib/conda.xsh
no change     /home/masaru/anaconda3/etc/profile.d/conda.csh
modified      /home/masaru/.bashrc
(base) masaru@ASUS-TUF-Gaming:~$ conda update --all
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/masaru/anaconda3


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    _anaconda_depends-2020.07  |           py38_0           6 KB
...

Anacondaの功罪

 今回インストールしたAnacondaは2020年7月版。主な開発ツールのPATHを乗っ取る仕様であることを考えると半年以上放置されているのは少し疑念を感じます。もちろんconda updateはかけるのですが……。

 最新版をいち早く使いたい方はAnaconda無しのアカウントを作るか、仮想環境で運用することになりそうです。

(base) masaru@ASUS-TUF-Gaming:~$ python --version
Python 3.8.8