/
build environment.txt
280 lines (257 loc) · 14.2 KB
/
build environment.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
### 使用OS: CentOS 7.6 64-bit
## 0. GUIでの設定事項
# かな漢字と英語を入力できるようにする
# 設定>地域と言語>入力ソース を選択し、英語(US)と日本語(かな漢字)を追加する ※かな漢字以外はダメ
# 入力ソースの切り替えをAlt+Spaceでできるようにする
# 設定>デバイス>キーボード>タイピング を選択し、次の入力ソースをSuper+SpaceからAlt+Spaceに変更
# Ctrl+ALt+T でターミナル起動できるようにする
# 設定>デバイス を選択して一番下の+をクリックし、以下のように設定する
# 名前: terminal
# Command: gnome-terminal
# Shortcut: Ctrl+Alt+T
# ターミナルの背景色の変更(お好みで)
# ターミナルの上側のタブの編集>preferences>プロファイル>色>文字と背景の色 を選択し、
# 「システムのテーマ色を使用する」のチェックを外し、「組み込みのスキーム」を「Tango dark」に設定
## 1. sudo 権限の追加のやり方
$ su - root
$ visudo #実行によりsudoersファイルを開ける
'''
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
'''
↑rootの行の下に以下の1行を追加する
ユーザー名 ALL=(ALL) ALL
$ exit # rootモードからログアウト
## 2. NTFSフォーマットのデバイスのマウント
$ sudo yum install epel-release
$ sudo yum -y install ntfs-3g
$ sudo mount /dev/disk/hoge /mnt/hogehoge
## 3. Emacs の導入
$ sudo yum -y install ncurses-devel gnutls-devel make
$ cd /usr/local/src/
# 2019/5/27時点での最新版は26.2
# term+.elなどが正常に動作しないため、24.3に変更
$ sudo wget http://ftp.jaist.ac.jp/pub/GNU/emacs/emacs-24.3.tar.gz
$ sudo tar zxvf emacs-24.3.tar.gz
$ cd emacs-24.3/
$ ./configure --without-x # 26.3 の場合は--with-mailutils も追加
$ make
$ sudo make install
$ sudo rm -f ../emacs-24.3.tar.gz
# uninstall したいときは、emacs-24.3/直下で $ sudo make uninstall
## 4.HDDのバックアップ
$ sudo dd if=/dev/hoge | gzip -c > /run/media/hoge/hogehoge.img.gz #圧縮しながらバックアップ
$ sudo gzip -dc < /run/media/hoge/hogehoge.img.gz | dd of=/dev/hoge #解凍
## 5. pyenvでAnacnoda環境の構築(anaconda3-5.0.1)
$ curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
'''
WARNING: seems you still have not added 'pyenv' to the load path.
# Load pyenv automatically by adding
# the following to ~/.bashrc:
export PATH="~/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
'''
↑以上のようなメッセージが出るので、~/.bashrcファイルに追記する($ echo '' >> ~/.bashrcを使用)
$ echo 'export PATH="~/.pyenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(pyenv init -)"' >> ~/.bashrc
$ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
$ exec $SHELL -l #.bashrc変更内容を起動したシェルへ反映
$ pyenv update
$ pyenv install -l | grep anaconda #anacondaに絞ってインストール可能なバージョンを検索
$ pyenv install anaconda3-5.0.1
# tensorflow_gpu 1.3.1 に対応しているPython3.6.3が入っている。
# 最新版だと>3.7のため、tensorflowが使えない(2019/5/27時点)
$ pyenv global anaconda3-5.0.1
$ python -V # バージョンが3.6.3になっていることを確認
$ echo 'export PATH="$PYENV_ROOT/versions/anaconda3-5.0.1/bin/:$PATH"' >> ~/.bashrc
$ echo 'export PYENV_VIRTUALENV_DISABLE_PROMPT=1' >> ~/.bashrc #anacondaのバージョンをプロンプトに表示させない
$ exec $SHELL -l
## 6. homeディレクトリ直下のディレクトリを日本語から英語に変更
#ダウンロード、テンプレート、デスクトップなどになっている場合
$ LANG=C xdg-user-dirs-gtk-update
## 7. NVIDIA driverのinstall
# 2019/5/27時点で最新版のdriver
# 使用しているGPU: GeForce GTX 1070
# GPUの種類によってダウンロードするドライバーは違う
# Nvidia社のGPUを使用していることが前提
$ lspci | grep -i nvidia #GPUの確認
$ sudo yum install -y kernel-devel kernel-headers gcc make git pciutils tmux
$ lsmod | grep nouveau # デフォルトでインストールされているnouveauの存在を確認
$ sudo su
$ mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img
$ dracut --omit-drivers nouveau /boot/initramfs-$(uname -r).img $(uname -r)
$ echo 'blacklist nouveau' >> /etc/modprobe.d/modprobe.conf
$ echo 'blacklist nouveau' >> /etc/modprobe.d/nouveau_blacklist.conf
$ reboot
# 再起動後
$ lsmod | grep nouveau # nouveauが存在しないことを確認
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
CUDA toolkitにもNVIDIAドライバーが内包されているため、segmentation faultを起こして起動しなくなってしまう。
CUDAを使うなら、先にドライバーをインストールするのは絶対にやってはいけない!
# https://www.nvidia.co.jp/Download/index.aspx?lang=jpからドライバーをダウンロード
# Linux x64 (AMD64/EM64T) Display Driverのバージョン 430.14 (2019/5/14リリース)
$ cd /tmp
$ wget https://www.nvidia.co.jp/content/DriverDownload-March2009/confirmation.php?url=/XFree86/Linux-x86_64/430.14/NVIDIA-Linux-x86_64-430.14.run&lang=jp&type=TITAN
# 以下のコマンドを実行すると強制的にシングルユーザーモード (CUIでの操作しかできない)に移行するため、事前にユーザー名とパスワードを覚えておくこと!
$ sudo init 3
# シングルユーザーモードに移行後
$ sudo systemctl stop nvidia-driver # 万が一nvidiaドライバーが起動していた場合は停止しておく
$ sudo bash /tmp/NVIDIA_Linux-x86_64-430.14.run
# 以降は指示に従う
1. Install NVIDIA's 32-bit compatibility libraries?
# 32-bitと64-bitのライブラリを混合させていないなら不要
> No
2. An incomplete installation of libglvnd was found. All of the essential libglvnd libraries are present, but one or more optional components are missing. Do you want to install a full copy of libglvnd? This will overwrite any existing libglvnd libraries.
> Install and overwrite existing files
3. Would you like to run the nvidia-xconfig utility to automatically update your X configuration file so that NVIDIA X driver will be used when you restart X? Any pre-existing X configuration file will be backed up.
> Yes
4. Your configuration file has been successufully updated. Installation of the NVIDIA Accelarated Graphics Driver for Linux _x86_64 (version : 430.14) is now complete.
> Yes
$ reboot
# 再起動後
$ nvidia-smi # GPUが認識されていることを確認
# 右上にある、対応しているCUDAのバージョンの最新版を確認(それ以下のバージョンのCUDAならどれでもOKという意味)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
## 8. CUDA-10.0 のinstall
$ pip install tensorflow-gpu==1.13.1
$ cd ~/Downloads
$ wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda-repo-rhel7-10-0-local-10.0.130-410.48-1.0-1.x86_64
$ sudo rpm -ivh cuda-repo-rhel7-10-0-local-10.0.130-410.48-1.0-1.x86_64
$ wget http://developer.download.nvidia.com/compute/cuda/10.0/Prod/patches/1/cuda-repo-rhel7-10-0-local-nvjpeg-update-1-1.0-1.x86_64.rpm
$ sudo rpm -ivh cuda-repo-rhel7-10-0-local-nvjpeg-update-1-1.0-1.x86_64.rpm
$ sudo yum clean all
$ sudo yum install cuda
$ echo 'export PATH="/usr/local/cuda-10.0/bin:$PATH"' >> ~/.bashrc
$ echo 'export LD_LIBRARY_PATH="/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH"' >> ~/.bashrc
$ exec $SHELL -l
$ nvcc -V # CUDAのバージョン確認
## 8.5 NVIDIAドライバーを入れた後にCUDAを入れてしまい、起動しなくなってしまった場合の対処法
# シングルユーザーモードでログインする
# カーネルを選択する際に「e」を押し、linuxで始まる行の最後にsingleを追記して、Ctrl+x
$ nvidia-smi
# NVML: Driver/library version mismatchが表示されるはず(異なるバージョンのドライバが存在するため)
$ dmesg # segmentation faultを起こしていることを確認
$ rpm -qa | grep nvidia
$ rpm -qa | grep cuda
# 二つのコマンドで出て来るライブラリを全てsudo yum remove <PKGNAME>で削除
# 残っている場合があるため、全て消えたことを確認する
$ cd ~/Downloads
$ sudo rpm -ivh cuda-repo-rhel7-10-0-local-nvjpeg-update-1-1.0-1.x86_64.rpm
$ sudo yum clean all
# シングルユーザーモードだとネットワーク接続されていないため、先に/etc/sysconfig/network-scripts/ifcfg-enp10s0ファイルを編集する
# Ethernetで接続する場合(wifiだと設定方法違うかも?)
$ sudo vi /etc/sysconfig/network-scripts/ifcfg-enp10s0
'''
# ファイルの末尾に以下の2行を追記する
DNS1=<プライマリーDNSサーバーアドレス>
DNS2=<セカンダリーDNSサーバーアドレス>
'''
$ sudo systemctl restart network.service
$ curl ifconfig.co # グローバルIPアドレスが表示される(ネットワークに接続されていることを意味する)
$ sudo yum install cuda
$ echo 'export PATH="/usr/local/cuda-10.0/bin:$PATH"' >> ~/.bashrc
$ echo 'export LD_LIBRARY_PATH="/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH"' >> ~/.bashrc
$ exec $SHELL -l
$ nvcc -V # CUDAのバージョン確認
$ cd <NVIDIAドライバーを保存したディレクトリ>
$ sudo bash NVIDIA_Linux-x86_64-430.14.run --uninstall
$ reboot #シングルユーザーモードを終了して再起動する
'''
# 多分これで再起動できるはず。もしかしたらinitial ramdisk imageを再構成する必要があるかも?
$ ls -l /boot/initramfs-$(uname -r).img* # 修復したいカーネルを見つける
$ dracut -f /boot/initramfs-$(uname -r).img $(uname -r)
'''
$ nvidia-smi # CUDAのバージョンに対応するNVIDIAドライバーが存在することを確認
## 9. CuDNN-7.4.2 のinstall
$ cd ~/Downloads
$ wget https://developer.download.nvidia.com/compute/machine-learning/repos/rhel7/x86_64/libcudnn7-7.4.2.24-1.cuda10.0.x86_64.rpm
$ wget https://developer.download.nvidia.com/compute/machine-learning/repos/rhel7/x86_64/libcudnn7-devel-7.4.2.24-1.cuda10.0.x86_64.rpm
$ sudo rpm -ivh libcudnn7-7.4.2.24-1.cuda10.0.x86_64.rpm
$ sudo rpm -ivh libcudnn7-devel-7.4.2.24-1.cuda10.0.x86_64.rpm
$ sudo cp -i /usr/include/cudnn.h /usr/local/cuda/include/
# or $ sudo cp -i /usr/include/cudnn.h /usr/local/cuda-10.0/include/
$ sudo cp -i /etc/alternatives/libcudnn* /usr/local/cuda/lib64/
# or $ sudo cp -i /etc/alternatives/libcudnn* /usr/local/cuda-10.0/lib64/
$ ipython
> import tensorflow # CUDAとCuDNNが認識されていることを確認
> exit
## 10. 有用なpython ライブラリのインストール
$ pip install --upgrade pip
$ pip install umap-learn # Uniform Manifold Approximation and Projectionによる次元削減
$ pip install slackclient # slackと連携
$ pip install impyute # 多重代入法による欠損値補完
$ pip install opencv-python # opencvによる画像処理
$ pip install mlxtend # SVMの分類境界可視化など
$ pip install cupy chainer # Chainerによるdeep learning
$ pip install keras # Kerasによるdeep learning
$ pip install optuna # ハイパーパラメータ最適化
# PyTorchによるdeep learning
$ pip3 install https://download.pytorch.org/whl/cu100/torch-1.1.0-cp36-cp36m-linux_x86_64.whl
$ pip3 install https://download.pytorch.org/whl/cu100/torchvision-0.3.0-cp36-cp36m-linux_x86_64.whl
## 11. PyPiに存在しないリポジトリのダウンロード先(pythonライブラリ)
$ mkdir ~/Documents/pythonlibs
$ echo 'export PYTHONPATH="home/<ユーザー名>/Documents/pythonlibs/:$PYTHONPATH"' >> ~/.bashrc
#絶対パスで指定しないといけない(?)
$ cd ~/Documents/pythonlibs
$ git clone <ダウンロードしたいリポジトリのリンク.git>
e.g. Robust Continuous Clusteringのリポジトリのダウンロード
$ git clone https://github.com/yhenon/pyrcc.git
## 12. Arduino IDEの導入
$ cd ~/Downloads
# https://www.arduino.cc/en/Main/Donate から最新版をダウンロードする
# 2019/5/31現在で1.8.9が最新版
$ tar Jxfv arduino-1.8.9-linux64.tar.xz
$ cd arduino-1.8.9/
$ sudo ./install.sh
$ echo 'alias ard="~/Downloads/arduino-1.8.9/arduino"'>> ~/.bashrc #ardだけでArduinoを実行できるように設定
$ exec $SHELL -l
## 13. ImageJ Fijiの導入
$ cd ~/Downloads
$ wget https://downloads.imagej.net/fiji/latest/fiji-linux64.zip
$ unzip fiji-linux64.zip
$ echo 'alias imj="~/Downloads/Fiji.app/ImageJ-linux64 %F"'>> ~/.bashrc #imjだけでImageJを実行できるように設定
$ exec $SHELL -l
## 14. Fritzingの導入
# fritzing-0.9.2b-18.fc30.src.rpmをダウンロード
# Ubuntuの場合は公式HPにある通りの手順でやればインストールできるはず(未確認)
$ sudo yum install qt5-qtbase-devel
$sudo yum install qt5-qtserialport-devel
# 上手くいかなかったら下を実行する?
'''
sudo rpm -ivh qt5-qtserialport-devel-5.11.3-1.fc29.x86_64.rpm
sudo yum -y install dnf
sudo dnf --refresh install qt5-qtserialport-devel
'''
$ sudo yum install qt5-qtsvg-devel
$ sudo yum install -y quazip-qt5-devel
$ sudo rpmbuild --rebuild fritzing-0.9.2b-18.fc30.src.rpm #ダウンロードしたディレクトリで実行する
$ sudo find / -name '*fritzing*' # rpmファイルがある場所を探す
$ sudo yum install -y google-droid-sans-fonts google-droid-sans-mono-fonts
$ sudo touch /etc/yum.repos.d/naulinux-school.repo
$ vi /etc/yum.repos.d/naulinux-school.repo
# 以下を書き込む。終了時は「:w !sudo tee %」
'''
[naulinux-school]
name=NauLinux School
baseurl=http://downloads.naulinux.ru/pub/NauLinux/6.2/$basearch/sites/School/RPMS/
enabled=0
gpgcheck=1
gpgkey=http://downloads.naulinux.ru/pub/NauLinux/RPM-GPG-KEY-linux-ink
'''
$ sudo yum --enablerepo=naulinux-school install electronics-menu
$ sudo rpm -ivh /root/rpmbuild/RPMS/x86_64/fritzing-0.9.2b-18.el7.x86_64.rpm
$ sudo rpm -ivh /root/rpmbuild/RPMS/x86_64/fritzing-debuginfo-0.9.2b-18.el7.x86_64.rpm
$ Fritzing #起動
# google chromeの導入
$ sudo vi /etc/yum.repos.d/google-chrome.repo
# 以下を書き込む(終了は:wq)
'''
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
'''
$ sudo yum install -y google-chrome-stable