# Unsupervised ASR
## Local container (with gpu acceleration)
The container we use would be [Nvidia Pytorch Release 21.06](https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/rel_21-06.html#rel_21-06) and would require latest version of docker.
### docker engine installation (for linux)
The reason using docker is because it won't ruin your computer, simply remove the container will do if something went wrong unfortunately
1. Set docker's apt library
```
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the repository to Apt sources:
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
```
2. Install the package
```
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```
3. Verification
```
sudo docker run hello-world
```
for more information, please refer to [docker](https://docs.docker.com/engine/install/ubuntu/)
4. Postmodification (optional)
```
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
docker run hello-world
```
for more details, please visit [docker](https://docs.docker.com/engine/install/linux-postinstall/#:~:text=If%20you%20don%27t%20want,members%20of%20the%20docker%20group.)
### Nvidia Container (NGC)
Using version pytorch:21.06-py3
```
docker run --gpus all --ipc=host -it --rm nvcr.io/nvidia/pytorch:21.06-py3
```
Then in the new terminal (something like root@id)
```
sudo apt update
sudo apt-get install -y libfftw3-dev libsndfile1-dev libgoogle-glog-dev libopenmpi-dev libboost-all-dev
```
Finish building container
## Setup
### Install Miniconda
1. Get miniconda through curl
```
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o Miniconda3-latest-Linux-x86_64.sh
```
2. Set Execute Permission
```
chmod +x Miniconda3-latest-Linux-x86_64.sh
```
3. Install Miniconda
```
bash Miniconda3-latest-Linux-x86_64.sh
```
(Say yes to all the question it asked)
4. Restart bash
```
source ~/.bashrc
```
5. Verify
```
which conda #the result should not be under /opt
```
### Other steps
Absolutely same as the one TA has given
### Some bugs
You might encounter installation error when installing **flashlight**, which gives MKL library not found.
1. set CMAKE_PREFIX_PATH
``` bash
export CMAKE_PREFIX_PATH='/path_to_miniconda/envs/env_name/lib'
```
You might then see MKL headers not found
2. set CMAKE_INCLUDE_PATH
```
conda install mkl-include
```
``` bash
# in ~/.bashrc
export CMAKE_INCLUDE_PATH='/path_to_miniconda/envs/env_name/inculde'
```
you can refer to [stackoverflow](https://stackoverflow.com/questions/51109662/mkl-service-h-header-missing-from-anaconda-mkl-install/77152967#77152967)
### Tensorboard
If you want to show the tensorboard on docker, please check if you have open ports by ```docker ps -a``` under the PORTS category. Then in the docker terminal
``` bash
tensorboard --host=internal_ip --port=open_port --logdir=tb_folder_path
```
where internal_ip could be get by ```ifconfig```, which needs to be installed through ```apt-get install net-tools```. Windows system might be different, but the logic should be the same