Getting started - Ubuntu22.04
Ubuntu22.04をインストールしたら最初に行うこと。
ダウンロードサイトの変更
ダウンロード元がUbuntu本家サイトや海外の国になっている場合は、日本国内のダウンロードサイトに設定を変更します。
sudo sed -i 's/\/\/archive.ubuntu.com/\/\/jp.archive.ubuntu.com/g' /etc/apt/sources.list
sudo sed -i 's/\/\/us.archive.ubuntu.com/\/\/jp.archive.ubuntu.com/g' /etc/apt/sources.list
sudo sed -i 's/\/\/fr.archive.ubuntu.com/\/\/jp.archive.ubuntu.com/g' /etc/apt/sources.list
sudo apt -y update
パッケージ管理システムの設定
sudo apt update
sudo apt -y install ca-certificates curl gnupg lsb-release git wget
sudo apt -y install apt-transport-https
システムのアップデート
sudo apt -y update
sudo apt -yV upgrade
sudo apt -yV dist-upgrade
sudo apt -yV autoremove
sudo apt autoclean
sudo shutdown -r now
再起動します
ホームディレクトリのディレクトリ名を英語にする
LANG=C xdg-user-dirs-gtk-update
「Don't ask me this again」にチェックを入れて、「Update Names」 をクリックする
CtrlキーとCapsLockキーを入れ替える
(お好みで)
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:swapcaps']"
SSH
sudo apt update
sudo apt install openssh-server
sudo apt-get install openssh-client
タイムゾーンとロケール
タイムゾーンを Asia/Tokyo に、ロケールを ja_JP.UTF-8 に設定する。
sudo timedatectl set-timezone Asia/Tokyo
export LANG=ja_JP.UTF-8
export LC_ALL=ja_JP.UTF-8
export LANGUAGE=ja_JP.UTF-8
sudo sed -i 's/# ja_JP.UTF-8 UTF-8/ja_JP.UTF-8 UTF-8/g' /etc/locale.gen
sudo locale-gen
sudo update-locale LANG=ja_JP.UTF-8
sudo dpkg-reconfigure -f noninteractive locales
sudo /usr/sbin/update-locale LANG=$LANG LC_ALL=$LANG
日本語の言語サポートのインストール
sudo apt -y update
sudo apt -y install language-selector-common
sudo apt -y install $(check-language-support)
各種ツールのインストール
sudo apt -y update
sudo apt -y install net-tools pciutils
sudo apt -y install psutil
不要なソフトウェアの削除
sudo apt -y purge wolfram-engine
sudo apt -y purge libreoffice*
sudo apt -y purge thunderbird*
sudo apt -yV autoremove
sudo apt autoclean
Dockerのインストール
Dockerの公式GPGキーを追加
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Dockerリポジトリ登録
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Docker Engineのインストール
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
動作確認
docker --version
Docker version 20.10.17, build 100c701
sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
docker-composeのインストール(これ必要?)
sudo apt install docker-compose-plugin
動作確認(2022.8.20時点)
docker compose version
Docker Compose version v2.10.0
Dockerコマンドを非rootユーザーでも使えるようにする
sudo groupadd docker
sudo usermod -aG docker $USER
設定を反映するために再起動する
docker ps
エラーが出なければOK
NVIDIA(GPU)関連の設定
GPUを搭載したコンピュータの場合、NVIDIAのドライバーをインストールする。
UEFIのSecure Bootを無効化してから、インストールする方法
UEFIのSecure Bootを有効化したまま、Machine Owner Keyリストにバイナリの署名鍵を登録してインストールする方法
2の方法を説明する。
UbuntuデフォルトグラフィックドライバーのNouveauを無効化する
GUIを使って無効化する
設定」>「このシステムについて」>「グラフィック」でドライバーを確認する
「ソフトウェアとアップデート」>「追加のドライバー」がおそらくいちばん下の「X.Org X server -- Nouveau display driverをxserver-xorg-video-nouveauから使用します(オープンソース)」が選択されているので、「NVIDIA driver metapackageをnvidia-driver-***から使用します(プロプライエタリ)」を選択して「変更の適用(A)」をクリックする。
再起動する
コマンドラインから無効化する
lsmod | grep nouveau
nouveau 2306048 1
mxm_wmi 16384 1 nouveau
i2c_algo_bit 16384 1 nouveau
drm_ttm_helper 16384 1 nouveau
ttm 86016 2 drm_ttm_helper,nouveau
drm_kms_helper 311296 1 nouveau
drm 622592 5 drm_kms_helper,drm_ttm_helper,ttm,nouveau
video 61440 1 nouveau
wmi 32768 2 mxm_wmi,nouveau
テキストエディタで/etc/modprobe.d/blacklist-nouveau.confを編集する
sudo vi /etc/modprobe.d/blacklist-nouveau.conf
# 最終行に追記 (ファイルがない場合は新規作成)
blacklist nouveau
options nouveau modeset=0
initramfsを再生成する
sudo update-initramfs -u
再起動する
sudo reboot
NVIDIA ドライバーのインストール
インストール可能なドライバーを確認する
ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00002503sv00001462sd0000397Dbc03sc00i00
vendor : NVIDIA Corporation
model : GA106 [GeForce RTX 3060]
driver : nvidia-driver-525-server - distro non-free
driver : nvidia-driver-525-open - distro non-free recommended
driver : nvidia-driver-470 - distro non-free
driver : nvidia-driver-510 - distro non-free
driver : nvidia-driver-470-server - distro non-free
driver : nvidia-driver-525 - distro non-free
driver : nvidia-driver-515-server - distro non-free
driver : nvidia-driver-515 - distro non-free
driver : nvidia-driver-515-open - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
「recommended」な最新のドライバーをインストールする
sudo apt install -y nvidia-driver-525
「パッケージの設定」という画面では<了解>を選択する
MOKリストに署名鍵を登録する際に必要となるパスワードを設定して<了解>を選択する
"Configure Secure Boot"の設定完了後、再起動する
再起動すると"Perform MOK management"という青い画面に移行する
方向キーでEnroll MOKに移動してEnterキーで選択する
方向キーでContinueに移動してEnterキーで選択する
方向キーでYesに移動してEnterキーで選択する
「パッケージの設定」で設定したSecure Boot用のパスワードを入力してEnterキーで選択する
バイナリ署名鍵を登録できたので、Rebootに移動してEnterキーで選択する
動作確認
nvidia-smi
Sat Feb 18 01:05:08 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.78.01 Driver Version: 525.78.01 CUDA Version: 12.0 |
|-------------------------------+----------------------+----------------------+
| 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 NVIDIA GeForce ... Off | 00000000:01:00.0 On | N/A |
| 0% 43C P8 15W / 170W | 449MiB / 12288MiB | 25% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 2019 G /usr/lib/xorg/Xorg 206MiB |
| 0 N/A N/A 2157 G /usr/bin/gnome-shell 28MiB |
| 0 N/A N/A 3539 G ...264950234617016841,131072 189MiB |
| 0 N/A N/A 5376 G gnome-control-center 2MiB |
+-----------------------------------------------------------------------------+
NVIDIA Container Toolkitのインストール
コマンドでパッケージリポジトリとGPGキーを設定
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt update
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
INFO[0000] Loading docker config from /etc/docker/daemon.json
INFO[0000] Config file does not exist, creating new one
INFO[0000] Flushing docker config to /etc/docker/daemon.json
INFO[0000] Successfully flushed config
INFO[0000] Wrote updated config to /etc/docker/daemon.json
INFO[0000] It is recommended that the docker daemon be restarted.
/etc/docker/daemon.jsonが無い場合
sudo mkdir -p /etc/docker
sudo vi /etc/docker/daemon.json
/etc/docker/daemon.json
{
"runtimes" : {
"nvidia" : {
"path" : "/usr/bin/nvidia-container-runtime",
"runtimeArgs" : []
}
}
}
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
DockerでGPUが使えるか確認する
docker run --rm --gpus all \
nvcr.io/nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04 \
bash -c "nvidia-smi; nvcc -V"
==========
== CUDA ==
==========
CUDA Version 11.7.1
Container image Copyright (c) 2016-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
This container image and its contents are governed by the NVIDIA Deep Learning Container License.
By pulling and using the container, you accept the terms and conditions of this license:
https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license
A copy of this license is made available in this container at /NGC-DL-CONTAINER-LICENSE for your convenience.
Fri Feb 17 16:47:33 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.78.01 Driver Version: 525.78.01 CUDA Version: 12.0 |
|-------------------------------+----------------------+----------------------+
| 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 NVIDIA GeForce ... Off | 00000000:01:00.0 On | N/A |
| 0% 43C P8 15W / 170W | 380MiB / 12288MiB | 22% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Jun__8_16:49:14_PDT_2022
Cuda compilation tools, release 11.7, V11.7.99
Build cuda_11.7.r11.7/compiler.31442593_0
ノートPCでのGPU活用
ノートPCで動いているUbuntuは省電力(Hybrid Graphics機能)のためにX11のデフォルトがintel gpuになっているのが多いのですが、コマンドで設定を変えることでGPUをフルに活用するようになります。
sudo prime-select nvidia
アプリケーション
Google Chrome
cd /tmp
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
エラーがなければ
google-chrome
terminator
sudo add-apt-repository ppa:mattrose/terminator
sudo apt update
sudo apt install terminator
エラーがなければ
terminator
設定はお好みで
Visual Studio Code
公式サイト から「.deb」 をダウンロードする
curl -L https://go.microsoft.com/fwlink/?LinkID=760868 -o vscode.deb
sudo apt install ./vscode.deb
VLC
sudo add-apt-repository ppa:videolan/stable-daily
sudo apt-get update
sudo apt-get install vlc
エラーがなければ
vlc
GIMP
sudo add-apt-repository ppa:otto-kesselgulasch / gimp
sudo apt-get update
sudo apt install gimp
エラーがなければ
gimp
Inkscape
sudo add-apt-repository ppa:inkscape.dev/stable
sudo apt-get update
sudo apt -y install inkscape
エラーがなければ
inkscape
この記事が気に入ったらサポートをしてみませんか?