Previous class
Custom AI - Python - Streamlit - MiniConda
This class you will learn how to:
- Set-Up a mini-conda environment
- deploy a Custom AI Instance
Set-Up MiniConda
You should do this as the user/domain folder which will be the host.
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
After installing, initialize your newly-installed Miniconda. The following commands initialize for bash and zsh shells:
~/miniconda3/bin/conda init bash
~/miniconda3/bin/conda init zsh
Restart the shell
exec bash
Source the updated .bash configuration
source ~/.bashrc
Create your conda environment
conda create --name aiinstancename python=3.11
Activate your conda enviroment
conda activate aiinstancename
Install dependancies
pip install streamlit pip install openai
Set up the System Service
This you need to do as root
su -
Create the service eg: aiinstance.service
[Unit]
Description=v1 client
After=network.target
[Service]
User=flastcom
WorkingDirectory=/home/xxxcom/xxxServers/aiinstance
ExecStart=/home/xxxcom/miniconda3/envs/aiinstance/bin/python -m streamlit run /home/xxxcom/xxxServers/aiinstance/app_anyscale_streamlit.workswithprompt.py --server.port 35003
Restart=always
[Install]
WantedBy=multi-user.target
Enable - Start - Status
systemctl enable aiinstance.service systemctl start aiinstance.service systemctl status aiinstance.service
You should see your aiinstance running like this
[root@server:system]$ systemctl status v1-lmw.client.service
? v1-lmw.client.service - v1 client
Loaded: loaded (/etc/systemd/system/v1-lmw.client.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2024-02-08 00:48:40 EST; 7s ago
Main PID: 1822956 (python)
CGroup: /system.slice/v1-lmw.client.service
??1822956 /home/xxxcom/miniconda3/envs/aiinstance/bin/python -m streamlit run /home/xxxcom/xxxServers/aiinstance/app_anyscale_streamlit.workswithprompt.py --server.port 35003
Feb 08 00:48:40 server.xxx.life systemd[1]: Started v1 client.
Feb 08 00:48:42 server.xxx.life python[1822956]: Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.
Feb 08 00:48:42 server.xxx.life python[1822956]: You can now view your Streamlit app in your browser.
Feb 08 00:48:42 server.xxx.life python[1822956]: Network URL: http://xxx.249.5.201:35003
Feb 08 00:48:42 server.xxx.life python[1822956]: External URL: http://xxx.249.5.201:35003
Finally you need to use stunnel to push the http over https:
[File-AiInstance-domain]
accept = 35003 # this is the http port
connect = 35004 # this is the https port
cert = /var/cpanel/ssl/apache_tls/xxx.com.au/combined #these are the domains SSL certs locations
key = /var/cpanel/ssl/apache_tls/xxx.com.au/combined
Next class