Ubuntu 18.04 + DeepLearning4J + Eclipseの環境構築

前提

Ubuntu 18.04
Akitio node (thunderbolt3)
Geforce 1050Ti(10系ならOK)
CUDA 10.0
cuDNN 7.4

手順

もし、NVIDIAドライバーをインストール済みの場合は、NVIDIAドライバとCUDAをアンインストール(削除)する。
既存のNVIDIAドライバとCUDAは削除。https://askubuntu.com/questions/206283/how-can-i-uninstall-a-nvidia-driver-completely
sudo apt-get --purge remove nvidia-*
sudo apt-get --purge remove cuda-*
sudo apt autoremove
sudo rm /etc/X11/xorg.conf
sudo rm /etc/modprobe.d/blacklist-nouveau.conf
echo 'nouveau' | sudo tee -a /etc/modules
sudo apt update

AkitioNodeは接続しておく。

NVIDIAのCUDAインストールガイドに従ってインストール
gccとかも必要なので最初からちゃんと読むこと。
gccなどはこれで一発かも。バージョンに注意。
sudo apt-get install build-essencial

CUDAのインストールは、deb(network)が楽ちん。debとrunではインストール方法が違うので注意。今回はdeb。
キーを照合するときはカレントディレクトリをdeb or pubをダウンロードしたディレクトリにしておく。

念の為、ガイドの通り、Nouveauを無効化しておく(不要かも)
こんな感じでもできる(nogpumanagerを追加)。
sudo vim /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nogpumanager"
 編集したら、
sudo update-grub

ガイドの通りパスを設定。
ホームディレクトリで、
vim .bashrc

こんな感じにしてみた
export PATH="$PATH:/usr/local/cuda-10.0/bin"
export PATH="$PATH:/usr/local/cuda/"#cuDNN用。
export LD_LIBRARY_PATH="/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH"

ここでまだ再起動しない。ここで再起動するとログインループになる。
etc/X11にxconfファイルをつくる。
次のコマンドで自動で作られる。

sudo nvidia-xconf

Deviceのところを次のようにする
Section "Device"#Intel内蔵グラフィック
    Identifier     "intel"
    Driver         "nvidia"
    BusID          "PCI:0:2:0"#ここが大切。これ以外だとループ
EndSection

Section "Device"#1050Ti
    Identifier     "nvidia"
    Driver         "nvidia"
    BusID          "PCI:6:0:0"
EndSection

ここで再起動。


ログインループになっても焦らず、一度、AkitioNodeを外して、もう一度再起動すれば大丈夫。そしてまた設定を確認する。

ログインループにならなければ上出来。

nvidia-smiコマンドでGPU認識を確認。
認識されていなければ、AkitioNodeをちゃんと接続してもう一度再起動してみる。

もし試行錯誤中に画像の解像度がおかしくなっても、再設定で調整すること。
この点は、次期のドライバに期待。。
https://i94025.at.webry.info/201012/article_6.html

cuDNNをインストール

サイトからダウンロード。
 https://developer.nvidia.com/rdp/cudnn-download

次の3つが必要。
cuDNN Runtime Library for Ubuntu18.04 (Deb)
cuDNN Developer Library for Ubuntu18.04 (Deb)
cuDNN Code Samples and User Guide for Ubuntu18.04 (Deb)
サイトの手順(https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html)にあるようにtar圧縮ファイルからもインストールできるが、
このやり方ではサンプルソースファイルがうまくインストールされない。
リンクの手順の通り、インストールする。

eGPUから外部モニタへの出力はさらなる設定が必要だが、機械学習はこのままでもできる。
https://himeji-cs.jp/wiki/Ubuntu%E3%81%A7dGPU/iGPU%E3%81%AE%E3%83%87%E3%83%A5%E3%82%A2%E3%83%AB%E3%83%A2%E3%83%8B%E3%82%BF%E8%A8%AD%E5%AE%9A

DeepLearning4J

現時点(2019/1)では、OracleのJDK8が一番相性がよい。
JDK8をインストールしておく。
javaとjavacのバージョンが8になっているか確認しておく。
sudo add-apt-repository ppa:webupd8team/java
sudo apt update
sudo apt install oracle-java8-installer
sudo apt install oracle-java8-set-default 

defaultの設定がおかしい場合,次のコマンドで設定変更
sudo update-alternatives --config java
sudo update-alternatives --config javac 
 
Gitをインストール
sudo apt-get git 
QuickStartをみてサンプルをGitからダウンロード。
QuickStartの手順に従って コンパイル&インストール。
JDK8以外だとコンパイルエラー。JavaFX関連。

Eclipseをインストール。

Mavenをインストール
sudo apt-get install maven
(mvn --versionでバージョン確認)

EclipseのデフォルトコンパイラーをJDKに。

dl4j-examplesをMavenプロジェクトとしてインポート。
少し時間がかかる。
エラーがJavaFX以外で消えればOK。

parent プロジェクトで、pom.xmlを編集。
<nd4j.backend>nd4j-cuda-10.0-platform</nd4j.backend>

実行するexampleプロジェクトのpom.xmlファイルの依存に、次を追加。
位置としては、dependencyManagement内のところではなく、
dependenciesタグが一番外側にある少し下の方のところで、
deeplearning4j-coreのところとかに書き込んでみる
(https://deeplearning4j.org/docs/latest/deeplearning4j-config-cudnn)

<dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-cuda-10.0</artifactId>
            <version>1.0.0-beta3</version>
 </dependency>

ペアレントでMaven > update project
何かサンプルを実行(例えば、AnimalClassificationなど)

エラーなく動けばOK。


コメント

  1. Vint Ceramic Art | TITNIA & TECHNOLOGY
    Explore an all new “Vint Ceramic worrione Art” sporting100 project on TITNIA & TECHNOLOGY. Our team of sculptors casino-roll.com and artists gri-go.com have created mens titanium wedding bands new and

    返信削除
  2. Youtube, the place personalities have made 1000's of videos exhibiting off games and testing out their bonus rounds. Babylon Jackpots is all of the fun of Cashman Bingo, Egyptian fashion. Give the well-known Big Wheel a spin for credit or jackpots, including the chance for the Grand Jackpot. When you land a bingo image, it is moved to the traditional bingo card and held till minimal of|no much 코인카지노 less than} one line is hit. And when you hit 3 or extra Free Game symbols, it triggers Free Games with wild multipliers. Enjoy the Pharaohs on this thrilling, traditional bingo expertise.

    返信削除

コメントを投稿

このブログの人気の投稿

Keras+TensorFlowを用いた深層学習環境構築(CPU/GPU)