[TIL] Ubuntu Settings : July 8, 2020

RE_BROTHER·2020년 7월 10일
0

TIL

목록 보기
23/41
post-thumbnail

Ubuntu install

Ubuntu OS install

혹시나 Ubuntu 설치법을 모르는 경우는 아래를 참고하시어 설치를 진행하시길 바람.

Ubuntu 18.04 LTS 운영체제 설치하는 방법 @Lael's World

Change apt source

  • 다운로드 속도 향상을 위해 repository mirror를 카카오 mirror로 변경
  • /etc/apt/sources.list에 기본 ubuntu mirror 주소가 있고, 이를 vi 명령어를 이용하여 변경
~$ sudo vi /etc/apt/sources.list
:%s/kr.archive.ubuntu.com/mirror.kakao.com
~$ sudo apt-get update

Check Network Interface

Network Adaptor 확인을 위해 net-tools에 포함된 ifconfig를 사용한다. 기본 Ubuntu 18.04 LTS는 포함하고 있지 않으므로, net-tools를 설치한다.
정상적으로 설치가 되었다면 ifconfig -a 로 본인의 네트워크 인터페이스를 확인한다.

~$ sudo apt install net-tools
~$ ifconfig -a
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.197.218  netmask 255.255.255.0  broadcast 192.168.197.255
        inet6 fe80::7393:4006:7019:bb66  prefixlen 64  scopeid 0x20<link>
        inet6 fd44:c6a6:922c:0:79c6:764a:444d:b95e  prefixlen 64  scopeid 0x0<global>
        inet6 fd44:c6a6:922c:0:f0dc:7b5b:e40c:23d2  prefixlen 64  scopeid 0x0<global>
        inet6 fd44:c6a6:922c::489  prefixlen 128  scopeid 0x0<global>
        ether b4:2e:99:04:10:e1  txqueuelen 1000  (Ethernet)
        RX packets 3946410  bytes 550270004 (550.2 MB)
        RX errors 0  dropped 254766  overruns 0  frame 0
        TX packets 114759  bytes 8209523 (8.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 1623  bytes 149090 (149.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1623  bytes 149090 (149.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

해당 Ubuntu의 Network Interface는 enp2s0인 것을 확인하였으니, 고정 IP 설정을 진행한다.

Setting a Static IP Address

네트워크 config 변경을 위해 network-manager-all.yaml 을 열고

~$ sudo vi /etc/netplan/*.yaml

renderer 밑에 아래와 같은 내용을 추가한다. 아래 내용은 IP를 192.168.197.218로 지정한 예

ethernets:
	enp2s0:
    		dhcp6: no
            	addresses: [192.168.197.218]
                gateway4: 192.168.197.1
                nameservers:
                	addresses: [8.8.8.8, 8.8.4.4]

:wq로 저장한 뒤에 네트워크 설정을 시스템에 적용한다.

~$ sudo netplan apply

정상적으로 IP가 변경되었는지 확인하려면 다시 ifconfig -a를 통해 확인이 가능하다.

Nvidia Driver 설치

뻘짓을 많이 하는 구간인데, autoinstall을 통해 편하게 할 수 있다고 한다.

~$ sudo add-apt-repository ppa:graphics-drivers/ppa
~$ sudo apt update
~$ sudo ubuntu-drivers autoinstall
~$ sudo reboot

혹시나 설치 과정에서 기존 설치된 프로그램들과 충돌 발생 시 아래 명령어 입력

~$ sudo apt --purge autoremove nvidia*

의존성 에러가 발생하는 경우는 아래 명령어 입력

~$ sudo apt --fix-broken install
~$ sudo apt-get -f install
~$ sudo apt-get upgrade

Install CUDA toolkit

NVIDIA 공식 홈페이지에서 CUDA toolkit을 GPU 버전과 맞는 버전으로 검색하여 설치하면 된다. 하지만 본인이 특수한 버전을 설치해야 하는 상황이라면 아래처럼 하면 큰일난다. 진짜 큰일난다.
작성일 기준(2020-07-08) cuda-11.0이 설치된다.

~$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.105-1_amd64.deb
~$ sudo dpkg -i cuda-repo-ubuntu1804_10.1.105-1_amd64.deb
~$ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
~$ sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
~$ sudo apt-get update
~$ sudo apt-get -y install cuda

혹시나 cuda-11.0이 설치되어 마음이 아프다거나, 많이 속상한 경우에는 아래와 같이 진행하면 된다.

~$ sudo apt-get install cuda-10.1

정상적으로 설치가 되었다면 진심으로 축하드립니다. cd 명령어를 통해 home 디렉토리로 이동하여 .profile을 띄우고

~$ cd
~$ vi .profile

아래 내용을 추가하고 변경사항을 저장한다.

export PATH=/usr/local/cuda-10.1/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH
~$ source .profile

Install NVIDIA Docker

get.docker.com에 등록되어 있는 스크립트를 바로 로컬에서 실행하는데, 이 스크립트는 기본적으로 docker-ce(Community Edition) repository를 가르키고 있기 때문에 바로 실행시켜주면 됨.

curl -fsSL https://get.docker.com/ | sudo sh

Docker 설치가 완료되면 nvidia-docker 설치

# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker

# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update

# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

# Test nvidia-smi with the latest official CUDA image
docker run --runtime=nvidia --rm nvidia/cuda:10.2-base nvidia-smi

위 코드 실행 후 nvidia-smi가 실행된다면 정상적으로 설치가 된 것이다.

Ubuntu Settings

ubuntu에서 기본적으로 사용할 세팅들을 적어보려 한다.

adduser

~$ sudo adduser <ID>

Docker permission

~$ sudo usermod -aG docker <ID>

Directory permission

~$ sudo chmod -R a+rws [directory]

SSH Server

~$ sudo apt-get update
~$ sudo apt-get install openssh-server

openssh-server 가 정상적으로 설치되었는지 확인.

~$ dpkg -l | grep openssh

정상적으로 설치되어 있다면 아래 스크립트를 통해 ssh를 실행한다.

~$ sudo service ssh start

To be continued...

profile
I hope the All-Rounder Developer & Researcher

0개의 댓글