Setting up Pytorch

For my capstone project, I choose the topic Speech Enhancement using a Wavenet or a Wavegan approach. The main aim of this project is to enhance speech signals by the use of speech synthesis rather than the traditional noise removal approaches.

For understanding the existing methods for Speech Enhancement  I came across a GitHub code by "santi-pdp". In order to run this code, I had to install all the prerequisites which were mentioned in the readme file.

Setting up Pytorch:

I already had PyTorch installed on my virtual machine but was not able to utilize GPUs inside the virtual machine. In order to use GPU for training, I decided to set up PyTorch in windows which would allow me to use my laptop GPU (RTX 2070). 

Step 1 - INSTALLING ANACONDA :
In order to install PyTorch on windows, I had to install Anaconda. In order to install Anaconda I went to the following link:

After downloading the 64-bit version I installed the software using recommended options. 
In order to move forward, we need to use the anaconda command prompt instead of the normal command prompt for PyTorch installation. 

After opening the anaconda command prompt, I followed the instructions for installation of PyTorch on their official website: https://pytorch.org/get-started/locally/  

I created a separate environment in order to install PyTorch by typing the following command:
"conda create --name test". Here test is the name of the environment which could be as per your choice. 
You could then activate the environment by "conda activate test".
Then copy the command which is specific to your system mentioned on the PyTorch website. For me it was : 
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch

In order to check if you have currently installed torch and torchvision correctly :
Type python in order to run python code interactively.
Then type import torch and press enter. 
After pressing enter, type the command print(torch.__version__) and press enter to display your torch version. In my case it was 1.4.0

To check torchvision version, import torchvision and then type print(torchvision.__version__) and this should display the version of torchvision that is currently installed in the environment. For me, the version of torchvision installed was: 0.5.0.

Step 2 - MAKING ENVIRONMENT AVAILABLE TO JUPYTER NOTEBOOK

Install ipykernel as the kernels available in jupyter notebooks are iPython Kernels. 
The command for installing ipykernel is :
conda install ipykernel

In order to check if your kernel has been setup or not, go to jupyter notebooks and create a new file.
Select the kernel option and in the dropdown menu go to the change kernel selection. If your environment name shows up there then you are good to go.

For me the my environment name was not listed in the selection.

Turns out the way to solve this is to install the nb_conda_kernels package. The issue was because this package was not installed in the environment. In order to that you need to type 
conda install -n test ipykernel
where test is the name of the environment.
After installing ipykernel you need to type jupyter notebook in the terminal which would then open jupyter notebook and then you could see your environment listed in the kernel list.
After finishing this in order to make sure I had all the elements necessary for running the code, I checked CUDA version by typing:
conda list cudatoolkit  
In my case the cuda version is 10.1.243

In order to run the code properly,I had to install certain packages.


INSTALLING SoundFile :

SoundFile is an audio library which can read and write sound files.

conda install -c conda-forge pysoundfile

INSTALLING scipy and matplotlib:

conda install -c conda-forge scipy matplotlib

INSTALLING Librosa:

Librosa is a python package used for audio and music analysis.

conda install -c conda-forge librosa

INSTALLING h5py:

The h5py package provides an interface to the HDF5 binary data format. HDF5(Hierarchical Data Format 5) is an open source file format that supports large complex heterogeneous data. 

conda install -c conda-forge h5py

Installing Numba:

Numba is a just in time compiler for python that makes the code computation faster to the level of c or Fortran code.
conda install numba

Installing pyfftw:
pyfftw is a pythonic wrapper around fftw, the c library for fast fourier transform.

Command for installation:
conda install -c conda-forge pyfftw

Installing tensorboardX:

conda install -c conda-forge tensorboardx

Installing ahoproc tools:
Ahoproc tools is a repository on git.
In order to install ahoproc tools, you need to install git.



conda install -c git

After installing git I cloned the git repository which had ahoproc tools using the command:

git clone https://github.com/santi-pdp/ahoproc_tools

Next step is to cd into ahoproc_tools and run the setup.py file.

python setup.py install

Comments

Popular posts from this blog

A Wavenet for Speech Denoising