New Computer Setup
Follow these instructions when installing the IoT-GPT app on a new computer. The checklist to verify during the final round is followed by the setup section.
Setup
1. Prepare Environment
Launch WSL2 (Ubuntu) and stay in the user's home directory.
Install PSQL:
sudo apt update
sudo apt install postgresql postgresql-contrib
# check if service is running
sudo service postgresql status
# start the service if necessary
sudo service postgresql startInstall Conda:
git clone https://github.com/fastai/fastsetup.git
cd fastsetup
source setup-conda.sh
. ~/.bashrc
conda install -yq mambaAdd conda bash aliases:
# Run the command:
nano ~/.bash_aliases
# Paste these aliases into the file:
alias a=alias
a cls="clear"
a multipull="ls | parallel git -C {} pull"
a jp="jupyter notebook --no-browser"
a jl="jupyter lab --no-browser"
a ca="conda activate ''"
a mkpth="conda create -n pth python=3.10"
a cals="conda env list"
a gs='git status'
# Close, save, and source the file:
ctrl+x
y
source ~/.bash_aliasesInstall Cuda:
sudo apt-key del 7fa2af80
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda-repo-wsl-ubuntu-12-2-local_12.2.2-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-12-2-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo dpkg -i cuda-repo-wsl-ubuntu-12-2-local_12.2.2-1_amd64.deb
sudo apt-get update
sudo apt-get -y install cudaAdd SSH key for GH cloning (no passphrase needed). Make sure you add this new key in GitHub account under Settings > SSH and GPG Keys.
ssh-keygen -t ed25519 -C "sudhir@gqc.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Create an ai3 dir and clone the 3 repositories:
mkdir /home/gqc/git
mkdir /home/gqc/git/gqc
mkdir /home/gqc/git/gqc/ai3
cd /home/gqc/git/gqc/ai3
git clone git@github.com:gqc/ai3-hackathon.git
git clone git@github.com:gqc/ai3-api-drf.git
git clone git@github.com:gqc/ai3-frontend-react.gitNavigate to the main codebase:
cd /home/gqc/git/gqc/ai3/ai3-hackathonSetup the Python virtual environment (both vanilla Python with venvwrapper and Conda have been tested).
# NOTE: Sudhir and Jake can't get the conda env to work properly, so we're just moving forward with the root conda env.
pip install -r requirements.txt
pip install -e .Pull and extract the LFS files:
# Install LFS
sudo apt install git-lfs
# Pull LFS files:
git lfs pull
# Install unzip
sudo apt install unzip
# unzip the files:
unzip input_data.zip
unzip PSIAP_AI3.zipLogin and cache huggingface credentials:
python
import huggingface_hub as hf
hf.login()
# Paste this key:
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
# Add token as git credential? (Y/n)
n
quit()Install mosquitto MQTT:
sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
sudo apt-get update
sudo apt-get install mosquitto mosquitto-clients
sudo apt clean
2. Setup Database and API
Open a terminal and run these commands:
cd /home/gqc/git/gqc/ai3/ai3-api-drf
ca base # or ca ai3 if you made a venv
pip install -r requirements-essential.txt
cd scripts
./1_install_psql.sh
sudo su postgres
psqlIn the resulting PSQL command window, run these commands:
SELECT 'CREATE DATABASE ai3'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'mydb')\gexec
ALTER USER postgres WITH PASSWORD 'gq010102';
\qExit the postgres user:
exitContinue in the terminal:
cd /home/gqc/git/gqc/ai3/ai3-api-drf
ca base # or ca ai3 if you made a venv
python manage.py migrateNOTE If the migrate fails because postgres might not be listening on the IP/port, try changing the PORT value in settings.py to 5433 instead of 5432.
Run the API:
python manage.py runserver 0.0.0.0:8000
3. Setup and Start Frontend
Check Node version:
node --version.If node is less than 16, uninstall and reinstall a higher version:
Uninstall existing node versions:
sudo apt remove '^node.*$'
sudo apt remove '^libnode.*$'
apt-get purge nodejs &&\
rm -r /etc/apt/sources.list.d/nodesource.list &&\
rm -r /etc/apt/keyrings/nodesource.gpgInstall newer version:
# Download and import the Nodesource GPG key
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
# Create deb repository
NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
# Run Update and Install
sudo apt-get update
sudo apt-get install nodejs -y
Install yarn globally:
sudo npm install -g yarncd /home/gqc/git/gqc/ai3/ai3-frontend-reactInstall dependencies:
yarn installStart the app:
yarn start
4. Start Publisher
Open a terminal and run these commands:
cd /home/gqc/git/gqc/ai3/ai3-hackathon
# activate env
ca base
# start publisher
multi-publisher
5. Start Subscriber
- Open a terminal.
cd /home/gqc/git/gqc/ai3/ai3-hackathon- For first time setup:
- Start the subscriber:
multi-subscriber -c subscriber-multi.ymlNOTE If the connection to DB fails, check port 5432 vs 5433. - After the model loads (it will take a few minutes), kill the subscriber process.
- Switch huggingface model to offline mode:
export HF_DATASETS_OFFLINE=1
export TRANSFORMERS_OFFLINE=1
- Start the subscriber:
- After the first setup has been complete, you can start the subscriber with the command:
multi-subscriber -c subscriber-multi.yml