2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ubuntu 20.04 Server インストールとディープラーニング設定

Last updated at Posted at 2020-05-05

タイトルの通りです。

LXCのコンテナ内からディープラーニングする場合は ホスト側での作業 を行った後に、コンテナ内で下記の作業を apt-get install nvidia-headless-440 を除いて行うとよい。

インストール

  1. http://cdimage.ubuntu.com/ubuntu-server/focal/daily-live/current/focal-live-server-amd64.iso からインストールDVDをダウンロードし、USBスティックかDVDに焼く
  2. インストーラーで日本語を選べないが、キーボードの配置を選ぶ項目が最初から2番めくらいにあるため必ず「Japanese」を選ぶ。そうじゃないと後で辛い。それ以外はデフォルトの選択肢を選んでおけばよい。以下の作業は全部rootで行う(sudoを使うなど)

サーバー起動後の設定

/etc/apt/apt.conf.d/00myconf
APT::Default-Release "focal";
APT::Install-Recommends 0;
APT::Get::Purge 1;
  1. 余計なパッケージが入らないように上記のファイルを作る
  2. 時刻(タイムゾーン)がおかしいので dpkg-reconfigure tzdata でタイムゾーンを設定する
  3. (内蔵の時計が日本時間ではなくUTCなら timedatectl set-local-rtc true する)
  4. focal-proposed がデフォルトで有効になっているので /etc/apt/sources.list.d/proposed.list を編集する。またfocal-backportsも有効なので、要らなければ /etc/apt/sources.list を編集する。
  5. /etc/fstab を編集してマウントオプションに noatime,lazytime を付けておくとアクセスが少し速くなる。仮想環境で動作しているなら discard を付けても良い
  6. 言語パックが全く入っていないので apt-get install language-pack-en language-pack-ja でインストールする
  7. いらないパッケージ( cloud-guest-utils
    cloud-init
    cloud-initramfs-copymods
    cloud-initramfs-dyn-netconf
    eatmydata
    lxd-agent-loader
    plymouth
    plymouth-theme-ubuntu-text
    snapd など)を apt-get purge で削除する。その後に apt-get --purge autoremove する

NVIDIA ドライバなどのインストール

  1. GUIを用いずNVIDIA GPUを用いた計算だけサーバーにさせる場合 apt-get install nvidia-headless-440 をインストールする。GUIも用いる場合代わりに nvidia-driver-440 をインストールする。440 よりも新しいドライババージョンが必要なら https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa から準公式ドライバーをインストールする。NVIDIAのウェブサイトから持ってきては絶対にいけない
  2. nvidia-smi は apt-get install nvidia-utils-440 で入る。ドライバのバージョンと揃えること

Python3 の最低限のインストール

  1. apt-get install python3-pip python3-setuptools python3-wheel python3-numpy python3-yaml python3-six python3-future python3-requests python3-matplotlib python3-pil python3-h5py python3-graphviz python3-pydot

Pytorch インストール

PyTorch は内部にCUDAライブラリなどを含みGPUがある場合も無い場合も同じパッケージで動作するので pip3 install torch torchvision とすればよい

TensorFlow インストール

CUDA ライブラリインストール

Google のTensorflowは内部にCUDAライブラリを含んでいないため、動作させるためには自分でCUDAライブラリをインストールする必要がある。TensorFlow 2.1, 2.2あたりはCUDA 10.1 をインストールする必要があり、たまたま Ubuntu 20.04 の標準アーカイブに入っているから apt-get install nvidia-cuda-dev libgomp1 とすればよい(libgomp1 はtensorflowが用いる)

libcudnn のインストール

  1. wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libcudnn7_7.6.5.32-1+cuda10.1_amd64.deb
  2. dpkg -i libcudnn7_7.6.5.32-1+cuda10.1_amd64.deb

TensorFlow が依存するPythonパッケージのインストール

apt-get install python3-scipy python3-sklearn python3-skimage python3-opencv python3-protobuf python3-termcolor python3-wrapt python3-werkzeug python3-markdown python3-google-auth python3-cache-tools python3-requests-oauthlib

TensorFlow のインストール

pip3 install tensorflow-gpu

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?