data analysis & visualization

 

 

 

conda pack을 통해 환경을 추출했는데 spyder 에서 아래와 같은 에러가 뜨는 경우가 있다.

 

 

해당 에러에 대하여 pyqt나 qt qtpy를 다시 인스톨하라는 stackoverflow 답변들이 많았다. 

 

test 해 본 결과 

 

해당 상태에서 qt만 다시 인스톨해주면 spyder가 열리는 것을 확인하였다. 

 

anaconda.org/anaconda/qt/files

 

Files :: Anaconda Cloud

 

anaconda.org

 

 

 

 

운영체제에 맞게 다운로드 

 

conda install <패키지 경로>\<패키지 명>

 

conda install qt-5.9.7-vc14h73c81de_0.tar.gz

 

이제 다시 spyder를 실행하면 실행이 된다. 

나는 conda create -n <환경명> python=3.6으로 환경을 설치해서 쓰던 도중 python의 버전이 변경되는 이상한 현상을 겪었다. 물론 내 실수겠거니 싶지만 고치는게 문제였다. python을 지우게 되면 버전이 다 바뀌게되기 때문이다.

그래서 python의 default 설정을 바꿔보도록 하자. 

 

우선 내 문제는 conda 가상환경의 python을 default로 잡지 않고 base의 경로를 잡는게 문제였다.

 

python은 환경의 경로 /bin/<python버전 ex)python3.6>으로 나타난다. 예를들어 python3.8이 설정된 base는 

/root/anaconda3/bin/python3.8이다.   

GPU환경에서 /root/anaconda3/envs/bin/python3.6에 있어야 할 GPU버전이 base경로로 잡혀있다. 이제 이 설정을 바꿔보자 .

 

python 의 경로를 확인하는 명령어는 windows에서는 where python, mac이나 linux에서는 which python이다. 

 

해당 가상환경에 activate 한 뒤 아래와 같이 설정하자. 

alias python='/root/anaconda3/envs/bin/python3.6'

. ~/.bashrc

 

 

이렇게 jupyter라는 가상환경을 고쳐 보았고 아래와 같이 나타났다. 

 

'python' 카테고리의 다른 글

python oracle DB 연동  (0) 2020.12.03
offline conda pack spyder설치 에러  (0) 2020.12.01
jupyterlab 확장기능  (0) 2020.11.21
아나콘다 오프라인 가상환경 생성 , 가상환경 추출 및 설치  (0) 2020.11.20
pyinstaller  (0) 2020.11.20

tensorboard 외부접속

딥러닝2020. 11. 27. 00:07

나는 tensorboard는 유용해 보였지만 사용법을 몰라서 못쓰던 유저였다. 그래서 외부접속 같은 옵션들을 간략하게 설명하려고 한다.

 

먼저 내 콘다는 /root/anaconda3/envs/jupyter/에 있다.

해당 콘다의 python의 패키지는 어디에 존재하는지는 운영체제마다 다르겠지만 linux(ubuntu20.04)는 

가상환경의 경로안에 lib/<python버전>/site-packages에 패키지들이 존재한다. 

에러에 대한 원래 코드를 확인하고 싶다면 아래 경로를 확인해보았으면 한다. 

 

 

 

 

 

 

위 코드는 keras의 tensor board의 예제이다

 

tutorials.pytorch.kr/intermediate/tensorboard_tutorial.html

 

TensorBoard로 모델, 데이터, 학습 시각화하기 — PyTorch Tutorials 1.6.0 documentation

TensorBoard로 모델, 데이터, 학습 시각화하기 파이토치(PyTorch)로 딥러닝하기: 60분만에 끝장내기 에서는 데이터를 불러오고, nn.Module 의 서브클래스(subclass)로 정의한 모델에 데이터를 공급(feed)하고,

tutorials.pytorch.kr

내 코드의 경로는 '/home/ducj/jupyter/pytorch_study'에 해당하는데 

 

from torch.utils.tensorboard import SummaryWriter

writer = SummaryWriter('runs/fashion_mnist_experiment_1')

 

명령어를 사용하게 되면

/home/ducj/jupyter/pytorch_study/runs/fashion_mnist_experiment_1에 생성이 된다.

 

그런 후 tensorboard --logder <run까지만> 입력을 하게되면 실행되고 port의 default 값은 6006이다.

 

외부접속을 허용하게 하려면 방화벽을 열어야 되는데 sudo ufw allow 6006을 하게되면 6006 포트가 열린다.

 

또한 인터넷에서 포트포워딩 같은 것을 해주어야 접속이 가능하다. host 0.0.0.0은 모든 host를 허용한다고 하는 것인데 우리가 매번 치던 localhost는 127.0.0.1에 해당된다.

 

bind_all이라는 기능도 있던데 따로 host를 생성해주는 것 같았다. 

 

 

마지막으로 ssh를 사용하고 있을 때이다.

 

ssh -L <내 로컬컴퓨터에서 접속할 port>:<매칭할호스트:포트> <계정명>@<ssh 호스트>

 

자 ssh를 통해 외부접속이 열렸다. 한번 확인해보자. 

 

위와 같이 localhost를 열었다.

 

 

잘들어가진다.

'딥러닝' 카테고리의 다른 글

전이학습(Transfer Learning)  (0) 2021.05.25
기울기 소실 문제와 ResNet  (0) 2021.05.25
순환신경망(1/3)  (0) 2021.04.11
GPU 메모리 조절 방법  (0) 2019.11.19
CNN channel 1개와 3개의 성능비교(cats and dogs)  (0) 2019.06.18

jupyterlab 확장기능

python2020. 11. 21. 00:52

 

확장기능 조회 

jupyter labextension list

 

확장기능을 사용하기위해 npm과 nodejs를 깔아주어야한다. 

apt install npm

 

nodejs는 아래처럼 설치해도 되나 10 버전 이상부터 깔리는 확장기능이 있어 14.15.1 버전 저렇게 찾아서 설치하면 된다.

 

sudo apt install nodejs

 

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

source ~/.bashrc

nvm list-remote

nvm install v14.15.1

 

 

ipywiget 설정 : 모르면 왠만하면 하는게 좋다.

jupyter labextension install @jupyter-widgets/jupyterlab-manager

#jupyter lab 버전에 맞게 설치해주면 되며 2점대버전은 아래와 같다.

jupyter labextension install @jupyter-widgets/jupyterlab-manager@2.0

 

실행시간 출력되게 설정

jupyter labextension install jupyterlab-execute-time

 

 Settings->Advanced Settings Editor->Notebook에서 세팅을 아래 부분을 바꾸면되는데 아래 그림과 같이 한 후 저장!

{"recordTiming": true}

 

 

메모리 및 CPU설정 조회 

 

jupyter labextension install jupyterlab-topbar-extension jupyterlab-system-monitor

conda install -c conda-forge nbresuse

cpu 개수 확인

grep ^processor /proc/cpuinfo | wc -l

 

 

구글드라이브 설정

jupyter labextension install @jupyterlab/google-drive

 

console.cloud.google.com/apis

 

Google Cloud Platform

하나의 계정으로 모든 Google 서비스를 Google Cloud Platform을 사용하려면 로그인하세요.

accounts.google.com

 

 

 

API 및 서비스 사용 설정 클릭

 

 

 

 

 

 

 

 

 

 

 

깃허브 설정

jupyter labextension install @jupyterlab/github

 

깃 설정

conda install -c conda-forge jupyterlab jupyterlab-git

jupyter lab build

vi ~/.jupyter/jupyter_notebook_config.py

c.JupyterLabGit.actions = {"post_init": ["touch dummy_init.dat"]}

변수목록 조회 기능

jupyter labextension install @lckr/jupyterlab_variableinspector

 

leaflet 기능 사용가능하게 설정

conda install -c conda-forge ipyleaflet
jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-leaflet

 

matplotlib 조절 가능하게 설정

conda install -c conda-forge ipympl

jupyter labextension install @jupyter-widgets/jupyterlab-manager

jupyter lab build

 

 

목차설정

jupyter labextension install @jupyterlab/toc

 

kite 설정(자동완성기능)

bash -c "$(wget -q -O - https://linux.kite.com/dls/linux/current)"

pip install jupyter-kite

jupyter labextension install "@kiteco/jupyterlab-kite"

drawio 설정

jupyter labextension install jupyterlab-drawio

 

debugging 설정

conda install -c conda-forge xeus-python

jupyter labextension install @jupyterlab/debugger

 

대시 설정 (설치실패)

conda install -c plotly -c defaults -c conda-forge "jupyterlab>=1.0" jupyterlab-dash=0.1.0a3

jupyter labextension install jupyterlab-dash

 

그림 코드 추출 (설치실패)

jupyter labextension install nbgather

conda install -c conda-forge itkwidgets

 

SQL 연결 

conda install -c conda-forge pymapd nodejs

pip install jupyterlab-omnisci

jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build

jupyter labextension install jupyterlab-omnisci

 

 

 

이메일 연동

pip install jupyterlab_email

jupyter labextension install jupyterlab_email

jupyter serverextension enable --py jupyterlab_email

 

vi ~/.jupyter/jupyter_notebook_config.py

c.JupyterLabEmail.smtp_servers = [{'name': 'gmail', 'domain': 'gmail.com', 'username': '<YOUR USERNAME>', 'smtp': 'smtp.gmail.com', 'port': 465}]

 

ufw allow 465

 

tensorboard 설정

jupyter labextension install jupyterlab_tensorboard

vi ~/.jupyter/jupyter_notebook_config.py

c.Spawner.cmd = ['jupyter-labhub']

 

오프라인으로 가상환경 생성

 

conda create -n <가상환경명> {python=3.6} {<패키지명=={버전}>}

위 형태가 기본 가상환경 만드는 형태

오프라인의 경우 패키지 설치가 안되므로 가상환경조차 생성되지 않음.

 

conda create -n <새로운 가상환경명> --clone <복제할 가상환경명>으로 가상환경 복제 가능

따라서 anaconda 설치 시 기본설치되는 root 를 복제하면 가상환경 생성이 가능

 

conda create -n test --clone root 혹은 conda create –n test --clone base

 

아나콘다 오프라인으로 가상환경 추출 및 설치

 

 

conda env list : 가상환경명 , 가상환경경로 확인 가능

conda list : 해당 가상환경에 패키지 목록 및 버전 확인 가능

 

패키지는 아나콘다를 C드라이브에 설치했을 경우

C:\Users\<윈도우 사용자명>\anaconda3\envs\<가상환경명>\Lib\site-packages에 설치됨

 

conda pack을 활용하면 자료를 추출 가능

conda install –c conda-forge conda-pack conda pack설치

 

conda pack –n <추출할 가상환경명> -o <추출할 가상환경압축파일.tar.gz>

conda export 를 써서 패키지명을 추출 가능[생략]

 

 

 

 

 

'python' 카테고리의 다른 글

conda python 경로 인식못할 때  (0) 2020.11.28
jupyterlab 확장기능  (0) 2020.11.21
pyinstaller  (0) 2020.11.20
matplotlib 시각화 정리 [여러 그림 그리기, quiver plot]  (0) 2020.11.05
pypy  (0) 2020.08.31

pyinstaller

python2020. 11. 20. 13:24