Network Attached Storage (NAS) ๐Ÿ“€

First, please ask the administrator for a username and a password!

What is NAS for?

  • Storing/sharing materials for research, e.g., datasets, codes, etc.
  • Being linked to workstations for remote development.

DO NOT keep any sensitive information on NAS!

  1. Gaining Access To NAS
  • Ask the administrator for a username and a password
  • Change the password after the first login with web interface at https://223.195.240.67:1006

You might see a unsecured connection warning from your web browser when you try to access the NAS web interface. It is OK๐Ÿ™„ to ignore the warning and proceed to the website.

regular

However, with an unsecured connection, your data, especially your username and password will be transmitted in plain text๐Ÿคฎ. So, it is recommended to install a SSL certificate on your PC, especially if you are using a public network and you share the same username and password with other services.

To install a SSL certificate on you PC,

  • Download the certificate.
  • Install it on your PC. For Windows and Chrome, follow this instruction. For other operating systems and browsers, please search for the instructions online.
  1. Connecting To NAS
    • NAS Web Interface
      • Open a web browser and go to https://223.195.240.67:1006
      • Enter your username and password
      • Click [Sign In]
      • NAS Web Interface main features include:
        • [File Station] is for managing files and folders
        • [Personal] contains your account information
    • SFTP Clients
      Please refer to Data Transfer ๐Ÿšš for more information
  2. NAS Folder Structure
    • your_username contains your personal data.
    • PAPER-WORK is for storing our lab’s documents.
    • PUBLIC is for sharing materials from graduated members, this folder is read-only.

GPU Workstations

First, please ask the administrator for a username and a password!

SSH Keys ๐Ÿ”‘

SSH keys are a pair of cryptographic keys used to authenticate a user to a remote server. Basically, you will need two keys:

  • A private key is kept on your local machine at ~/.ssh/id_XXX (Linux/MacOS) or C:\Users\your_username\.ssh\id_XXX (Windows)
  • A public key is stored on workstations at ~/.ssh/authorized_keys

regular

Instead of entering your password every time you connect to a workstation, your PC and workstations exchange encrypted messages via private key and public key. This way, you can log in without entering a password. This is more secure and convenient.

To set up SSH keys, follow these steps:

  1. Generate SSH keys

    This step should be done ONLY ONE TIME!

    • Open a terminal on your local machine
    • Run the following command to generate a new SSH key pair
      ssh-keygen -t ed25519 -C "your_comment"
      
      where your_comment is any text you want, for example, cilab
      • You will be asked to enter a file name to save the key pair. Press Enter to use the default file name ~/.ssh/id_ed25519 (Linux/MacOS) or C:\Users\your_username\.ssh\id_ed25519 (Windows)
      • Next, you will be prompted to enter a passphrase to protect the keys. You can leave it empty by pressing Enter or type a passphrase for added security. I personally leave it empty but please choose what you feel comfortable with.
      • After that, your SSH key pair will be generated in the ~/.ssh directory (Linux/MacOS) or C:\Users\your_username\.ssh (Windows) on your local machine:
        • private key is saved as id_ed25519
        • public key is saved as id_ed25519.pub
  2. Add the SSH key to the SSH agent

    This step should be done ONLY ONE TIME!

    • Start the SSH agent

      • For Linux and macOS, from the terminal in local machine,
        eval "$(ssh-agent -s)"
        
      • For Windows,
        • Open Services by following one of these methods
          • Option 1: Press Windows + R to open the Run dialog, type service.msc and press Enter
          • Option 2: Press Start Menu, type services and press Enter
        • Look for OpenSSH Authentication Agent in the list
        • Double-click on it to open its properties
        • Set the Startup type to Automatic
        • Press Apply
        • Press Start to start the service
        • Press OK to close the properties window
    • Add the SSH key to the agent, open a terminal on your local machine and run the following command:

      • For Linux and macOS,
        ssh-add ~/.ssh/id_ed25519
        
      • For Windows,
        ssh-add C:\Users\your_username\.ssh\id_ed25519
        
  3. Copy the public key to the workstations

    Do the following steps for ALL the workstations!

    • Open the public key file id_ed25519.pub on your local machine using Notepad or any text editor
    • Copy its content. For example, it should look like this:
      ssh-ed25519 AAAAC3Nza... your_comment
      
    • Open a terminal on your local machine
    • Login to a workstation using SSH
      ssh your_username@workstation_ip_address -p 1004
      
    • Create the ~/.ssh directory if it does not exist
      mkdir -p ~/.ssh
      
    • Paste the content into the ~/.ssh/authorized_keys file on the workstation
      echo "ssh-ed25519 AAAAC3Nza... your_comment" >> ~/.ssh/authorized_keys
      
      replace ssh-ed25519 AAAAC3Nza... your_comment with the actual content of your public key file.
    • Set the correct permissions for the ~/.ssh directory and the authorized_keys file so that only you can read and write to them
      chmod 700 ~/.ssh
      chmod 600 ~/.ssh/authorized_keys
      
    • Exit the workstation
      exit
      
  1. Test the connection
    • Open a terminal on your local machine
    • Run the following command to test the SSH connection
      ssh your_username@workstation_ip_address -p 1004
      
      If everything is set up correctly, you should be able to log in to the workstation without entering a password! This is also applied when you use VSCode to connect to workstations.

In summary,

  • Local machines:
    • A private key file at ~/.ssh/id_ed25519 (Linux/MacOS) or C:\Users\your_username\.ssh\id_ed25519 (Windows)
    • Adding the private key to the SSH agent
  • Workstations: a public key at ~/.ssh/authorized_keys

Notes:

  • After entering ssh your_username@workstation_ip_address -p 1004, if you are asked to enter your password, it means that the SSH key authentication is NOT set up correctly. Leave a message in our KakaoTalk group for help!
  • NO NOT share your private key ~/.ssh/id_ed25519 or C:\Users\your_username\.ssh\id_ed25519 with anyone. You can think of it as your password!
  • If you have any issue with REMOTE HOST IDENTIFICATION HAS CHANGED and errors related to .ssh/known_hosts, please remove the corresponding line in the ~/.ssh/known_hosts file on your local machine or simply delete ~/.ssh/known_hosts if you are comfortable doing so.
  • If you want to use the same SSH key on multiple workstations and multiple local machines, you can copy the public key to all the workstations using the step 2 above and private key to all your local machines.

Basic Usage ๐Ÿ–ฅ๏ธ


Connecting To Workstations ๐Ÿ–ฅ๏ธ

Let’s start with the most common way to connect to a workstation, which is using SSH with a terminal.

  • Open a terminal
  • Connect to the workstation with the following command
    ssh username@workstation_ip -p 1004
    
  • If you ssh key authentication is set up correctly, you should be able to connect to the workstation without entering a password. Otherwise, follow the above instructions to make ssh key again!
  • You are now connected to the workstation
    regular

Environment Setup ๐Ÿšง

For the most part, you will be working on GPU workstations with Python based projects. Here is an example of how to set up your Python environment:

  1. Connect to the workstation with SSH
  2. Install Anaconda
    • Download the latest version of Anaconda for Linux, for example, Anaconda3-2024.10-1-Linux-x86_64.sh
      wget https://repo.anaconda.com/archive/Anaconda3-2024.10-1-Linux-x86_64.sh
      
    • Enter the following command to install Anaconda
      bash Anaconda3-2024.10-1-Linux-x86_64.sh
      
      then follow the instructions to complete the installation.
    • Create a new environment with Python 3.9
      conda create -n <your environment name here> python=3.9
      
      Replace <your environment name here> and 3.9 with any name and any version of Python that you need.
    • Activate the environment
      conda activate <your environment name here>
      
      You should see the environment name in the terminal prompt which is (csd) in the figure below.
      regular
  3. Hello World!
    • Let’s start with a simple Python script
    • Use nano text editor to create a Python script
      nano hello.py
      
    • Enter the following content
      print("Hello, World!")
      
    • Save the file by pressing Ctrl + O and then Enter
    • Close nano by pressing Ctrl + X
    • Run the file with the following command
      python hello.py
      
      You should see the output Hello, World! in the terminal!

Interacting With Workstations ๐Ÿ–ฅ๏ธ

VSCode is an All-in-One powerful editor that runs on your local machine. It can be used to connect to a remote workstation for develpment. It comes with a lot of useful features via extensions. This guide will show you how to set up and use VSCode to connect to a CILab workstation.

  • Download and install VSCode on your local machine (NOT the workstation!)

  • Remember to make a reservation before using a workstation.

  • SSH configuration:
    (skip this step if you have already done it before.)

    • Run VS Code on your local machine.
    • Install the Remote-SSH extension in VSCode
      regular
    • Press F1 (Windows/Linux) or โ‡งโŒ˜P (macOS) to open Command Palette
    • Type Remote-SSH: Open SSH Configuration File... and press Enter
      regular
    • Select:
      • Linux: ~/.ssh/config
      • Windows: C:\Users\your_username\.ssh\config
      • macOS: /Users/your_username/.ssh/config

    then press Enter.

    • Add the following lines to the file:
      Host any_name_you_like
          HostName workstation_ip_address
          User your_username
          Port 1004
      
    • Save the file and close it.
  • Connecting to a server

    • Run VS Code on your local machine (if you haven’t.)
    • Press F1 (Windows/Linux) or โ‡งโŒ˜P (macOS) to open Command Palette
    • Type Remote-SSH: Connect to Host... and press Enter
      regular
    • Select the name you set in the previous step and press Enter
    • If you ssh key authentication is set up correctly, you should be able to connect to the workstation without entering a password. Otherwise, follow the above instructions to make ssh key again!
    • Wait for the connection to be established
    • You should see the workstation name in the bottom left corner of the VS Code window. In the example below, the server name is cilabws05
      regular
    • Let’s look for available GPUs. Open a new terminal by selecting Terminal -> New Terminal from the top menu
    • Type cilab-gpu and press Enter
    • In the example below, GPU #0 is being used by someone else while GPUs #1, #2, and #3 are free.
      regular

Now everything is set up and you can start working on the workstation with VS Code!

Tips and tricks

  • With VS Code, in general, a task, e.g., openning a terminal instance, can be done in multiple ways. Play around with it to find the way you like.
  • In VS Code, most of the tasks can be done via Command Palette and they can also be associated with keyboard shortcuts. Click the wheel icon in the bottom left corner then select Keyboard Shortcuts for more information.
  • In addition the Remote-SSH extension, you can also install other extensions in VS Code. For example, GitLens is useful for managing Git repositories. Recommended extensions: compareit, Edit csv, GitHub Copilot, GitHub Pull Requests and Issues, GitLens, LaTeX Workshop, Markdown All in One, Python, Remote-SSH, Remote Development, TensorBoard, and WSL.
  • With LaTeX Workshop, VSCode can be used to write and compile LaTeX documents. The output PDF file can be viewed directly in VSCode.
  • To run code in background, you can use nohup command. For example, nohup python train.py &. For more information, visit nohup. Also, you can use screen or tmux for more advanced features.

Scheduling Jobs โฐ

- By default, code runs on GPUs via Terminals or VSCode will be killed after 15 minutes automatically.
- Job needs to be submitted on CILab GPU Scheduler.

In this part, we will learn how to schedule jobs on CILab GPU Scheduler.

  • I strongly recommend you to install certificates for a secure connection as you will send your username and SSH key to the server. Without this, other people might be able to see your username and SSH key. You need to do this only once.
  • Open web browser and go to https://223.195.240.6X:1006 where X is the server number.
  • If you see a warning message from the browser, it is because you have not installed the certificates! If you risk it, you can click on Advanced and then Proceed to 223.195.240.6X (unsafe) to continue. The below figure is the login page of the GPU scheduler.

regular

  • Enter your username and select your private SSH key file, usually located at ~/.ssh/id_ed25519 (Linux/MacOS) or C:\Users\your_username\.ssh\id_ed25519 (Windows). Then click on the Login button. regular

  • You will be redirected to the dashboard page. Here is the screenshot of the dashboard page. regular

  • There are three main sections in the dashboard page:

    • Job Scheduler is for submitting and managing your jobs.
    • File Explorer is for managing and visually inspecting your files on the workstation.
    • Terminal is for running commands on the workstation.
  • We will use the Job Scheduler to submit and manage your jobs in the following sections.

    • Click on the Job Scheduler tab and you will see the job scheduler page regular
    • Command: command to run your code, e.g., python train.py. Please do NOT include CUDA_DEVICE_ORDER and CUDA_VISIBLE_DEVICES in the command as the GPU scheduler will automatically set them for you based on the GPU(s) you select below. Similarly, please do not use them in your code.
    • Working Directory: the directory where your code is located, e.g., /home/your_username/your_project
    • Conda Environment: the conda environment you want to use, you can select an existing environment by clicking on the dropdown menu
    • Experiment Note: any note you want to add for the job. This is optional
    • Notification Email: the email address you want to receive notifications about your job when it is finished or if there is an error. This is optional
    • GPU / CPU: select CPU or GPUs for your job. You can select multiple GPUs if you need.
    • You can save all the above information as a template for future use by clicking on the Save As... on the top left corner. This way, you do not need to fill in the information every time you submit a job.
    • Now you can submit your job by clicking on the Submit Task button. You will see your job in the Job Queue section. The below figure shows an example of a job submission and the job is running successfully. regular
    • The job will be managed automatically by the GPU scheduler. In case you select GPUs that are currently being used by other members, your job will be put in the Waiting List as below regular
    • Your job will start automatically when the GPU(s) you selected are available.
    • In this window, you can also View Log to inspect the process by clicking View Output regular
    • Then a log viewer will pop up. Here you can monitor GPUs, etc. and your job’s output in real time regular
    • In this window, in addition to ‘View Log’, you can also Kill and Delete you jobs.
    • If you job is killed or finished, an email notification will be sent to you if you have provided an email address regular
    • To inspect what happened to your job, you can click Activity Logs on the top left corner
  • In addition to the Job Scheduler, you can also use the File Explorer and Terminal. I believe you can figure out how to use them by yourself and hopefully they will be useful for you. If you have any questions about the GPU scheduler, please ask questions in our KakaoTalk group.


Data Transfer ๐Ÿšš

Secure File Transfer Protocol (SFTP) is required for transferring data between your PCs, workstations and NAS. There are several SFTP clients available for you to choose from, such as FileZilla, Bitvise, etc. For command line based software, sshfs, rclone, etc. are also available. In this tutorial, we will use FileZilla, sshfs, and rclone as examples.

  • FileZilla
    FileZilla is a free software and available for Windows, macOS, and Linux. It is easy to use and provides a user-friendly interface for transferring files between your PCs, workstations and NAS.
    Here are the steps to make a connection to workstations/NAS via FileZilla:

    • Download and install FileZilla

    • Head to File -> Site Manager -> New Site

    • Fill in the following information:

      • Protocol: SFTP - SSH File Transfer Protocol
      • Host: workstation/NAS’s IP address
      • Port: 1004
      • Logon Type: Normal
      • User: your_username
      • Password: your_password
    • Click Connect
      regular

      For the first time you connect to a workstation/NAS, you will be asked to verify the server’s fingerprint. Click on the OK button to continue.

      Note that the above steps are for the first time you connect to a workstation/NAS. After that, you can simply select a server and click on the Connect button to connect to the server.

    In the figure below, the left panel is for your local machine and the right panel is for the remote server (workstation/NAS). You can drag and drop files between these two panels to transfer data. To visually inspect the data, you can right-click on a file and select View -> Edit to open it.
    regular

  • sshfs
    sshfs is a command line based software that allows you to mount a remote file system via SFTP. In other words, you can access a folder on the workstation/NAS via a local folder on your PCs. To install sshfs, follow the instructions for Linux, Windows, and macOS.

    To mount a workstation/NAS folder on your local machine, follow these steps:

    • Open a terminal on your local machine.

    • Run the following command to mount a remote folder on your machine:

      sshfs your_username@remote_IP_address:/your_username/remote_folder -p 1004 local_folder
      

      In addition to your PCs, the above command can also be run on a workstation! This way, your workstation can access a NAS folder or another workstation’s folder.

      You will need to execute the above command every time you restart your PCs or workstations.

  • rclone
    rclone is another command line based software that allows you to transfer data between your PCs, workstations and NAS. It supports various cloud storage providers, including Google Drive, Dropbox, etc. To set up rclone on a local machine or a workstation, follow these steps:

    • Download rclone-version-os.zip based on your operating system
      regular
    • Unzip the downloaded file to a folder, for example, /home/user/rclone
    • Run the following command to set up a connection to a workstation/NAS:
    cd /home/user/rclone
    ./rclone config
    
    • Follow the instructions to set up a new connection:
      • Enter n to create a new remote
      • Enter the following information:
        • name: type any name for the connection, for example, nas
        • storage: type sftp for secure file transfer protocol
        • host: type the workstation/NAS’s IP address
        • user: type your username
        • port: type 1004
        • You will be asked to enter your password SSH password, leave blank to use ssh-agent.... Type y and press Enter. After that, enter your password and press Enter
        • For the rest of the questions, you can press Enter to use the default values until you see the main menu again
          regular
        • From the figure above, you can see that the connection nas has been successfully set up. Let’s test the connection by running the following command:
        ./rclone lsd nas:/
        
        regular
        • If you see a list of folders on the workstation/NAS, the connection is successful. You can now transfer data between your PCs, workstations and NAS using rclone with the following command:
        ./rclone copy -P --fast-list --drive-chunk-size=256M --multi-thread-streams=16 --transfers=4 --multi-thread-cutoff=256 local_folder nas:/remote_folder
        
        or simply
        ./rclone copy -P local_folder nas:/remote_folder
        
        There are many other features of rclone that you might want to explore. Execute ./rclone --help or visit Rclone Commands for more information.