EC2 가상환경 구동 후 Ubuntu 세팅에서 jupyter notebook/ colab 구동하기
이번 시간에는 딥러닝을 조금 더 빠르고, GPU 제한 없이 구동할 수 있는 방법이 없을까, 하다가 찾은 방법입니다.
다만 오류가 상당히 많아서, 이 부분을 먼저 언급하고 진행해야 할 것 같습니다.
참조 블로그
https://towardsdatascience.com/connecting-google-colab-to-an-amazon-ec2-instance-b61be9f9cf30
Connecting Google Colab to an Amazon EC2 instance
Boost your Colab Notebook’s GPU
towardsdatascience.com
필요 프로그램/ 구매 계정
AWS EC2 (아마존) : 1년간 학습용으로도 무료로 제공하고 있습니다. 가상 환경을 제작합니다
- 미리 계정 생성 및 로그인이 필요합니다. (영어 주의)
PuTTY : EC2를 구동해서 가상 환경을 만들 수 있는 키 변형 프로그램. 위의 블로그에서도 확인할 수 있습니다.
위의 EC2를 구매(인스턴스 생성)까지 마친 후에 진행할 수 있습니다.
생각보다 한글화가 다 되어 있어서 어렵진 않을 것이라고 생각됩니다.
문제는 블로그 마지막 부분의 코드입니다.
PuTTY를 구동하는 과정까지는 완전히 동일한 코드로 진행해도 무방합니다.
jupyter notebook도 원활히 진행되는데요.
엔터키 누를때마다 개별적으로 pip가 설치됩니다.
pip install jupyter_http_over_ws
jupyter serverextension enable --py jupyter_http_over_ws
* 중간에 markupafe가 버전이 낮아서 추가로 설치해줘야 할 수 있습니다.
pip install markupsafe==2.0.1
아래는 markupsafe에서 버전 호환이 안될 시 jinja2 버전도 확인함(필자 노크북)
pip install jinja2
ubuntu를 켜준 후에, jupyter notebook을 세팅하는 과정에서 문제가 생깁니다.
NotebookApp.disable_check_xsrf
jupyter notebook의 config 부분에서 disable_check_xsrf 문법에 대해서 생략한 부분이 있었는데, 잘못 언급되어 있어서
거의 반나절은 헤맨것 같습니다.
놀랍게도 reply로 틀렸다고 지적해주신 분의 코드도 구동이 안되는 것을 확인할 수 있습니다.
아래 코드로 진행해야 합니다.
jupyter notebook \
--NotebookApp.allow_origin='https://colab.research.google.com' \
--port=8888 \
--NotebookApp.port_retries=0 \
--NotebookApp.disable_check_xsrf=True
Config file and command line options — Jupyter Notebook 6.5.2 documentation
Replace actual URL, including protocol, address, port and base URL, with the given value when displaying URL to the users. Do not change the actual connection URL. If authentication token is enabled, the token is added to the custom URL automatically. This
jupyter-notebook.readthedocs.io