-
select an Ubuntu server for 16GB RAM and atleast 30GB of storage
-
For Windows, create a config file:
HostName ec2-xx-X-xx-xx.ap-region-1.compute.amazonaws.com User ubuntu IdentityFile C:/Users/username/.ssh/mlops-pemfile.pem StrictHostKeyChecking no
- login to the server using
ssh mlops-practice - update
sudo apt update - download anaconda
wget https://repo.anaconda.com/archive/Anaconda3-2023.03-Linux-x86_64.sh - install anaconda
bash Anaconda3-2023.03-Linux-x86_64.sh - Create an Anaconda environment -
conda create -n mlops python=3.10.9and activate the sameconda activate mlops
- create a separate folder (
soft) for other tools - install docker
cd soft sudo apt install docker.io cd .. - install docker compose from github page
wget https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-linux-x86_64 - make the docker-compoise zip executable
chmod +x docker-compose-linux-x86_64 - set environment path
nano .bashrcand add at the endexport PATH="${HOME}/soft:${PATH}" - renameing docker compose for ease
mv docker-compose-linux-x86_64 docker-compose - check if rename and executable file conversion is done proberly
which docker-compose - run the codes to avoid using sudo for docker
sudo groupadd dockerandsudo usermod -aG docker $USER - test docker
docker run hello-world
- setup github
git config --global user.name "user_name"andgit config --global user.email "mail_id@domain.com"
- in VSCode, setup remote server using Connect to Host and add the
mlops-practiceconfig file
- install mlflow
pip install mlflow - initialte mlflow from the folder
mlopsso that it can be used for other projects as well - can install other requirements using
pip install -r requirements.txt - run mlflow using
mlflow ui --backend-store-uri sqlite:///mlflow.dbto store all the artifacts and meta data on the sqlite db mlflow.db - for test, run
python 2_experiment_tracking/main.py - check the mlflow url
- use the below codes to initialize the database to store metadata and setup the name of experiment to track
mlflow.set_tracking_uri("sqlite:///mlflow.db") mlflow.set_experiment("nyc-taxi-experiment-1")
-
Use linux free tier server
-
update the server
sudo yum update -
in case pip3 is not available
sudo yum update python3-pip -
install dependencies and packages -
pip3 install boto3 mlflow psycopg2-binary -
setup the instance with credentials
aws configureAWS Access Key ID [None]: xxxxxxxxxxxxxxxxxxx AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Default region name [None]: us-east-2 Default output format [None]: -
check the list of s3 buckets available
aws s3 ls -
setup the database
- go to AWS RDS and click on
Create Database - select PostgresSQL and Free Tier from Template
- update the below items
DB instance identifier : database-1 Master username : postgres Master password : ************* uncheck Enable storage autoscaling VPC security group (firewall): Choose existing Existing VPC security groups: lkaunch-wizard-xy - go to AWS RDS and click on
-
upload
configandcredentialsfiles from local system to ec2(used for model building)scp -i mlops-ec2-practice.pem C:\Users\myname\.aws\config ubuntu@ec2-xx-xxx-xxx-xxx.ap-south-1.compute.amazonaws.com:~/.scp -i mlops-ec2-practice.pem C:\Users\myname\.aws\credentials ubuntu@ec2-xx-xxx-xxx-xxx.ap-south-1.compute.amazonaws.com:~/. -
copy these files to .aws folder
mv config ~/.aws/andmv credentials ~/.aws/ -
run the below code to setup aws reference
aws ec2 describe-instances --profile "soumyadip" export AWS_PROFILE=soumyadip -
change the inbound rules of the mlflow tracking ec2 server using Edit Inbound Rules and add the Public IP4 adress of the Model training server
add both SSH and TCP for both local and ML model EC2 servers -
in the MLflow tracking server run
mlflow server -h 0.0.0.0 -p 5000 --backend-store-uri postgresql://DB_USER:DB_PASSWORD@DB_ENDPOINT:5432/DB_NAME --default-artifact-root s3://S3_BUCKET_NAME
mlflow server -h 0.0.0.0 -p 5000 --backend-store-uri postgresql://mlflow:namep@mlflow-database.xzyasdf.us-east-3.rds.amazonaws.com:5432/mlflow_db --default-artifact-root s3://artifacts-remote
- test using
3_model_registry/tracking_server.ipynband experiment details will be updated on the mlflow experiment UI - refer
3_model_registry/models_tracking.pyto train multiple models
