이 블로그 검색

2017년 12월 7일 목요일

내가 자주 쓰는, 기억해야 하는 파이썬 command - Ubuntu

framework 버전 확인
anaconda 를 통해 pip install 로 설치된 tensorflow 1.3.1 로 동작 확인
u0018670@sys-90257:~$ env | grep PATH
PATH=/home/u0018670/bin:/home/u0018670/.local/bin:/home/u0018670/anaconda2/bin:/opt/ibm/xlC/current/bin:/opt/ibm/xlf/current/bin:/opt/at10.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
u0018670@sys-90257:~$ python
Python 2.7.13 |Anaconda, Inc.| (default, Sep 15 2017, 20:54:27)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow as tf
>>> print(tf.__version__)
1.3.1
>>>


powerAI toolkit 에 포함된 tensorflow 로 동작

u0018670@sys-90257:~$ . /opt/DL/tensorflow/bin/tensorflow-activate
u0018670@sys-90257:~$ env | grep PATH
LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:/usr/local/cuda-8.0/extras/CUPTI/lib64:/opt/DL/tensorflow/lib
PATH=/home/u0018670/bin:/home/u0018670/.local/bin:/home/u0018670/anaconda2/bin:/opt/ibm/xlC/current/bin:/opt/ibm/xlf/current/bin:/opt/at10.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/DL/tensorflow/bin
PYTHONPATH=/opt/DL/tensorflow/lib/python2.7/site-packages
u0018670@sys-90257:~$ python
Python 2.7.13 |Anaconda, Inc.| (default, Sep 15 2017, 20:54:27)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow as tf
>>> print(tf.__version__)
1.1.0
>>>


python system path 확인

u0018670@sys-90257:~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-powerpc64le-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/home/u0018670/.local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']
>>>


native python3 설치 후 link 생성

native python3 를 다음과 같이 설치 후,
u0018670@sys-90257:~$ sudo apt-get install python3

jupyter 도 pip install 설치
u0018670@sys-90254:~$ pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
bleach (2.1.1)
decorator (4.1.2)
entrypoints (0.2.3)
html5lib (1.0b10)
ipykernel (4.6.1)
ipython (6.2.1)
ipython-genutils (0.2.0)
ipywidgets (7.0.5)
jedi (0.11.0)
Jinja2 (2.10)
jsonschema (2.6.0)
jupyter (1.0.0)
jupyter-client (5.1.0)
jupyter-console (5.2.0)
jupyter-core (4.4.0)
MarkupSafe (1.0)


그런데 jupyter 가 실행이 안됨.

u0018670@sys-90257:~$ jupyter
-bash: /home/u0018670/.local/bin/jupyter: /usr/bin/python: bad interpreter: No such file or directory

안되는 이유는 /usr/bin/python 파일이 없어서 그래서 link 시켜주면 잘 됨.
u0018670@sys-90257:~$ sudo ln -s /usr/bin/python3 /usr/bin/python
u0018670@sys-90257:~$ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

u0018670@sys-90257:~$ jupyter
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json]
               [subcommand]


theano 기본 테스트
root@3498b2e65eb1:/tmp# python
Python 3.5.4 |Anaconda, Inc.| (default, Sep 19 2017, 14:42:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano
>>> import theano.tensor as T
>>> import numpy as np
>>> x = T.dscalar('x')
>>> y = x ** 2
>>> f = theano.function(inputs=[x], outputs=y)
>>> f(1)
array(1.0)
>>> f(2)
array(4.0)
>>> f(3)
array(9.0)
>>>

jupyter notebook 에서는 다음과 같이 출력 확인

댓글 없음:

댓글 쓰기