Shortcuts

Building on Windows

To build TorchAudio on Windows, we need to enable C++ compiler and install build tools and runtime dependencies.

We use Microsoft Visual C++ for compiling C++ and Conda for managing the other build tools and runtime dependencies.

1. Install build tools

MSVC

Please follow the instruction at https://visualstudio.microsoft.com/downloads/, and make sure to install C++ development tools.

Note

The official binary distribution are compiled with MSVC 2022. The following section uses path from MSVC 2022 Community Edition.

Conda

Please follow the instruction at https://docs.conda.io/en/latest/miniconda.html.

2. Start the dev environment

In the following, we need to use C++ compiler (cl), and Conda package manager (conda). We also use Bash for the sake of similar experience to Linux/macOS.

To do so, the following three steps are required.

  1. Open command prompt

  2. Enable developer environment

  3. [Optional] Launch bash


The following combination is known to work.

  1. Launch Anaconda3 Command Prompt.


    https://download.pytorch.org/torchaudio/doc-assets/windows-conda.png

    Please make sure that conda command is recognized.


    https://download.pytorch.org/torchaudio/doc-assets/windows-conda2.png

  2. Activate dev tools by running the following command.

    We need to use the MSVC x64 toolset for compilation. To enable the toolset, one can use vcvarsall.bat or vcvars64.bat file, which are found under Visual Studio’s installation folder, under VC\Auxiliary\Build\. More information are available at https://docs.microsoft.com/en-us/cpp/build/how-to-enable-a-64-bit-visual-cpp-toolset-on-the-command-line?view=msvc-160#use-vcvarsallbat-to-set-a-64-bit-hosted-build-architecture

    call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
    

    Please makes sure that cl command is recognized.

    https://download.pytorch.org/torchaudio/doc-assets/windows-msvc.png
  3. [Optional] Launch bash with the following command.

    If you want a similar UX as Linux/macOS, you can launch Bash. However, please note that in Bash environment, the file paths are different from native Windows style, and torchaudio.datasets module does not work.

    Miniconda3\Library\bin\bash.exe
    
    https://download.pytorch.org/torchaudio/doc-assets/windows-bash.png

3. Install PyTorch

Please refer to https://pytorch.org/get-started/locally/ for the up-to-date way to install PyTorch.

4. [Optional] cuDNN

If you intend to build CUDA-related features, please install cuDNN.

Download CuDNN from https://developer.nvidia.com/cudnn, and extract files in the same directories as CUDA toolkit.

When using conda, the directories are ${CONDA_PREFIX}/bin, ${CONDA_PREFIX}/include, ${CONDA_PREFIX}/Lib/x64.

5. Install external dependencies

conda install cmake ninja

6. Build TorchAudio

Now that we have everything ready, we can build TorchAudio.

git clone https://github.com/pytorch/audio
cd audio
# In Command Prompt
pip install -e . -v --no-build-isolation
# In Bash
pip install -e . -v --no-build-isolation

Note

Due to the complexity of build process, TorchAudio only supports in-place build. To use pip, please use --no-use-pep517 option.

pip install -v -e . --no-use-pep517

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources