Code & Env Setup

Code Setup

In general, there are three workflows you can use to edit code and run it on the cluster:

  1. Sign on through the Terminal and use an editor like emacs, vim, or nano to edit code directly in the terminal on the cluster.

  2. Edit your code locally and then copy it up to the cluster using either scp, rsync, or pushing to a remote repo that is cloned on the cluster.

  3. Sign onto the cluster through an editor like VS code, and edit your files directly on the cluster compute.

Here, we walk through workflow #3. However, if you are running into latency problems interacting with the cluster through VS code directly, you may consider using workflow #2.

Your repo will then be setup on the cluster.

Environment Setup

You can use any environment management strategy you prefer. Our example below shows how to set up a conda environment.

  1. Create a new environment.

# Standard environment creation:
$ conda create --name <environment-name>

# If you want to setup the environment in a particular location, use this instead:
$ conda create --prefix /path/to/environment/directory
  1. Activate your environment.

# For the fist setup method above:
$ conda activate <environment-name>

# For the second setup method above:
$ conda activate /path/to/environment/directory
  1. Setup pip.

# This will make sure packages are installed in your environment
(environment-name)$ conda install pip
  1. Install any packages you need to run your code. For example, if you have a requirements file:

(environment-name)$ pip install -r requirements.txt

Now you are ready to run your jobs. Before submitting a job to the cluster, make sure your environment is activated. Alternately, you can activate your environment in your job script.

Last updated