class:phy3026

This is an old revision of the document!


Class materials in git

git clone https://github.com/monttj/computational-physics

Prepare your computing environment

Choose one of following methods to connect to use ssh and the other linux commands Use Mac OS or Linux You can directly access to the server with native bash (terminal) in Mac os or Linux. You can also install Linux (usually Ubuntu) to virtual box (link but the performance will be largely degraded since the os will share resources with native Windows

Install ubuntu via Microsoft appstore This part is written based on Windows 10 1903 update. Open Control Panel (제어판) - Programs and Features (프로그램 및 기능) - Turn Windows features on or off (Windows 기능 끄키/켜기) - activate 'Windows Subsystem for Linux' (Linux용 Windows 하위시스템 항목 활성화) - 재부팅

Open Microsoft appstore, search for 'Ubuntu' - install Ubuntu 18.04

Type username and root password. If you failed to correctly verify password (비밀번호를 두 번 입력해야하는데 실수로 서로 다르게 입력하여 계정 생성에 실패할경우), go to Settings (설정) - Apps & features (앱 및 기능) - Ubuntu 18.04 LTS (Ubuntu 18.04 LTS 클릭) - Advanced options - Reset)

In terminal, you can use linux commands like ssh, ls, cd.

*Optional: change ubuntu mirror and update In terminal,

sudo vi /etc/apt/sources.list
:%s/kr.archive.ubuntu.com/mirror.kakao.com/    (콜론 포함하여 vi기능에서 찾아바꾸기임)
('kr.archive.ubuntu.com'부분은 사람마다 다를 수 있으니 적당히 바꾸면 됨)
:wq                                            (저장하고 나오기)
sudo apt-get update
sudo apt-get upgrade                           (설치하시겠습니까? [Y/n]등의 메시지 나오면 Y 선택하여 설치)
sudo apt install python2.7                     (python 2.7 설치. 기본은 3.5)
sudo apt install python-pip                    (python2용 pip설치. python3은 python3-pip로 설치)
sudo pip install numpy                         (예를 들어 numpy 설치)

Next, you need to install Xming link to forward graphic output from server to your local computer. Then you add following lines in your bashrc

vi ~/.bashrc
GG                (vi 명령어, 맨 아래로 이동하기)
i                 (vi 쓰기모드)
export DISPLAY=0:0
esc key           (쓰기모드에서 나가기)
:wq               (저장하고 파일 닫기)
source ~/.bashrc  (변경사항 적용)

Install MobaXterm

https://mobaxterm.mobatek.net/download.html

MobaXterm

Connect to server

Ask to tutor to create accounts for students. Start local terminal in mobaxterm.

ssh -X YOURID@210.117.210.IP

Jupyter notebook

To write and excute python code in your local browser, you need to create ssh tunnel to server. First, make sure you are using unique port number for tunnel. Follow the lines in the server.

jupyter notebook --generate-config
vi /home/YOURID/.jupyter/jupyter_notebook_config.py

Then you can excute jupyter in server.

jupyter-notebook --no-browser

You can check your port number in c.NotebookApp.port = 8888. Now, create tunnel in your LOCAL(in desktop) terminal (not in server!).

ssh -f -N -L localhost:TunnelPort:localhost:TunnelPort YOURID@210.117.210.XX

Please don't confuse PORT (port to connect server when login) and TunnelPort (port to listen data from the server)!

The address to jupyter notebook will appear in the terminal. Copy & paste into local internet browser.

*Run .py in jupyter notebook*

%run some_code.py

*Disable ssh tunnel*

This is optional. But it can be required if you are using your own laptop without logout/restart, whatever. Find pid with ssh -p XXX…. (which is ssh tunnel command you wrote in terminal), then quit it.

ps -elf | grep ssh
kill -9 <PID>
  • class/phy3026.1568533945.txt.gz
  • Last modified: 2023/03/06 13:44
  • (external edit)