Warning
This page is located in archive.
How to edit code on a remote server
Option 1: Use a gui editor over ssh

Open ssh with -X flag to open X server. Open GUI editor (for example gedit or vim) and edit. Gedit is either not installed on cantor/taylor or it's in some module. A request has been written to the admin to install gedit/vim.


Option 2: mount the server file system

Mount the server's file system and edit the appropriate files as if they were on your own machine. On Ubuntu Linux you can open Nautilus (the default file browser) and choose “Connect to server”, enter the appropriate path sftp://<username>@cantor/home.nfs/<username>, for example: sftp://azayetey@cantor/home.nfs/azayetey and the file system is now mounted in your file browser and you can use gedit/pycharm or anything else to edit it. Note: If you are outside the local network then addressing the server as “cantor” or “tailor” will result in an error because your network does not know the server's address. This can be fixed by entering the complete address, sftp://<username>@cantor.felk.cvut.cz/home.nfs/<username>

Note: you can also use tools such as scp and rsync in linux to sync your project folder on your machine to the server. You can write an alias or script which will do this in a single simple command.


Option 3: Configure pycharm to use a remote interpreter

This is by far the best option as it allows you to use an IDE such as pycharm with a remote python interpreter (the one on the server) which means that you can run code and debug it as well as if it were on your own machine.

Steps:

1) Install pycharm-professional (remote interpretation isn't available on community version). For Ubuntu 16 or 18 you can simply use the command: sudo snap install pycharm-professional --classic and it's done. You will also need a student's license to use it. You can apply for it here. All you need to do is enter your name and university email adress and then confirm it in your email. It takes 2 minutes.

2) Open a pycharm project and go to file → settings → Project interpreter → add → ssh interpreter . Host: cantor (or taylor) Username: <username> Port: 22 (default) Enter your password and go to next. In the “Interpreter” tab write the following: /home.nfs/<username>/pyconfig

3) Use ssh through a terminal to login to the server and make the file: /home.nfs/<username>/pyconfig (basically make the file 'pyconfig' in the home directory). The file 'pyconfig' should contain the following:

#!/bin/bash -l
eval "ml PyTorch/1.1.0-fosscuda-2019a-Python-3.7.2"
python3 "$@"

Make the file executable by calling: chmod +x pyconfig

Brief explanation: In the “Interpreter” tab you need to tell pycharm the address of the python interpreter than you want to use. Normally this would be something like /usr/bin/python. The reason you need to make the pyconfig file is that so when pycharm looks for the remote interpreter, it runs this file which loads the appropriate modules before loading python.

And you are done (If you need to load additional modules, then add them to the pyconfig file). You should now be able to use pycharm with editing/running/debugging as if you were on your own machine.

courses/b3b33vir/resources/remote-editing/start.txt · Last modified: 2019/10/07 20:00 by jasekota