This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

*/

Linux screen/byobu

Linux 터미널에서 멀티세션이나 혹은 터미널 연결이 끊긴 후에도 계속 서버에 작업을 시키고자 할 때 주로 사용하며, 이전의 접속 환경을 유지하며 연속된 작업을 하고자 할 때 편리함.

  • 설치 방법
    $ sudo apt-get install byobu
  • 실행
    $ byobu
  •   실행후 명령
    • screen 실행후의 명령어는 Ctrl-a로 시작
      Ctrl-a, 숫자 : 숫자에 해당하는 창으로 이동
      Ctrl-a, a : 바로 전 창으로 이동
      Ctrl-a, A : 현재 창의 Title을 수정
      Ctrl-a, c : (create) 새로운 쉘이 생기면서 그 쉘로 이동
      Ctrl-a, C : Clear Screen
      Ctrl-a, d : (detach) 현재 작업을 유지하면서 screen 세션에서 빠져나옴. 세션은 살아있음
      Ctrl-a, D : (detach) screen 세션에서 빠져나오고 로그 아웃
      Ctrl-a, k : 현재 윈도우를 kill, destroy
      Ctrl-a, n : (next) 다음 창으로 이동
      Ctrl-a, p : (previous) 이전 창으로 이동
      Ctrl-a, w : 창 리스트 보여주기
      Ctrl-a, x : lock screen
      Ctrl-a, ' : 창번호 또는 창이름으로 이동
      Ctrl-a, " : 창번호를 보여줌
      Ctrl-a, esc : Copy 모드로 전환. Copy 모드에서는 vi의 이동키로 이동 가능
      Crtl-a, [ 커서 이동을 할 수 있고 특정 블럭을 복사하는 기능으로 사용
      먼저 시작 위치에서 space 바를 누르고 끝 위치에서 space 바를 누르면 해당 부분이 buffer로 복사
      Ctrl-a, ] : buffer의 내용을 stdin으로 입력.
      Ctrl-a, :(콜론) : 명령행 모드로 전환
      exit : screen 의 쉘상에서 exit 를 입력하고 엔터를 하면 세션이 완전히 종료
  • 빌드 타임이 아주 긴 작업이나 오랜 프로세스 시간이 필요한 어플리케이션을 돌릴때 byobu실행 후 쉘안에서 수행 시키고 Ctrl-a, d 로 세션을 빠져나와도 작업중인 프로세스가 종료되지않고 계속 진행된다.

TensorFlow 개발 환경 구축하기(Docker)

TensorFlow 개발 환경 구축하기(Docker)

필요조건

  • 64-bit desktops or laptops
  • Ubuntu 16.04 or higher

TensorFlow 종류 선택

  • CPU 만 사용 :  NVIDIA GPU가 없는 경우
  • GPU 지원 : 텐서플로우 프로그램은 일반적으로 CPU보다 GPU에서 훨씬 빠르게 실행됨.

GPU지원 타입으로 텐서플로우 실행시 필요한 NVIDIA  소프트웨어

  • CUDA® Toolkit 9.0: NVIDIA 설명서 참조. CUDA 경로 이름을 LD_LIBRARY_PATH 환경 변수에 추가
  • cuDNN v7.0. : NVIDIA 설명서 참조.   설명서 대로 CUDA_HOME 환경 변수 만들었는 확인
  • 소스에서 빌드하기위한 CUDA Compute Capability 3.0 이상 및 당사 바이너리 용 3.5 이상의 GPU 카드
  • libcupti-dev library

Docker 설치

  • Community Edition(CE) 와 Enterprise Edition(EE) 두 종류의 에디션이 존재
  • 설치방법으로Docker’s  Repository 를 이용하거나 Manually 설치 할 수 있음

Repository를 이용한 설치

Docker CE를 설치하기 전에 Docker Repository를 설정하고, 그 다음에  Docker를 설치하고 업데이트 할 수 있다.

Ropository 셋업

  • apt package 인덱스를 업데이트
  • $ sudo apt-get update
  • HTTPS를 통해 저장소를 사용할 수 있도록 패키지를 설치
  • $ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
  • Docker의 official GPG key를 추가
  • $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  • Repository  추가
  • $ sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable" 

  Docker CE 설치

  • apt package 인덱스 업데이트
  • $ sudo apt-get update
  • Docker CE 마지막 버젼 install
  • $ sudo apt-get install docker-ce

Root 유저가 아닐 경우 추가 작업

  • sudo 명령없이 docker를 수행할 수 있도록 docker 그룹을 생성한다.
  • $ sudo groupadd docker 
  • 내 user id를 docker 그룹에 등록한다.
  • $ sudo usermod -aG docker $USER  

Boot 시 Docker를 바로 사용할 수 있도록 설정

  •   systemd에 등록
  • $ sudo systemctl enable docker  
  • 제대로 됐는지 확인하기 위해 logout후 login 후  sudo 없이 실행. 다음과 같이 나오면 성공
  • $ docker run hello-world
    
    Hello from Docker!
     This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
      1. The Docker client contacted the Docker daemon.
      2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
         (amd64)
      3. The Docker daemon created a new container from that image which runs the
         executable that produces the output you are currently reading.
      4. The Docker daemon streamed that output to the Docker client, which sent it
         to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
      $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
      https://hub.docker.com/
    
    For more examples and ideas, visit:
    
    https://docs.docker.com/engine/userguide/
  • docker version 확인
  • $ docker version
    Client:
     Version:      18.03.1-ce
     API version:  1.37
     Go version:   go1.9.5
     Git commit:   9ee9f40
     Built:        Thu Apr 26 07:17:20 2018
     OS/Arch:      linux/amd64
     Experimental: false
     Orchestrator: swarm
    
    Server:
     Engine:
      Version:      18.03.1-ce
      API version:  1.37 (minimum version 1.12)
      Go version:   go1.9.5
      Git commit:   9ee9f40
      Built:        Thu Apr 26 07:15:30 2018
      OS/Arch:      linux/amd64
      Experimental: false
    
참조 :

Ubuntu에 GPU 지원 TensorFlow 설치하기 - 1

리눅스 머신에 TensorFlow를 설치하기 위해서는 다음과 같은 기본 조건이 필요

  • 64-bit desktops or laptops
  • Ubuntu 16.04 or higher

GPU 지원 TensorFlow를 실행시키기 위한 NVIDIA 요구사항

      • /usr/local/cuda-9.1/lib64 을 LD_LIBRARY_PATH에 추가
      $ export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  • cuDNN SDK v7. For details, see NVIDIA's documentation. CUDA_HOME 환경 변수를 만들 었는지 확인 필요.
  • GPU drivers supporting your version of the CUDA Toolkit.
  • GPU card with CUDA Compute Capability 3.0 or higher for building from source and 3.5 or higher for our binaries. See NVIDIA documentation for a list of supported GPU cards.
  • GPU card with CUDA Compute Capability 3.0 or higher
  • The libcupti-dev library,
  • CUDA Toolkit >= 9.0:
    $ sudo apt-get install cuda-command-line-tools 
    and add its path to your LD_LIBRARY_PATH environment variable:
    $ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}/usr/local/cuda/extras/CUPTI/lib64
    For CUDA Toolkit <= 7.5 do:
    $ sudo apt-get install libcupti-dev 
Docker 에 TensorFlow 설치하기

Reference

Ububtu 16.04 에 NVIDIA 드라이버 설치

  • 다운로드 전에 NVIDIA Driver명칭을  www.nvidia.com/drivers 에서 확인. 다음과 같이 드라이버 설치

    • $ sudo add-apt-repository ppa:graphics-drivers/ppa
    • $ sudo apt-get update
    • $ sudo apt-get install nvidia-390
    • * GTX 950의 경우 nvidia-390, 그래픽카드 모델에 따라 nvidia-390대신 해당 드라이버 이름을 사용해야함.
    • $ sudo reboot
  • version 확인
    • $ cat /proc/driver/nvidia/version
  • 설치된 nvidia드라이버 삭제할 경우
    • $ dpkg –get-selections | grep nvidia            // 리스트 항목을 개별적으로 apt-get remove ??? 으로 삭제
    • $ sudo apt-get purge nvidia-*                       // nvidia로 시작하는 설치된 모든것 삭제

vector에 할당한 메모리 해제 방법


new로 할당한 객체를 제대로 해제하지 않으면 메모리 릭이 발생.
다음과 같이 해제하여 메모리 릭 방지.



std::vector<strFileInfo*>  FileList;

// new 메모리할당 및 추가
strFileInfo* ifo = new strFileInfo();
:
FileList.push_back(ifo );

// 해제시 erase() 수행후 delete
strFileInfo *ifo = *iter;
iter = FileList.eraseiter );
delete ifo;


로마자 (알파, 베타, 감마, 델타, .., 오메가), 그리스 문자

ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ 
αβγδεζηθικλμνξοπρστυφχψω

アルファ,ベータ,ガンマ,デルタ,...
그리스문자
한글
영어
日本語
Α α
알파
Alpha
アルファ
Β β
베타
Beta
ベータ
Γ γ
감마
Gamma
ガンマ
Δ δ
델타
Delta
デルタ
Ε ε
엡실론
Epsilon
イプシロン
Ζ ζ
제타
Zeta
ジータ
Η η
에타
Eta
イータ
Θ θ
세타
Theta
シータ
Ι ι
이오타 (요타)
Iota
イオタ
Κ κ
카파
Gamma
カッパ
Λ λ
람다
Lamda
ラムダ
Μ μ
Mu
ミュー
Ν ν
Nu
ニュー
Ξ ξ
크시
Xi
クシー
Ο ο
오미크론
Omicron
オミクロン
Π π
파이
Pi
パイ
Ρ ρ
Rho
ロー
Σ σ
시그마
Sigma
シグマ
Τ τ
타우
Tau
タウ
Υ υ
입실론
Upsilon
ウプシロン
Φ φ
파이
Phi
ファイ
Χ χ
카이
Chi
カイ
Ψ ψ
프사이
Psi
プサイ
Ω ω
오메가
Omega
オメガ

참고 :

WinInet을 이용하여 http 서버에서 파일 다운로드 받기

Header
   wininet.h
API
   InternetOpen( )                     - WinInet 함수들을 초기화
   InternetConnect( )                 - Http혹은 FTP 사이트 연결
   HttpOpenRequest( )               - HTTP Request handle 생성
   HttpSendRequest( )                - HTTP 서버로 Request 전달
   HttpQueryInfo( )                    - 파일을 전체크기
   InternetQueryDataAvailable( )   - 서버가 바로보낼수 있는 크기를 알려줌
   InternetReadFile( )                  - 서버로부터 지정된 크기만큼 파일을 읽어옴
   InternetCloseHandle( )             - 열려있는 핸들을 닫음


예제
#include < wininet.h >
  HINTERNET hOpen, hConnect, hReq;
  LPCSTR postheader = "Content-Type: application/x-www-form-urlencoded";
  int port = 80;

  hOpen = InternetOpen("SimplePost", INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
  if(hOpen == NULL)  {
     return -1;
  }
  // "127.0.0.1"대신에 다운받을 화일이 있는 서버주소를 입력 
  hConnect = InternetConnect(hOpen, "127.0.0.1", port, 0, 0, INTERNET_SERVICE_HTTP, 0, 0);
  hReq = HttpOpenRequest(hConnect, "POST", "/test.bin", "HTTP/1.1", 0, 0, INTERNET_FLAG_NO_CACHE_WRITE, 0);
  HttpSendRequest(hReq, postheader, lstrlen(postheader), NULL, 0);

  DWORD dwRead = 0;
  DWORD Size;
  CHAR Data[1025] = "";
  FileOpen("Filename");
  do 
  {     // 다운받는화일의 나머지 크기 얻어오기
     InternetQueryDataAvailable(hReq,&Size,0,0);     // 남은 크기가 1024보다 크면 1024로 고정
     if(Size>1024) Size = 1024;
     InternetReadFile(hReq, (LPVOID)Data, Size, &dwRead);
     if(dwRead) {
        Data[dwRead] = 0x00;
        FileWrite(Data, Size);
     }
  } while(dwRead != 0);  //읽어온 데이터의 크기가 0이 아니면 계속 반복

  FileClose();

  InternetCloseHandle(hConnect);
  InternetCloseHandle(hOpen);

  hConnect = NULL;
  hOpen = NULL;

// FileOpen(), FIleWrite(), FIleClose()함수 별도

Linux Xubuntu에 CommonAPI C/C++ 개발환경 구축하기

Xubuntu 16.04 환경(설치방법)에서 GENIVI의 CommonAPI C/C++ 개발 환경을 구축해 보자.
  • JAVA 설치(Version 8)
    • Oracle Site(www.oracle.com)에서 JAVA SE 8 8u161 다운로드
    • 다운로드페이지에서 Accept License Agreement 체크
    • 64bit 버젼 다운로드(jdk-8u161-linux-x64.tar.gz)
    • Xubuntu에 기본적으로 설치되어져있는 firefox에서 다운로드 받으면 ~/Downloads폴더에 저장된다.
    • Downloads 폴더로 이동후 압축을 해제한다.
      • $ tar -xvzf jdk-8u161-linux-x64.tar.gz
    • 관리자 권한으로 압축해제된 파일들을 /usr/local 폴더 아래로 이동시킨다.
      • $ sudo mv jdk1.8.0_161 /usr/local
    • 앞에서 설치한 파일들을 사용할 수 있도록 다음과 같이 환경 변수를 설정한다.
      • $ sudo vi /etc/profile
        • JAVA_HOME=/usr/local/jdk1.8.0_161
        • PATH=$PATH:$JAVA_HOME/bin
        • CLASS_PATH=.:$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
        • export JAVA_HOME PATH CLASS_PATH
    • 다음과 같이 변경된 profile을 적용한다.
      • $ source /etc/profile

    • g++ Compiler를 설치 및 버젼 확인.
      • $ sudo apt-get install g++
      • $ g++ --version

    • cmake 설치 및 버젼 확인.
      • $ sudo apt-get install cmake
      • $ cmake --version

    • expat 설치
      • $ wget http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz
      • $ tar -xzf expat-2.1.0.tar.gz 
      • $ cd expat-2.1.0/
      • $ ./configure
      • $ make
      • $ sudo make install

    • CommonAPI 개발환경 구축 완료

식빵이의 놀이


VMWare상 Xubuntu에서 Install VMWare Tools설치

VMWare상 Xubuntu에서 Install VMWare Tools 설치 방법
Windows와 공유폴더를 사용하려면 설치해야 한다.


  • Terminal 실행
          $ su
          $ ls -la /media/min/VMware\ Tools/
          $ tar -zxpf /media/min/VMware\ Tools/VMwareTools-10.1.6-5214329.tar.gz
          $ cd vmware-tools-distrib
          $ ./vmware-install.pl             <= 여러차례 enter 필요
* 설치가 완료되면 VMWare Tools는 Eject된다.

:


Xubuntu Root 계정 만들기

Xubuntu를 설치 후 root 계정 만들기
  • Terminal 실행
    • $sudo passwd root
    • [sudo] password for 현재계정 : <= 현재계정의 password입력
    • Enter new UNIX password :  <= root계정의 password로 사용할 것 입력
    • Retype new UNIX password : <= 위의 password를 재입력

logout후 root 계정으로 login 

VMWare에 Linux Xubuntu 설치


  • Xubuntu download
    • Home Pages : https://xubuntu.org/
    • Xubuntu 16.04 LTS Torrents Download : Torrent file(64bits)(32bits)
    • 특징 : 
      • Ubuntu와 같은 동일한 소프트웨어 소스를 사용.
      • Ubuntu에서 사용하는 실행코드들을 사용가능. 
      • 시스템 자원을 덜 사용하는 Xfce 데스크톱 환경을 사용.
  • Xubuntu 설치
    • VMWare File->New Virtual Machine 선택
    • Typical -> Next
    • Guest Operating System Installation -> Installer disc image -> Browse
      • 위에서 다운로드 받은 파일( xubuntu-16.04.3-desktop-amd64.iso ) 선택

    • Username & Password 입력 -> Next
    • Virtual machine이름과 저장위치 선택 -> Next 

    • Specify Disk Capacity 
      • 기본 20.0 GByte : 특별히 사용할게 많지 않으면 기본용량으로
    • Ready to Create Virtual Machine -> Finish
      • 자동설치(2~30분)
    • 설치완료
      • loggin : 앞에서 입력한 User name과 Password 입력

  • Update
    • Language Support
      • Run this action now <- Click
      • The language support is not installed completely -> install
      • Install/Remove languages.. <- Click
        • Install하고자하는 언어 선택 : Korean -> Apply