LoginSignup
9
8

More than 5 years have passed since last update.

DeepLearning 用 GPU 環境構築 (python framework 環境整備編)

Posted at

前提

構築するもの

  • tensolflow 1.8 + gpu用仮想環境
  • pytorch 0.4.0 + gpu用仮想環境

両方の環境に一般的に機械学習で使うであろうパッケージも追加

【備考】:
末尾に tensorflow 1.4 -> 1.5 にアップグレードした際の方法メモあり
末尾に tensorflow 1.5 -> 1.6 にアップグレードした際の方法メモあり

Tensolflow 環境

作った環境と使用した conda コマンド

conda create -n tensorflow-gpu python=3.6
activate tensorflow-gpu
conda install pandas matplotlib jupyter notebook scipy scikit-learn scikit-image h5py seaborn
pip install opencv-python
pip install tensorflow-gpu
  • バージョン指定する場合は tensorflow-gpu==1.4 のように書く
  • h5py は tf.Keras でチェックポイントを書き出す際に必要とされるライブラリ

動作チェック

  • tensorflow は公式インストールガイドに記載された以下のコマンドでチェック(IPythonか何かを起動して実行してください)
  • エラーが起きず、Session コマンド で gpu の情報が出力されればOK
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

pytorch 環境

pytorc のみのインストール手順は公式ホームページにて説明があるので, バージョンが異なる場合はそちらを参照してください.

作った環境と使用した conda コマンド

conda create -n pytorch python=3.6
activate pytorch
conda install pandas matplotlib jupyter notebook scipy scikit-learn scikit-image seaborn
pip install opencv-python

conda install pytorch cuda90 -c pytorch
pip install torchvision

動作チェック

  • 以下のコマンドで Ture が戻ってくればOK
import torch;
print(torch.cuda.is_available())

Appendix

【tensorflow 1.4 -> 1.5 の変更】

tensolflow が 1.5 にバージョンアップしたので cuda 8.0, cuDNN v6 を cuda 9.0, cuDNN v7 を入れなおして
tensolflow の仮想環境で

pip install -U tensorflow-gpu

を実行することで, 無事に tensorflow 1.5.0 がインストールされて gpu も認識された.

【tensorflow 1.5 -> 1.6 の変更】

tensolflow が 1.6 にバージョンアップした.

tensofboard のパッケージ名が変更されているので、以下の順でアップグレードする必要がある.

pip uninstall tensorflow-tensofboard
pip install -U tensorflow-gpu
9
8
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
9
8