본문 바로가기

SQL/IT_tips

installing pytorch / torchvision : torchvision으로 이미지인식 데이터 분석하기

728x90
반응형

facebook에서 개발한 딥러닝 툴인 파이토치의 설치와 파이토치를 activate 해서 torchvision 설치까지 완료해보자!

파이썬 패키지 설치를 위한 터미널 접속방법은 3가지이다.

1) 아나콘다 프롬프트  (Anaconda Prompt) - 패키지 설치시 Conda로 시작

2) windows powershell -> bash 접속 (별도 설정 필요)

3) 실행(windows +R) - cmd-> bash 접속(별도 설정 필요)

 

나의 경우는 GPU를 서버에 물려놓고 접속하는 환경인지라, 

위의 방법과 다른 putty를 통한 원격서버로 pytorch 설치과정을 진행할 계획이다.

 

접속창>pip install https://download.pytorch.org/whl/cpu/torch-1.1.0-cp36-cp36m-linux_x86_64.whl 입력

(접속 터미널과 python 버전마다 명령어가 모두 상이하니 pytorch 홈페이지에서 명령값을 직접확인하는 것이 편리하다)

 

(중간에 pip install upgrade하라고 떠서 그것도 해줌;;)

 

드디어 업그레이드 완료된 pip 명령창에 "pip install torch"를 치면 설치가 좌라락~

 

@:~$ conda create -n pytorch python=3.6
Solving environment: done

 

## conda create -n pytorch python=3.6 명령창 입력!

==> WARNING: A newer version of conda exists. <==
  current version: 4.5.4
  latest version: 4.6.14

Please update conda by running

    $ conda update -n base conda



## Package Plan ##

  environment location: /home/eve/.conda/envs/pytorch

  added / updated specs:
    - python=3.6


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    libgcc-ng-8.2.0            |       hdf63c60_1         7.6 MB
    zlib-1.2.11                |       h7b6447c_3         120 KB
    readline-7.0               |       h7b6447c_5         392 KB
    openssl-1.1.1b             |       h7b6447c_1         4.0 MB
    xz-5.2.4                   |       h14c3975_4         366 KB
    setuptools-41.0.1          |           py36_0         656 KB
    sqlite-3.28.0              |       h7b6447c_0         1.9 MB
    python-3.6.8               |       h0371630_0        34.4 MB
    ca-certificates-2019.1.23  |                0         126 KB
    wheel-0.33.4               |           py36_0          40 KB
    tk-8.6.8                   |       hbc83047_0         3.1 MB
    libstdcxx-ng-8.2.0         |       hdf63c60_1         2.9 MB
    ncurses-6.1                |       he6710b0_1         958 KB
    libedit-3.1.20181209       |       hc058e9b_0         188 KB
    pip-19.1.1                 |           py36_0         1.9 MB
    certifi-2019.3.9           |           py36_0         155 KB
    ------------------------------------------------------------
                                           Total:        58.8 MB

The following NEW packages will be INSTALLED:

    ca-certificates: 2019.1.23-0
    certifi:         2019.3.9-py36_0
    libedit:         3.1.20181209-hc058e9b_0
    libffi:          3.2.1-hd88cf55_4
    libgcc-ng:       8.2.0-hdf63c60_1
    libstdcxx-ng:    8.2.0-hdf63c60_1
    ncurses:         6.1-he6710b0_1
    openssl:         1.1.1b-h7b6447c_1
    pip:             19.1.1-py36_0
    python:          3.6.8-h0371630_0
    readline:        7.0-h7b6447c_5
    setuptools:      41.0.1-py36_0
    sqlite:          3.28.0-h7b6447c_0
    tk:              8.6.8-hbc83047_0
    wheel:           0.33.4-py36_0
    xz:              5.2.4-h14c3975_4
    zlib:            1.2.11-h7b6447c_3

Proceed ([y]/n)? y
-계속하기 y 입력

Downloading and Extracting Packages
libgcc-ng-8.2.0      |  7.6 MB | ######################################################################## | 100%
zlib-1.2.11          |  120 KB | ######################################################################## | 100%
readline-7.0         |  392 KB | ######################################################################## | 100%
openssl-1.1.1b       |  4.0 MB | ######################################################################## | 100%
xz-5.2.4             |  366 KB | ######################################################################## | 100%
setuptools-41.0.1    |  656 KB | ######################################################################## | 100%
sqlite-3.28.0        |  1.9 MB | ######################################################################## | 100%
python-3.6.8         | 34.4 MB | ######################################################################## | 100%
ca-certificates-2019 |  126 KB | ######################################################################## | 100%
wheel-0.33.4         |   40 KB | ######################################################################## | 100%
tk-8.6.8             |  3.1 MB | ######################################################################## | 100%
libstdcxx-ng-8.2.0   |  2.9 MB | ######################################################################## | 100%
ncurses-6.1          |  958 KB | ######################################################################## | 100%
libedit-3.1.20181209 |  188 KB | ######################################################################## | 100%
pip-19.1.1           |  1.9 MB | ######################################################################## | 100%
certifi-2019.3.9     |  155 KB | ######################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > source activate pytorch
#
# To deactivate an active environment, use:
# > source deactivate
#


@:~$ source activate pytorch

## pytorch를 activate 해야 torchvision을 계속 설치할 수 있다. 


(pytorch) ***@******:~$ pip install torchvision

## pytorch 활성화한 상태에서 pip install torchvision 입력


Collecting torchvision
  Using cached https://files.pythonhosted.org/packages/2e/45/0f2f3062c92d9cf1d5d7eabd3cae88cea9affbd2b17fb1c043627838cb0a/torchvision-0.3.0-cp36-cp36m-manylinux1_x86_64.whl
Collecting torch>=1.1.0 (from torchvision)
  Using cached https://files.pythonhosted.org/packages/69/60/f685fb2cfb3088736bafbc9bdbb455327bdc8906b606da9c9a81bae1c81e/torch-1.1.0-cp36-cp36m-manylinux1_x86_64.whl
Collecting pillow>=4.1.1 (from torchvision)
  Downloading https://files.pythonhosted.org/packages/d2/c2/f84b1e57416755e967236468dcfb0fad7fd911f707185efc4ba8834a1a94/Pillow-6.0.0-cp36-cp36m-manylinux1_x86_64.whl (2.0MB)
     |################################| 2.0MB 247kB/s
Collecting six (from torchvision)
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting numpy (from torchvision)
  Downloading https://files.pythonhosted.org/packages/c1/e2/4db8df8f6cddc98e7d7c537245ef2f4e41a1ed17bf0c3177ab3cc6beac7f/numpy-1.16.3-cp36-cp36m-manylinux1_x86_64.whl (17.3MB)
     |################################| 17.3MB 20.7MB/s
Installing collected packages: numpy, torch, pillow, six, torchvision
Successfully installed numpy-1.16.3 pillow-6.0.0 six-1.12.0 torch-1.1.0 torchvision-0.3.0
(pytorch) ***@****:~$ python

##torch vision이 활성화 되었는지 확인해보기 위해 python을 실행한다.


Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
>>>

 

##import torchvision을 한결과 자연스럽게 다음 커맨드로 넘어간다

##torchvision 성공적으로 import 완료! 

728x90