> For the complete documentation index, see [llms.txt](https://diff-svc.gitbook.io/the-beginners-guide-to-diff-svc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://diff-svc.gitbook.io/the-beginners-guide-to-diff-svc/setting-up/setting-up-the-environment.md).

# Setting up the Environment

Setting up the environment is probably the "hardest" part for many people.

## Set up Python Environment

{% hint style="info" %}
This project is tested under **Python 3.8**. Other versions may cause issues.
{% endhint %}

To avoid conflict with other projects, it's recommended to use a virtual environment. We will use [Anaconda](https://www.anaconda.com/products/distribution) in this guide, you can also use [Miniconda](https://docs.conda.io/en/latest/miniconda.html) or other options if you are familiar with them.

### Using Conda

1. Download and install Anaconda: <https://www.anaconda.com/products/distribution>

{% hint style="info" %}
If you are on a Windows machine, go to Start -> Anaconda3 -> Anaconda Prompt to use the **Anaconda Prompt** that you just installed to run the following steps. \
\
(NOT *Anaconda Powershell Prompt* since commands will be slightly different on Powershell)
{% endhint %}

2. Run this command to create a virtual environment with Python 3.8 named *diff-svc* (you can also use other names):

```
conda create -n diff-svc python=3.8
```

3. Next, run this command to activate the virtual environment you just created:

```
conda activate diff-svc
```

If the next line starts with `(diff-svc)`, the virtual environment is activated successfully.&#x20;

{% hint style="info" %}
Make sure you are in this environment when running the commands later in this guide.
{% endhint %}

## Install Diff-SVC Dependencies

1. Go to Diff-SVC's [GitHub repository](https://github.com/prophesier/diff-svc), click on code -> Download ZIP

> Alternativly, use git clone if you know what it is

<figure><img src="https://502630556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFg9oD4efto6wDWIyTcNi%2Fuploads%2FWuc7BJz9V03gSEzUpVBs%2Fimage.png?alt=media&amp;token=6aba991a-3388-4e1f-958a-b0a1badf6e8b" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Do **NOT** download from Releases, it's not the latest version.
{% endhint %}

2. Extract the zip file, you should now have a diff-svc-main folder.
3. [Navigate](/the-beginners-guide-to-diff-svc/appendix.md#navigate-to-a-directory-in-cmd) to the diff-svc-main folder in the command line and make sure you are in the `diff-svc` environment.
4. Run this command to install PyTorch:

   ```
   conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
   ```

{% hint style="info" %}
This command may not apply to everyone. You can run `nvidia-smi` to check the highest supported CUDA version of your GPU, then use the command from <https://pytorch.org/get-started/locally/> to download the corresponding version.
{% endhint %}

{% hint style="info" %}
If your supported CUDA version is lower than 11.6 even after upgrading the NVIDIA Driver, try using  `conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3` to install the 11.3 version.&#x20;
{% endhint %}

5. Run this command to install other required packages:

   ```
   pip install -r requirements_short.txt
   ```

{% hint style="info" %}
If you are on a Windows machine, you may encounter an error that says `Microsoft Visual C++ 14.0 or greater is required` when building `webrtcvad`. You can follow the instruction on the error message and install [the latest build tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) or just install [Visual Studio](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community\&channel=Release\&version=VS2022\&source=VSLandingPage\&passive=false\&cid=2030).
{% endhint %}

## Install Tensorboard (Optional)

Tensorboard helps you visualize ***training***. This step is not required for the program to function but it's recommended to do.&#x20;

Run this command in the diff-svc environment to install Tensorboard.

```
pip install tensorboard
```

## Install Jupyter Notebook and Create Kernel (Optional)

One of the options for ***inference*** is using [Jupyter Notebook](https://jupyter.org/). This step is not required if you want to use other tools for inference or if you want to use other programs (like [VSCode](https://code.visualstudio.com/)) that also support Jupyter Notebook. You may decide if you want to do it this way and come back later.

1. Run this command to install Jupyter Notebook

```
conda install notebook
```

To make the diff-svc environment visible in Jupyter, you need to create a kernel.&#x20;

2. Run this command to install ipykernel:

```
conda install ipykernel
```

3. Create a kernel named `diff-svc` (you can also use other names):

```
ipython kernel install --user --name=diff-svc
```

## Download the Required Checkpoints

You also need to download some model checkpoints and place them correctly.

<figure><img src="https://502630556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFg9oD4efto6wDWIyTcNi%2Fuploads%2Fl8X3rQ3IgRUj7dhJaU9g%2Fimage.png?alt=media&amp;token=544ebb71-4ea6-421f-8060-b705526aa014" alt=""><figcaption><p>Folder Structure</p></figcaption></figure>

1. Get checkpoints.zip from the Diff-SVC Discord server or some other mirror links online.
2. Extract the folders inside and put them under a folder called `checkpoints` under your diff-svc folder.
3. **(If you want to train a 44.1kHz model)**, you should also download the 44.1kHz vocoder from [here](https://github.com/openvpi/vocoders/releases). (You only need `nsf_hifigan_xxxxxx.zip`, ignore the "finetune" and "onnx" ones)
   1. Extract the zip file and put the `nsf_hifigan` folder under `checkpoints`.
   2. *(The 24kHz vocoder is not needed in this case, but you can also keep it there)*
