목차

Tensorflow

  • description : tensorflow 관련 내용 기술
  • author : 도봉산핵주먹
  • email : hylee@repia.com
  • lastupdate : 2020-07-08

Tensorflow

Install

Ubuntu 18.04 (GPU version)

1. CUDA Toolkit 10.1 update2

 https://developer.nvidia.com/cuda-toolkit-archive (회원 가입 필요 없음)

tip:위 버전이 Tensorflow2 gpu 호환 가능 버전

2. cuDNN v7.6.4 설치

 https://developer.nvidia.com/rdp/cudnn-archive (회원가입 필요)

tip:위 버전이 CUDA Toolkit 10.1 update2 호환 버전

3. python3.8 설치

 https://linuxize.com/post/how-to-install-python-3-8-on-ubuntu-18-04/

4. NVIDIA driver 설치

$> nvidia-smi
$> ubuntu-drivers devices
$> sudo ubuntu-drivers autoinstall

https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-18-04-bionic-beaver-linux
우분투에서 NVIDIA 드라이버 설치 방법

gpu 사용 확인 code

from tensorflow.python.client import device_lib
device_lib.list_local_devices()


Remove

Show

$> pip3 show tensorflow

Uninstall

sudo pip3 uninstall tensorflow-gpu


Upgrade

sudo pip3 install --upgrade tensorflow-cpu

tensorflow GPU 사용하기

Tip

33. TensorFlow 2.0 Release 및 변경사항 정리 – Tf.Session & Tf.Placeholder 삭제, @Tf.Function, Tf_upgrade_v2
SyntaxError regarding async when attempting to jupyter

dhan@dhan-linux:~$ jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root
[I 17:59:50.050 NotebookApp] Writing notebook server cookie secret to /home/dhan/.local/share/jupyter/runtime/notebook_cookie_secret
Traceback (most recent call last):
  File "/home/dhan/.local/bin/jupyter-notebook", line 8, in <module>
    sys.exit(main())
  File "/home/dhan/.local/lib/python3.8/site-packages/jupyter_core/application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/dhan/.local/lib/python3.8/site-packages/traitlets/config/application.py", line 663, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/home/dhan/.local/lib/python3.8/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/dhan/.local/lib/python3.8/site-packages/notebook/notebookapp.py", line 2037, in initialize
    self.init_webapp()
  File "/home/dhan/.local/lib/python3.8/site-packages/notebook/notebookapp.py", line 1675, in init_webapp
    self.web_app = NotebookWebApplication(
  File "/home/dhan/.local/lib/python3.8/site-packages/notebook/notebookapp.py", line 183, in __init__
    settings = self.init_settings(
  File "/home/dhan/.local/lib/python3.8/site-packages/notebook/notebookapp.py", line 302, in init_settings
    nbextensions_path=jupyter_app.nbextensions_path,
  File "/home/dhan/.local/lib/python3.8/site-packages/notebook/notebookapp.py", line 1292, in nbextensions_path
    from IPython.paths import get_ipython_dir
  File "/home/dhan/.local/lib/python3.8/site-packages/IPython/__init__.py", line 55, in <module>
    from .core.application import Application
  File "/home/dhan/.local/lib/python3.8/site-packages/IPython/core/application.py", line 25, in <module>
    from IPython.core import release, crashhandler
  File "/home/dhan/.local/lib/python3.8/site-packages/IPython/core/crashhandler.py", line 27, in <module>
    from IPython.core import ultratb
  File "/home/dhan/.local/lib/python3.8/site-packages/IPython/core/ultratb.py", line 116, in <module>
    from IPython.utils import path as util_path
  File "/home/dhan/.local/lib/python3.8/site-packages/IPython/utils/path.py", line 17, in <module>
    from IPython.utils.process import system
  File "/home/dhan/.local/lib/python3.8/site-packages/IPython/utils/process.py", line 19, in <module>
    from ._process_posix import system, getoutput, arg_split, check_pid
  File "/home/dhan/.local/lib/python3.8/site-packages/IPython/utils/_process_posix.py", line 23, in <module>
    import pexpect
  File "/usr/lib/python3/dist-packages/pexpect/__init__.py", line 75, in <module>
    from .pty_spawn import spawn, spawnu
  File "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 14, in <module>
    from .spawnbase import SpawnBase
  File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 224
    def expect(self, pattern, timeout=-1, searchwindowsize=-1, async=False):
                                                               ^
SyntaxError: invalid syntax

해결법

$> sudo apt-get remove python-pexpect python3-pexpect
$> sudo pip3 install --upgrade pexpect

https://askubuntu.com/questions/1106943/syntaxerror-regarding-async-when-attempting-to-run-jupyter-in-python-3-7

ModuleNotFoundError: No module named 'pexpect'

dhan@dhan-linux:~$ ipython
.....
.....
ModuleNotFoundError: No module named 'pexpect'

해결법

pip install -I pexpect
python -c 'import pexpect'

https://github.com/facebookresearch/DrQA/issues/9

Troubleshooting

Ref