LoginSignup
0
0

More than 5 years have passed since last update.

深層学習用サーバセットアップ

Posted at

Ubuntu16.04

ゲートウェイサーバ

ユーザ名と公開鍵をゲートウェイサーバ管理者に送り、アカウントを作ってもらう。

#秘密鍵・公開鍵の作成
$ ssy-keygen -t rsa

GPUサーバ

GPUサーバ管理者にアカウントを作ってもらう。

#ログインしてパスワードの設定
$ passwd

シェル

強力な補完を使いたいのでzshをインストール。
他にはfishもよいが、command1 && command2が使えなかったりfor文の書式がbash、zshと異なり慣れなかった。

#インストール
$ sudo apt install zsh
$ chsh -s /usr/bin/zsh

CUDA

バージョンを確認、CUDA:8、cuDNN:6

$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61

$ cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
#define CUDNN_MAJOR    6

systemのPython

$ python3 -V
Python 3.5.2
$ python3 -m venv system35
The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt-get install python3-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/home/natsuki/system35/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

venvが入っていない

systemのpython2.7からはchainerやtensorflowがセットアップされていることが確認できる
確認したサンプルプログラム/usr/local/torch7/convnet-benchmarks/chainer/alex.py

pyenv

systemの環境を汚さずにユーザディレクトリにライブラリを入れたりPythonのバージョンをあげたりAnacondaを入れたりしたい。

#インストール
$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv

~/.zshrcに以下を追記

~/.zshrc
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

source ~/.zshrcして現在のインタプリタでも有効にする。

Anaconda

pyenvで入るAnacondaとPythonのバージョン対応表

anaconda3-5.0.0 anaconda3-5.1.0 anaconda3-5.2.0 anaconda3-5.3.0
3.6.8 3.6.4 3.6.5 3.7.0

以下のようにビルド名を確認してCUDAのバージョンに対応するtensorflow-gpuを探す。

$ conda search tensorflow-gpu

image.png

Python3.7系では動かないことが確認できたので、Python3.6.8のanaconda3-5.0.0をインストールする。

$ pyenv install anaconda3-5.0.0
$ pyenv global anaconda3-5.0.0

以下のようにバージョンとビルドを指定してtensorflow-gpuをインストールする。

$ conda install tensorflow-gpu=1.2.1=py36cuda8.0cudnn6.0_0

GPUが見えているか確認

from tensorflow.python.client import device_lib
device_lib.list_local_devices()

image.png

備考

$ pip install tensorflow-gpu

では共有ライブラリlibcublas.soの依存が解決できなかった。condaは便利。

謝辞

研究室選びの相談に乗ってくれた友人と予算を引っ張ってきている先生方に感謝。

0
0
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
0
0