# IDE and Useful Tools

## IDE and Useful Tools

This section is intended to recommend an IDE and helpful tools for beginners running FedPruning. If you already have a preferred IDE and tools, feel free to skip this section.

### IDE Setup

Since FedPruning is built with Python, we recommend beginners use either VSCode or PyCharm. In this guide, we’ll provide instructions for setting up VSCode.

#### Installing VSCode

You can download VSCode for your system from its [official website](https://code.visualstudio.com/). It’s free to use.

#### Installing Extension

As many users run their code on a remote server, VSCode offers functionality for working with files on remote machines. To enhance your workflow, install the necessary extensions for remote development in VSCode:

1. Open the Extensions view by clicking the square icon ![](https://1390655419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgaUoRi1J9UJefJk6eUE3%2Fuploads%2Fgit-blob-827f73e552fceaf6b6521c98a7768df29c7827b0%2Fextensionicon.png?alt=media) in the sidebar or by pressing Ctrl+Shift+X.
2. In the search bar, type **Remote - SSH** and **Remote Development**.
3. Install both the **Remote - SSH** and **Remote Development**.

![Remote - SSH](https://1390655419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgaUoRi1J9UJefJk6eUE3%2Fuploads%2Fgit-blob-0cdefd46b89f53f8f6349614b4f3282d136f921f%2Fremotessh.png?alt=media) ![Remote Development](https://1390655419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgaUoRi1J9UJefJk6eUE3%2Fuploads%2Fgit-blob-f224d6f0b2ac351088926d9f36d1d248ef4d5546%2FRemoteDevelop.png?alt=media)

#### Access to the Remote Server

**Step 1**: follow these steps to open the configuration file in the Remote Explorer :

![Open the configuration file in the Remote Explorer](https://1390655419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgaUoRi1J9UJefJk6eUE3%2Fuploads%2Fgit-blob-55e64d42bf4328a8c3f53ded894cf551c72dfb2e%2Fsetssh.jpg?alt=media)

**Step 2**: Edit the configuration file to connect to the remote server.

Direct Connection Example: If the server IP is 192.0.0.1 and the username is hong, add the following lines:

```
Host remote_server
    HostName 192.0.0.1
    Port 22
    User hong
```

Using a Jump Server: If you need to connect via a jump server (e.g., the IP is jumpserver.com), add the following lines:

```
Host jump_server
    HostName  jumpserver.com 
    Port 22
    User hong

Host remote_server
    HostName 192.0.0.1
    Port 22
    User hong
    ProxyCommand ssh -W %h:%p jump_server
```

Save the configuration file. You should now see the target server listed in the Remote Explorer:

![remote server in the Remote Explorer](https://1390655419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgaUoRi1J9UJefJk6eUE3%2Fuploads%2Fgit-blob-526c16383bc8166d28ce8f3fb3f2d2a956c13d27%2Fopenssh.png?alt=media)

**Step 3**: select remote\_server from the Remote Explorer. If using a jump server, you’ll first be prompted to enter the jump server password, followed by the remote server password. Once connected, you can access the file system and open a remote terminal directly on the server.

## Some Useful tools

We recommend some helpful tools to make running FedPruning more efficient and comfortable.

### Tmux

When running multiple experiments, especially those that take a long time, closing the terminal can stop your code. To avoid this, we recommend using **Tmux**, which allows you to manage multiple terminal session and run experiments in the background. This guide will cover basic Tmux usage, but you can find more detailed documentation [here](https://github.com/tmux/tmux/wiki).

#### Example: Running Two Python Files Simultaneously

In this example, we will run two Python files, test1.py and test2.py, at the same time.

#### Installation

To install Tmux, run:

```
apt install tmux
```

#### Opening a New Session

To run test1.py, first create a new Tmux session, naming it s1, by entering the following in the terminal:

```
tmux new -s s1
```

This will open a new session (s1) with a default window. You can now run test1.py inside this session.

#### Detach a Session

While test1.py is running, you’ll want to start test2.py. To do so, you need to detach from the current session. Press Ctrl+B (Control+B), then press D to detach and return to the main terminal. You can now open a new session to run the second Python file.

#### Attach to a Session

If you want to check the progress of test1.py, you can re-enter the s1 session by using the following command:

```
tmux attach -t s1
```

#### Delet a Session

To delete an unused session, for example, s1, simply use this command:

```
tmux kill-session -t s1
```

### gpustat

gpustat is a tool that shows GPU memory statistics. To install it, run:

```
pip install gpustat
```

Once installed, you can check the GPU status by entering:

```
gpustat
```

### Weights & Biases (WandB)

Weights & Biases (WandB) is a machine learning development platform that enables users to track and visualize various aspects of their model training in real-time. To install it, run the following command:

```
pip install wandb
```

After installation, you’ll need to log in to WandB to start tracking your experiments. To do this, run:

```
wandb login 
```

Follow the instructions to enter your API key.

FedPruning already includes WandB integration, so when you run FedPruning, you can monitor your model’s training progress on the WandB website at <https://wandb.ai/home>. Below is an overview of the WandB workspace:

![Overview of the WandB workspace](https://1390655419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgaUoRi1J9UJefJk6eUE3%2Fuploads%2Fgit-blob-5b96aaa22b93982dbeef87b1f13e64213a695915%2Fwandb.png?alt=media)

If you don’t want to upload experiment data while testing or debugging, you can switch to offline mode by running:

```
wandb offline
```

WandB will stop sending data until you switch back to online mode by running:

```
wandb online
```

For more details on how to use WandB in projects, refer to the official documentation at <https://docs.wandb.ai/>.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://honghuangs-organization.gitbook.io/fedpruning-documents/installation/ide-and-tools-setting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
