# Tutorial: Setting Up a Collaborative Jupyter Lab

This tutorial outlines the steps to set up a collaborative Jupyter Lab environment for multiple users. Make sure to follow each step carefully.

#### **A. Initial Preparation**

1. **Create a Tmux Session:**
    
    
    - Open your terminal and run the command: `tmux new -t your_session_name` (replace "your\_session\_name" with your desired name).
    - **What is Tmux?**
        
        
        - It keeps your terminal session active even if the SSH connection is lost.
        - It allows you to access the terminal session from different locations.
    - **Important Tmux commands:**
        
        
        - To exit the session: Press `Ctrl+b` then `d`.
        - To re-enter the session: `tmux a -t your_session_name`.
    - For more information on tmux, visit: [https://tmuxcheatsheet.com/](https://tmuxcheatsheet.com/)
2. **Create a Conda Environment:**
    
    
    - Ask all users for the required Python version.
    - Create a conda environment with the command: `conda create -n your_env_name python=python_version` (replace "your\_env\_name" and "python\_version" accordingly).
        
        
        - Example: `conda create -n collaboration python=3.9`
    - Activate the environment: `conda activate your_env_name`
3. **Create a Working Directory:**
    
    
    - Create a new directory to store your collaborative project. You can use the initials of each team member or person (e.g., NF, MH, RDWP).
    - Command: `mkdir your_directory_name`
    - Enter the directory: `cd your_directory_name`

#### **B. Installing and Configuring Jupyter Lab**

4. **Install Jupyter Lab and Jupyter-Collaboration:**
    
    
    - Ensure that the conda environment you created earlier is active.
    - Install Jupyter Lab and Jupyter-Collaboration: `pip install jupyter jupyter-collaboration`
    - Alternatively: Install them when creating the conda environment by adding `jupyter jupyter-collaboration` to the end of the `conda create` command.
5. **Run Collaborative Jupyter Lab:**
    
    
    - Run the following command in the terminal: `jupyter lab --collaborative --allow-root --no-browser --ip=0.0.0.0 --port your_desired_port`
    - Replace "your\_desired\_port" with the port number you want to use.
6. **Save the Jupyter Token:**
    
    
    - After running the command above, a link containing a token will appear.
    - **IMPORTANT:** Save this token securely. Other people can access your Jupyter Lab if they know this token.

#### **C. Tunnel Configuration and Jupyter Lab Access**

7. **Provide Jupyter Lab Details:**
    
    
    - Inform the tunnel administrator (in this case, Naufal Faza) of the following information:
        
        
        - The name of the PC where Jupyter Lab is running.
        - The port number used.
        - The requested subdomain (if any).
        - Example: `uas-ai.digilabdte.com`, the subdomain is `uas-ai`.
8. **Access Jupyter Lab:**
    
    
    - After the tunnel administrator has completed the configuration, you will be given a link to access Jupyter Lab.
    - The link will look like this: `your_requested_subdomain.digilabdte.com/lab?token=your_token_value`.
    - Don't forget to enter the token you obtained in step 6.
9. **Start Collaborating:**
    
    
    - Inside Jupyter Lab, you can access the terminal and monitor resource usage with `nvtop`.
    - Make sure to coordinate with your team via group chat to avoid conflicts when running programs. Remember that Jupyter Lab is like Google Docs, so collaboration is real-time.