GPU 4 EA Ubuntu 18.04 LTS 서버 설정

1. Nvidia 설치 안내 사이트
https://medium.com/@avinchintha/how-to-install-nvidia-drivers-and-cuda-10-0-for-rtx-2080-ti-gpu-on-ubuntu-16-04-18-04-ce32e4edf1c0

2. 설치 명령어
1) cd Downloads/

2) ls
NVIDIA-Linux-x86_64-418.43.run #output of ls

3) chmod +x NVIDIA-Linux-x86_64-418.43.run
#to get permission to execute the run file

4) sudo ./NVIDIA-Linux-x86_64-418.43.run –no-x-check –no-cc-version-check

3. CUDA 설치
1) down load install file : https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604

2) create a file called blacklist-nouveau.conf in your home directory and add following lines to this file.

blacklist nouveau
options nouveau modeset=0

3) sudo service lightdm stop

4) sudo -i

5) sudo cp /home/avin/blacklist-nouveau.conf /etc/modprobe.d

6) sudo update-initramfs -u

7) exit

8) cd Downloads/

9) md5sum cuda_10.1.168_418.67_linux.run

10) sudo sh cuda_10.1.168_418.67_linux.run

11) export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}

12) nvcc -V

13) reboot

14) sudo gedit ~/.bashrc

15) export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
16) source ~/.bashrc

17) nvcc -V

4. CUDANN 설치
1) 참조 URL : http://blog.naver.com/PostView.nhn?blogId=schmacher&logNo=221383173685&parentCategoryNo=&categoryNo=18&viewDate=&isShowPopularPosts=true&from=search
행
https://goodtogreate.tistory.com/entry/TensorFlowTensorFlow-GPU-2080ti%EB%B2%84%EC%A0%84-%EC%9A%B0%EB%B6%84%ED%88%AC-1804-%EC%84%A4%EC%B9%98-%ED%95%98%EA%B8%B0

2) cuDNN 다운로드 : Download cuDNN v7.5.0 (Feb 25, 2019), for CUDA 10.1 링크에서 cuDNN Library for Linux 클릭하여 cudnn-10.1-linux-x64-v7.5.0.56.tgz 다운로드

    3) tar -zxvf cudnn-10.1-linux-x64-v7.5.0.56.tgz

4) sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-10.1/lib64/

5) sudo cp  cuda/include/cudnn.h /usr/local/cuda-10.1/include/

6) sudo chmod a+r /usr/local/cuda-10.1/include/cudnn.h /usr/local/cuda-10.1/lib64/libcudnn*

7) sudo apt-get install libcupti-dev

5. Anaconda 설치
1) 다운로드 링크 : https://www.anaconda.com/distribution/#linux

2) Linux Python 3.7 버전 다운로드

3) sudo bash Anaconda3-2019.03-Linux-x86_64.sh, 라이센스 동의하고 yes 입력해서 진행

4) 설치 마지막에 yes입력하면 conda 사용 가능

5) conda install python=3.6.5

6) conda create –name tf

7) conda activate tf

5. Tensorflow-GPU 설치
1) sudo apt install python-pip

2) pip install tensorflow-gpu

3) pip install –upgrade tensorflow-gpu

4) pip install jupyter

5) sudo apt install jupyter-core

5) jupyter notebook

6. jupyter가 실행되지 않을 때
1) 참고 URL : http://taewan.kim/tutorial_manual/dl_pytorch/02/install/linux_env/

2) sudo apt update

3) sudo apt install software-properties-common

4) sudo add-apt-repository ppa:deadsnakes/ppa

5) sudo apt install python3.7

6) python3.7 -V

7) sudo apt update

8) sudo apt install build-essential zlib1g-dev libncurses5-dev \
       libgdbm-dev libnss3-dev libssl-dev libreadline-dev \
       libffi-dev wget

9) wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz

10) tar -xf Python-3.7.2.tar.xz

11) cd Python-3.7.2

12) ./configure –enable-optimizations

13) sudo make altinstall

14) python3.7b -V

15) source activate tf

16) conda install -y pytorch-cpu torchvision-cpu -c pytorch

17) conda install -y -c derickl torchtext

18) conda install -y scikit-learn

19) conda install -y matplotlib

20) conda install -y pandas

7. POCA Server 설치

1) sudo apt install -y cmake build-essential

2) cd readyfor   

3) pip install -r requirements.txt

8. Anaconda 삭제

1) 참조링크 : https://medium.com/@rahulkhot_34158/install-and-un-install-anaconda-on-ubuntu-18-04-80a89d6333bc

2) rm -rf ~/anaconda3

3) sudo gedit ~/.bashrc

4) Remove contents anaconda setting from the above file.

5) rm -rf ~/.condarc ~/.conda ~/.continuum

9. python 3.6 설치
1) sudo add-apt-repository ppa:jonathonf/python-3.6

2) sudo apt-get update

3) sudo apt-get install python3.6

4) sudo rm /usr/bin/python
   sudo update-alternatives –install /usr/bin/python python /usr/bin/python2 1
   sudo update-alternatives –install /usr/bin/python python /usr/bin/python3 2

5) sudo update-alternatives –config python

10. Server 설치

1) coreapi 설치 : pip install coreapi==2.3.3 

2) Django 2.1.7 설치 : pip3 install Django==2.1.7

pip3 install django-rest-swagger==2.2.0

pip3 install djangorestframework==3.9.1

3) pip install drf-yasg==1.14.0

4) pip install httpie==1.0.2

5) pip install openapi-codec==1.3.2

6) pip install cryptography==2.6.1

7) pip install django-suit==0.2.26

8) pip install django-admin-rangefilter==0.3.14

9) pip install DateTimeRange==0.6.1

10) pip install numpy==1.16.4

11) pip install Keras==2.2.4

12) pip install tensorflow-gpu==1.13.1

13) pip install opencv-python==4.1.0.25

14) pip install dlib==19.17.0

15) pip install pandas==0.24.2

16) pip install imread==0.7.1

17) pip install Pillow==4.0.0

18) pip install scipy==0.18.1

19) pip install –upgrade tensor flow

20) cd ./roborus-pkg && python setup.py sdist && pip install dist/roborus-pkg-1.0.tar.gz
위의 명려이 실행되지 않을 경우 : cd roborus-pkg/dist/    pip install roborus-pkg-1.0.tar.gz

21) python manage.py makemigrations && python manage.py migrate

22) python manage.py runserver 0:9000

11. 서버 자동실행 설정
1) nvm 설치 : wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

2) nodejs 설치 : sudo apt install nodejs   sudo apt install npm   nodejs -v  source ~/.profile 

3) pm2 설치 : npm install pm2 -g    pm2 version

4) pm2.jason 파일 내용 변경
“cwd”: “/home/ai-server/pocaserver-devel”,

5) pm2 실행 : pm2 start pm2.json
      pm2 startup
      pm2 save

1. Nvidia 설치 안내 사이트
https://medium.com/@avinchintha/how-to-install-nvidia-drivers-and-cuda-10-0-for-rtx-2080-ti-gpu-on-ubuntu-16-04-18-04-ce32e4edf1c0

2. 설치 명령어
1) cd Downloads/

2) ls
NVIDIA-Linux-x86_64-418.43.run #output of ls

3) chmod +x NVIDIA-Linux-x86_64-418.43.run
#to get permission to execute the run file

4) sudo ./NVIDIA-Linux-x86_64-418.43.run –no-x-check –no-cc-version-check

3. CUDA 설치
1) down load install file : https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604

2) create a file called blacklist-nouveau.conf in your home directory and add following lines to this file.

blacklist nouveau
options nouveau modeset=0

3) sudo service lightdm stop

4) sudo -i

5) sudo cp /home/avin/blacklist-nouveau.conf /etc/modprobe.d

6) sudo update-initramfs -u

7) exit

8) cd Downloads/

9) md5sum cuda_10.1.168_418.67_linux.run

10) sudo sh cuda_10.1.168_418.67_linux.run

11) export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}

12) nvcc -V

13) reboot

14) sudo gedit ~/.bashrc

15) export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
16) source ~/.bashrc

17) nvcc -V

4. CUDANN 설치
1) 참조 URL : http://blog.naver.com/PostView.nhn?blogId=schmacher&logNo=221383173685&parentCategoryNo=&categoryNo=18&viewDate=&isShowPopularPosts=true&from=search
행
https://goodtogreate.tistory.com/entry/TensorFlowTensorFlow-GPU-2080ti%EB%B2%84%EC%A0%84-%EC%9A%B0%EB%B6%84%ED%88%AC-1804-%EC%84%A4%EC%B9%98-%ED%95%98%EA%B8%B0

2) cuDNN 다운로드 : Download cuDNN v7.5.0 (Feb 25, 2019), for CUDA 10.1 링크에서 cuDNN Library for Linux 클릭하여 cudnn-10.1-linux-x64-v7.5.0.56.tgz 다운로드

    3) tar -zxvf cudnn-10.1-linux-x64-v7.5.0.56.tgz

4) sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-10.1/lib64/

5) sudo cp  cuda/include/cudnn.h /usr/local/cuda-10.1/include/

6) sudo chmod a+r /usr/local/cuda-10.1/include/cudnn.h /usr/local/cuda-10.1/lib64/libcudnn*

7) sudo apt-get install libcupti-dev

5. Anaconda 설치
1) 다운로드 링크 : https://www.anaconda.com/distribution/#linux

2) Linux Python 3.7 버전 다운로드

3) sudo bash Anaconda3-2019.03-Linux-x86_64.sh, 라이센스 동의하고 yes 입력해서 진행

4) 설치 마지막에 yes입력하면 conda 사용 가능

5) conda install python=3.6.5

6) conda create –name tf

7) conda activate tf

8) export PATH=”/home/ai-server/anaconda3/bin:$PATH”

9) source ~/.bashrc

10) conda update conda

11) conda update anaconda

12) conda update python

13) conda update –all

5. Tensorflow-GPU 설치
1) sudo apt install python-pip

2) pip install tensorflow-gpu

3) pip install –upgrade tensorflow-gpu

4) pip install jupyter

5) sudo apt install jupyter-core

5) jupyter notebook

6. jupyter가 실행되지 않을 때
1) 참고 URL : http://taewan.kim/tutorial_manual/dl_pytorch/02/install/linux_env/

2) sudo apt update

3) sudo apt install software-properties-common

4) sudo add-apt-repository ppa:deadsnakes/ppa

5) sudo apt install python3.7

6) python3.7 -V

7) sudo apt update

8) sudo apt install build-essential zlib1g-dev libncurses5-dev \
       libgdbm-dev libnss3-dev libssl-dev libreadline-dev \
       libffi-dev wget

9) wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz

10) tar -xf Python-3.7.2.tar.xz

11) cd Python-3.7.2

12) ./configure –enable-optimizations

13) sudo make altinstall

14) python3.7b -V

15) source activate tf

16) conda install -y pytorch-cpu torchvision-cpu -c pytorch

17) conda install -y -c derickl torchtext

18) conda install -y scikit-learn

19) conda install -y matplotlib

20) conda install -y pandas

7. keras 설치

1) conda install keras-gpu

2) jupyter notebook

3) run MNIST example

import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.layers import Flatten,  MaxPooling2D, Conv2D
from keras.callbacks import TensorBoard

(X_train,y_train), (X_test, y_test) = mnist.load_data()

X_train = X_train.reshape(60000,28,28,1).astype(‘float32’)
X_test = X_test.reshape(10000,28,28,1).astype(‘float32’)

X_train /= 255
X_test /= 255

n_classes = 10
y_train = keras.utils.to_categorical(y_train, n_classes)
y_test = keras.utils.to_categorical(y_test, n_classes)

model = Sequential()
model.add(Conv2D(32, kernel_size=(3,3), activation=’relu’, input_shape=(28,28,1)) )
model.add(Conv2D(64, kernel_size=(3,3), activation=’relu’))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation=’relu’))
model.add(Dropout(0.5))
model.add(Dense(n_classes, activation=’softmax’))

model.compile(loss=’categorical_crossentropy’, optimizer=’adam’, metrics=[‘accuracy’])

tensor_board = TensorBoard(‘./logs/LeNet-MNIST-1’)

model.fit(X_train, y_train, batch_size=128, epochs=15, verbose=1,
  validation_data=(X_test,y_test), callbacks=[tensor_board])

tensorboard –logdir=./logs –port 6006

http://user-MS-&c06:6006

8. VNC 서버 설치
1) 참조 사이트 : https://junhyeok.tistory.com/690

2) 설정-공유-화면공유 -> 암호화 필요-암호입력
                            -> 유선연결1 -> 켬

3) sudo apt install dconf-editor

4) dconf-editor 실행

5) /org/gnome/desktop/remote-access 항모겡서 require-encryption 옵션을 꺼준다.

6) sudo nano /etc/systemd/system/vncserver@.service

[Unit]
Description=Start TightVNC server at startup
After=syslog.targetnetwork.target

[Service] 
Type=forking 
User=ai-server
PAMName=login 
PIDFile=/home/ai-server/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1 
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280×800 :%i 
ExecStop=/usr/bin/vncserver -kill :%i 

[Install] 
WantedBy=multi-user.target

7) sudo gedit .vnc/xstartup

#!/bin/bash 

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
x-window-manager &

gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &

9. xrdp 설치
# xrdp 설치
1) sudo apt-get install xrdp

2) sudo apt-get update

# xrdp 설치
3) sudo apt-get install mate-core mate-desktop-environment mate-notification-daemon

# xrdp에서 desktop environment 사용하도록 설정
4) sudo sed -i.bak ‘/fi/a #xrdp multiple users configuration \n mate-session \n’ /etc/xrdp/startwm.sh

5) sudo nano /etc/xrdp/xrdp.ini
[globals]의 port=3389 이 부분을 2.2.2에서 설정한 포트 값으로 변경후 저장

6) service xrdp restart

7) sudo ufw allow 3389/tcp

10. POCA Server 설치

1) sudo apt install -y cmake build-essential

2) cd readyfor   

3) pip install -r requirements.txt

11. Anaconda 삭제

1) 참조링크 : https://medium.com/@rahulkhot_34158/install-and-un-install-anaconda-on-ubuntu-18-04-80a89d6333bc

2) rm -rf ~/anaconda3

3) sudo gedit ~/.bashrc

4) Remove contents anaconda setting from the above file.

5) rm -rf ~/.condarc ~/.conda ~/.continuum

12. python 3.6 설치
1) sudo add-apt-repository ppa:jonathonf/python-3.6

2) sudo apt-get update

3) sudo apt-get install python3.6

4) sudo rm /usr/bin/python
   sudo update-alternatives –install /usr/bin/python python /usr/bin/python2 1
   sudo update-alternatives –install /usr/bin/python python /usr/bin/python3 2

5) sudo update-alternatives –config python

13. Server 설치

1) coreapi 설치 : pip install coreapi==2.3.3 

2) Django 2.1.7 설치 : pip3 install Django==2.1.7

pip3 install django-rest-swagger==2.2.0

pip3 install djangorestframework==3.9.1

3) pip install drf-yasg==1.14.0

4) pip install httpie==1.0.2

5) pip install openapi-codec==1.3.2

6) pip install cryptography==2.6.1

7) pip install django-suit==0.2.26

8) pip install django-admin-rangefilter==0.3.14

9) pip install DateTimeRange==0.6.1

10) pip install numpy==1.16.4

11) pip install Keras==2.2.4

12) pip install tensorflow-gpu==1.13.1

13) pip install opencv-python==4.1.0.25

14) pip install dlib==19.17.0

15) pip install pandas==0.24.2

16) pip install imread==0.7.1

17) pip install Pillow==4.0.0

18) pip install scipy==0.18.1

19) pip install –upgrade tensor flow

20) cd ./roborus-pkg && python setup.py sdist && pip install dist/roborus-pkg-1.0.tar.gz
위의 명려이 실행되지 않을 경우 : cd roborus-pkg/dist/    pip install roborus-pkg-1.0.tar.gz

21) python manage.py makemigrations && python manage.py migrate

22) python manage.py runserver 0:9000

14. 서버 자동실행 설정
1) nvm 설치 : wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

2) nodejs 설치 : sudo apt install nodejs   sudo apt install npm   nodejs -v  source ~/.profile 

3) pm2 설치 : npm install pm2 -g    pm2 version

4) pm2.jason 파일 내용 변경
“cwd”: “/home/ai-server/pocaserver-devel”,

5) pm2 실행 : pm2 start pm2.json
      pm2 startup
      pm2 save

Leave a Comment