Octoprint via Helm and Kubernetes

Hits: 55

This repository contains Helm chart configurations for deploying OctoPrint project. The setup.sh script allows you to easily configure and deploy the chart.

Direct Repo address for those with Kubernetes and Helm knowledge: https://github.com/kzorluoglu/octoprint-helm

Prerequisites

– Helm v3.x
– Kubernetes cluster
– Bash shell

Usage

Clone the Repository

git clone https://github.com/yourusername/yourrepository.git
cd yourrepository

Run the Setup Script

First, make the script executable:

chmod +x setup.sh

Then, run the script:

./setup.sh

The script will prompt you for the following information:

  • hostname: The hostname for your application.
  • dataPath: The path where data will be stored.
  • configPath: The path where the configuration file will be stored.
  • projectname: The name of the Helm project.

These values will be used to populate the config.yaml file, which will be used for the Helm installation.

Helm Install

The script will automatically run helm install with the provided project name and config.yaml file.

This will deploy your Helm chart with the configurations you’ve specified.

Troubleshooting

If you encounter any issues, please check the config.yaml file to ensure all values are correctly set. You can manually edit this file and rerun helm upgrade if needed.

MJPG-streamer installation and run at System Startup using Systemd – Ubuntu Server

Hits: 54

mjpg-streamer is a popular tool for streaming MJPEG video from webcams. In this tutorial, we will learn how to configure mjpg-streamer to run automatically at system startup using a systemd service unit file.

Installation via Snap

sudo snap install mjpg-streamer
#give camera access
snap connect mjpg-streamer:camera

Step 1: Create the Service Unit File

  1. Open a terminal on your Linux system.
  2. Run the following command to create a new systemd service unit file
sudo nano /etc/systemd/system/mjpg-streamer.service

In the text editor, paste the following content:

[Unit]
Description=MJPG Streamer
After=network.target

[Service]
ExecStart=ExecStart=mjpg-streamer -i "input_uvc.so" -o "output_http.so -w /home/kzorluoglu/charts/octoprint/www"
Restart=always

[Install]
WantedBy=multi-user.target

Step 2: Enable and Start the Service

  1. Reload the systemd daemon to read the new service unit file:
    • sudo systemctl daemon-reload
  2. Enable the service to start at boot
    • sudo systemctl enable mjpg-streamer.service
  3. Start the service:
    • sudo systemctl start mjpg-streamer.service
  4. Verify that the service is running without any errors
    • sudo systemctl status mjpg-streamer.service
  5. You should see the status of the service, indicating that it is active and running.
  6. Check the Webcam Output:
    • http://youriporhostname:8080/?action=stream

BONUS:

if you want to run mjpg-streamer without sudo, you can try the following steps. Add your user to the video group:

sudo usermod -aG video <your_username>

AI Model Trainer with EleutherAI/gpt-j-6b for Chameleon Shop Codes

Hits: 66

The Trainer use actually the best chatgpt alternative model on huggingface. Here is the Training notice from Original Source:

This model was trained for 402 billion tokens over 383,500 steps on TPU v3-256 pod. It was trained as an autoregressive language model, using cross-entropy loss to maximize the likelihood of predicting the next token correctly.

https://huggingface.co/EleutherAI/gpt-j-6b#training-procedure

Dataset Links: https://d8devs.com/chameleon-base-and-chameleon-shop-datasets-20230530-1918/



import os
import pandas as pd
import torch
from sklearn.model_selection import train_test_split
from transformers import TrainingArguments, Trainer, AutoModelForCausalLM, AutoTokenizer

checkpoint = "EleutherAI/gpt-j-6b"  # Model checkpoint updated

device = "cuda" if torch.cuda.is_available() else "cpu"

model = AutoModelForCausalLM.from_pretrained(checkpoint, trust_remote_code=True)

tokenizer = AutoTokenizer.from_pretrained(checkpoint, trust_remote_code=True)
if tokenizer.pad_token is None:
    tokenizer.pad_token = tokenizer.eos_token

model = AutoModelForCausalLM.from_pretrained(checkpoint, trust_remote_code=True)
model.to(device)

# Load your data
data = pd.read_csv(os.getcwd() + 'chameleon_base_dataset20230530-1942.csv')

# Prepare your data
# You need to decide how to use your CSV data to create training examples for the model.
# For example, you might concatenate the 'description', 'code', and 'explanation' fields into a single string.
texts = data['description'] + ' ' + data['code'] + ' ' + data['explanation']
labels = data['classname']

# Tokenize your data
inputs = tokenizer(texts.tolist(), padding=True, truncation=True, max_length=512, return_tensors='pt')
inputs['labels'] = torch.tensor(labels.tolist())  # assuming labels are numerical

# Split data into training and validation sets
train_inputs, val_inputs, train_labels, val_labels = train_test_split(inputs, labels, test_size=0.2)

# Define training arguments
training_args = TrainingArguments(
    output_dir='./results',          # output directory
    num_train_epochs=3,              # total number of training epochs
    per_device_train_batch_size=16,  # batch size per device during training
    per_device_eval_batch_size=64,   # batch size for evaluation
    warmup_steps=500,                # number of warmup steps for learning rate scheduler
    weight_decay=0.01,               # strength of weight decay
    logging_dir='./logs',            # directory for storing logs
    load_best_model_at_end=True,     # load the best model when finished training (default metric is loss)
    # but you can specify `metric_for_best_model` argument to change to accuracy, f1, etc.
)

# Initialize our Trainer
trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=train_inputs,
    eval_dataset=val_inputs,
)

# Training
trainer.train()

# Saving the fine-tuned model
model.save_pretrained('EleutherAI/gpt-j-6b-chameleon')