본문 바로가기
IT/AI

jupyterlab(주피터노트북) 외부접속 설정

by cbwstar 2024. 5. 20.
728x90
반응형

1. jupyterlab 설치

shell
닫기
pip3 install jupyter pip3 install jupyterlab

 

2. ipykernel  설치

shell
닫기
pip3 install ipykernel

 

3. 가상환경 생성 및 실행

가상환경은 아나콘다를 사용합니다.

shell
닫기
conda create -n [name] python=3.8 conda activate [name] /* 샘플 가상환경 생성 */ conda create -n vpython3.8 python=3.8

 

4. 가상환경 확인

shell
닫기
conda info -e or conda info -env

 

5. 커널추가

shell
닫기
python -m ipykernel install --user --name=[name] /* 가상환경을 커널에 추가 해 줘야 브라우저(주피터노트북)에서 해당 버전을 사용할수 있음 */ python -m ipykernel install --user --name=vpython3.8 python -m ipykernel install --user --name=base

 

6. 커널확인

shell
닫기
jupyter kernelspec list

 

0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Available kernels:
  base          /home/cbw/.local/share/jupyter/kernels/base
  vpython3.8    /home/cbw/.local/share/jupyter/kernels/vpython3.8
  python3       /home/cbw/anaconda3/share/jupyter/kernels/python3

 

7. 커널삭제

shell
닫기
jupyter kernelspec uninstall [name]


(base) cbw@gpusystem:~/anaconda3/bin$ jupyter kernelspec uninstall vpython3.8
Kernel specs to remove:
  vpython3.8           /home/cbw/.local/share/jupyter/kernels/vpython3.8
Remove 1 kernel specs [y/N]: y
Removed /home/cbw/.local/share/jupyter/kernels/vpython3.8
(base) cbw@gpusystem:~/anaconda3/bin$ jupyter kernelspec list
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Available kernels:
  base       /home/cbw/.local/share/jupyter/kernels/base
  python3    /home/cbw/anaconda3/share/jupyter/kernels/python3
(base) cbw@gpusystem:~/anaconda3/bin$ 

8. 외부접속 설정

shell
닫기
jupyter-lab --generate-config /* 접속비밀번호 생성 */ jupyter-lab password Enter password Verify password /* 패스워드 해시파일 생성 */

(base) cbw@gpusystem:~/anaconda3/bin$ jupyter-lab --generate-config
Writing default config to: /home/cbw/.jupyter/jupyter_lab_config.py

 

shell
닫기
vi /home/cbw/.jupyter/jupyter_lab_config.py c.ServerApp.password = '생성된비밀번호' c.ServerApp.ip = '0.0.0.0' c.ServerApp.allow_origin = '*' c.ServerApp.notebook_dir = '/home/cbw/workspace' c.ServerApp.port = 8890 c.ServerApp.password_required = True c.ServerApp.open_browser = False

 

9. 쥬피터 노트북 기동

shell
닫기
/* 기동 */ jupyter lab

 

10. 위치찾기

shell
닫기
whereis jupyter-lab /home/cbw/anaconda3/bin/jupyter-lab

 

11. 백그라운 실행 스크립트 생성

shell
닫기
vi jupyter-lab-start.sh nohup /home/cbw/anaconda3/bin/jupyter-lab 1>/dev/null 2>&1 & /* 실행권한 부여 */ chmod 777 jupyter-lab-start.sh /* 주피터 랩 실행 */ ./jupyter-lab-start.sh /* 실행 확인 */ cbw@gpusystem:~/workspace$ ps -ef|grep jupyter-lab cbw 3323461 1 16 15:40 pts/11 00:00:02 /home/cbw/anaconda3/bin/python /home/cbw/anaconda3/bin/jupyter-lab

 

쥬피터 노트북 실행화면

728x90
반응형


"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."