thedebugdiary
thedebugdiary
The Debug Diary
6 posts
🛠 Welcome to TheDebugDiary! 💻 Your go-to spot for byte-sized solutions to all your coding & tech dilemmas. From boot fixes to Kubernetes hacks, follow my journey as I navigate the digital maze. 🤖 #DebuggingLife 💡
Don't wanna be here? Send us removal request.
thedebugdiary · 2 years ago
Text
A Minimal Guide to Deploying MLflow 2.6 on Kubernetes
Introduction
Deploying MLflow on Kubernetes can be a straightforward process if you know what you're doing. This blog post aims to provide a minimal guide to get you up and running with MLflow 2.6 on a Kubernetes cluster. We'll use the namespace my-space for this example.
Prerequisites
A running Kubernetes cluster
kubectl installed and configured to interact with your cluster
Step 1: Create the Deployment YAML
Create a file named mlflow-minimal-deployment.yaml and paste the following content:
apiVersion: v1 kind: Namespace metadata: name: my-space --- apiVersion: apps/v1 kind: Deployment metadata: name: mlflow-server namespace: my-space spec: replicas: 1 selector: matchLabels: app: mlflow-server template: metadata: labels: app: mlflow-server name: mlflow-server-pod spec: containers: - name: mlflow-server image: ghcr.io/mlflow/mlflow:v2.6.0 command: ["mlflow", "server"] args: ["--host", "0.0.0.0", "--port", "5000"] ports: - containerPort: 5000 ---
apiVersion: v1 kind: Service metadata: name: mlflow-service namespace: my-space spec: selector: app: mlflow-server ports: - protocol: TCP port: 5000 targetPort: 5000
Step 2: Apply the Deployment
Apply the YAML file to create the deployment and service:
kubectl apply -f mlflow-minimal-deployment.yaml
Step 3: Verify the Deployment
Check if the pod is running:
kubectl get pods -n my-space
Step 4: Port Forwarding
To access the MLflow server from your local machine, you can use Kubernetes port forwarding:
kubectl port-forward -n my-space mlflow-server-pod 5000:5000
After running this command, you should be able to access the MLflow server at http://localhost:5000 from your web browser.
Step 5: Access MLflow within the Cluster
The cluster-internal URL for the MLflow service would be:
http://mlflow-service.my-space.svc.cluster.local:5000
You can use this tracking URL in other services within the same Kubernetes cluster, such as Kubeflow, to log your runs.
Troubleshooting Tips
Pod not starting: Check the logs using kubectl logs -n my-space mlflow-server-pod.
Service not accessible: Make sure the service is running using kubectl get svc -n my-space.
Port issues: Ensure that the port 5000 is not being used by another service in the same namespace.
Conclusion
Deploying MLflow 2.6 on Kubernetes doesn't have to be complicated. This guide provides a minimal setup to get you started. Feel free to expand upon this for your specific use-cases.
0 notes
thedebugdiary · 2 years ago
Text
Deploying Text Generation Web UI on a Kubernetes Cluster
In this blog post, we'll walk through the process of deploying a text generation web UI using the Docker image atinoda/text-generation-webui on a Kubernetes cluster. We'll cover everything from creating a Persistent Volume Claim (PVC) to setting up a Kubernetes Service for port forwarding.
Prerequisites
A running Kubernetes cluster
kubectl installed and configured to interact with your cluster
Step 1: Create a Namespace
First, let's create a namespace called text-gen-demo to isolate our resources.
kubectl create namespace text-gen-demo
Step 2: Create a Persistent Volume Claim (PVC)
We'll need a PVC to store our data. Create a YAML file named text-gen-demo-pvc.yaml with the following content:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: text-gen-demo-pvc namespace: text-gen-demo spec: accessModes: - ReadWriteOnce resources: requests: storage: 100Gi storageClassName: standard
Apply the PVC:
kubectl apply -f text-gen-demo-pvc.yaml
Step 3: Deploy the Pod
Create a YAML file named text-gen-demo-pod.yaml with the following content:
apiVersion: v1 kind: Pod metadata: name: text-gen-demo-pod namespace: text-gen-demo labels: app: text-gen-demo spec: containers: - name: text-gen-demo-container image: atinoda/text-generation-webui ports: - containerPort: 7860 - containerPort: 5000 - containerPort: 5005 env: - name: TORCH_CUDA_ARCH_LIST value: "7.5" volumeMounts: - name: text-gen-demo-pvc mountPath: /app/loras subPath: loras - name: text-gen-demo-pvc mountPath: /app/models subPath: models volumes: - name: text-gen-demo-pvc persistentVolumeClaim: claimName: text-gen-demo-pvc
Apply the Pod:
kubectl apply -f text-gen-demo-pod.yaml
Step 4: Create a Service
Create a YAML file named text-gen-demo-service.yaml with the following content:
apiVersion: v1 kind: Service metadata: name: text-gen-demo-service namespace: text-gen-demo spec: selector: app: text-gen-demo ports: - name: "webui" protocol: TCP port: 7860 targetPort: 7860 - name: "api" protocol: TCP port: 5000 targetPort: 5000 - name: "api-stream" protocol: TCP port: 5005 targetPort: 5005
Apply the Service:
kubectl apply -f text-gen-demo-service.yaml
Step 5: Port Forwarding
Finally, let's set up port forwarding to access the web UI locally.
kubectl port-forward svc/text-gen-demo-service 7860:7860 -n text-gen-demo
You should now be able to access the web UI at http://localhost:7860.
Troubleshooting
If you encounter issues with port forwarding, make sure:
The pod is running and healthy (kubectl get pods -n text-gen-demo)
The service is correctly configured (kubectl describe svc text-gen-demo-service -n text-gen-demo)
The service has endpoints (kubectl get endpoints text-gen-demo-service -n text-gen-demo)
Conclusion
You've successfully deployed a text generation web UI on a Kubernetes cluster! You can now interact with the web UI locally and generate text as needed.
0 notes
thedebugdiary · 2 years ago
Text
Installing .NET SDK 7 on Ubuntu 22.04: A Step-by-Step Guide
Introduction
The .NET SDK is a set of libraries and tools that allow developers to create .NET applications and libraries. With the release of .NET SDK 7, developers have access to a range of new features and improvements. In this blog post, we'll walk you through the process of installing .NET SDK 7 on Ubuntu 22.04 using a custom Bash script.
Why Ubuntu?
Ubuntu is one of the most popular Linux distributions, known for its ease of use and community support. It's a great choice for developers, and installing the .NET SDK on Ubuntu is straightforward.
Pre-requisites
Before you proceed with the installation, make sure you have:
A machine running Ubuntu 22.04
Curl installed (You can install it using sudo apt install curl if it's not already installed)
Basic knowledge of the terminal
The Bash Script Approach
We'll use a Bash script to automate the installation process. The script will:
Download the .NET SDK 7 tarball.
Create a directory in the user's home folder for the SDK.
Extract the SDK to this directory.
Set up the necessary environment variables.
Optionally, make these environment variables persistent across sessions.
The Script
Here's the Bash script that accomplishes these tasks:
#!/bin/bash # Check if running as root if [ "$EUID" -eq 0 ]; then echo "Please do not run as root, this script installs .NET SDK in the user's home directory." exit 1 fi # Download .NET SDK 7 echo "Downloading .NET SDK 7..." curl -O https://download.visualstudio.microsoft.com/download/pr/dbfe6cc7-dd82-4cec-b267-31ed988b1652/c60ab4793c3714be878abcb9aa834b63/dotnet-sdk-7.0.400-linux-x64.tar.gz # Create directory for .NET SDK echo "Creating directory for .NET SDK..." mkdir -p $HOME/dotnet # Extract .NET SDK echo "Extracting .NET SDK..." tar zxf dotnet-sdk-7.0.400-linux-x64.tar.gz -C $HOME/dotnet # Set up environment variables echo "Setting up environment variables..." export DOTNET_ROOT=$HOME/dotnet export PATH=$PATH:$HOME/dotnet # Make environment variables persistent read -p "Do you want to make these environment variables persistent? (y/n): " choice if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then echo "export DOTNET_ROOT=$HOME/dotnet" >> $HOME/.bashrc echo "export PATH=\$PATH:\$HOME/dotnet" >> $HOME/.bashrc echo "Environment variables have been added to $HOME/.bashrc" fi # Cleanup echo "Cleaning up downloaded files..." rm dotnet-sdk-7.0.400-linux-x64.tar.gz # Installation complete echo ".NET SDK 7 installation is complete!" # Verify the installation dotnet --version
How to Use the Script
Save the script into a file, for example, install_dotnet_sdk_7.sh.
Open a terminal and navigate to the directory where you saved the script.
Run chmod +x install_dotnet_sdk_7.sh to make the script executable.
Run ./install_dotnet_sdk_7.sh to execute the script.
Conclusion
Installing .NET SDK 7 on Ubuntu 22.04 is a straightforward process, especially when automated with a Bash script. This approach not only simplifies the installation but also ensures that you don't miss any steps. Happy coding!
0 notes
thedebugdiary · 2 years ago
Text
How to Reduce High Power Usage with Intel Wi-Fi 6 AX200 on Ubuntu
If you're using a laptop with the Intel Wi-Fi 6 AX200 card and you've noticed that your battery life isn't what it should be, the culprit might be higher-than-expected power consumption by your WiFi card. This blog post will guide you through the steps to diagnose and fix this issue on Ubuntu.
Step 1: Detect High Power Consumption with PowerTOP
The first step in diagnosing power issues is to identify which components are consuming the most power. PowerTOP is a useful tool for this.
Install PowerTOP:
sudo apt update sudo apt install powertop
Run PowerTOP:
sudo powertop
Navigate to the 'Device stats' tab to see power consumption by device. If your WiFi card is consuming more power than expected, proceed to the next steps.
Step 2: Check the Power State of the WiFi Card
Open a terminal and run the following command to check the power state of your WiFi card:
cat /sys/bus/pci/devices/0000:3b:00.0/power_state
If the output is D0, the device is fully powered on. We'll aim to change this to a lower power state.
Step 3: Check Your Power Management Settings
Ubuntu uses either its default power management or TLP for more advanced power management. If you're already using TLP but still experiencing high power usage, you might need to install the TLP Radio Device Wizard (tlp-rdw).
Install TLP and TLP RDW:
sudo apt update sudo apt install tlp tlp-rdw
Start TLP:
sudo tlp start
This should automatically apply various power-saving settings, including those for your WiFi card.
Step 4: Fine-Tune TLP Configuration (Optional: Use TLP UI)
If you want to fine-tune your power settings, you can manually edit TLP's configuration file or use TLP UI for a graphical interface.
Install TLP UI:
sudo apt install tlpui
Run TLP UI:
tlpui
Note: If you encounter issues with TLP UI not finding the configuration files for TLP 1.6, you can manually download them from the TLP GitHub project page and place them in the expected directory.
Conclusion
By following these steps, you should be able to significantly reduce the power consumption of your Intel Wi-Fi 6 AX200 card on Ubuntu. In our example, we were able to reduce the power usage from over 4W to just 1.7W, which can make a significant difference in battery life.
Remember, these are just guidelines. Always make sure to read the documentation and understand the changes you are making to your system.
0 notes
thedebugdiary · 2 years ago
Text
Markdown to Tumblr Blog Post
Purpose
The main purpose of the code is to convert Markdown text into formatted HTML, suitable for a blog post on Tumblr. Specifically, it enables live Markdown editing with syntax highlighting and automatic HTML generation. The rendered HTML is designed to emulate a terminal-like appearance and comes with syntax highlighting based on your custom classes.
How it Works
Setting Up the Environment
Firstly, the code uses external libraries like CodeMirror for the Markdown editor and syntax highlighting, and the marked.js library for converting Markdown to HTML.
<!-- Include CodeMirror and marked.js libraries --> <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.3/codemirror.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/3.0.8/marked.min.js"></script>
Language Mapping
A language map (langMap) is defined to correlate common programming languages to their corresponding CodeMirror modes. There's also a langToTumblrClassMap to map CodeMirror's native classes to custom Tumblr-friendly classes.
const langMap = { 'html': 'htmlmixed', 'javascript': 'javascript', // ... }; const langToTumblrClassMap = { 'keyword': 'npf_color_monica', 'atom': 'npf_color_joey', // ... };
HTML Sanitization
A function escapeHtml is defined to safely escape special HTML characters to prevent HTML injection vulnerabilities.
// Function to escape HTML characters function escapeHtml(unsafe) { return unsafe.replace(/&lt;;/g, "&lt;") .replace(/>/g, ">") // ... }
Custom Markdown Renderer
A custom marked.Renderer() instance is created to override how code blocks are rendered. CodeMirror's runMode is used to syntax-highlight each token in the code, which then receives Tumblr-specific styling.
const renderer = new marked.Renderer(); renderer.code = (code, lang) => { // Implementation... };
Markdown and HTML Editors
CodeMirror is used to create Markdown and HTML editors. The Markdown editor is where users write or paste their Markdown text. As the user types, the HTML is automatically generated below.
const markdownEditor = CodeMirror(document.getElementById("markdown-editor"), { mode: "markdown", lineNumbers: true, });
Real-Time Rendering
Event listeners are attached to the Markdown editor. Any change triggers the marked() function to convert the Markdown text into HTML. This HTML is then displayed in real-time in the "Markdown Output" section.
markdownEditor.on("change", function () { const markdownText = markdownEditor.getValue(); const html = marked(markdownText); document.getElementById("output").innerHTML = html; });
Raw HTML Output
The generated HTML is also shown in a read-only CodeMirror HTML editor, providing the raw HTML output for additional use or debugging.
const htmlOutputEditor = CodeMirror(document.getElementById("html-output-editor"), { mode: "htmlmixed", lineNumbers: true, readOnly: true });
Styling (Optional)
The styling part is entirely optional but adds a visual flair to the output, giving it a terminal-like appearance and enabling syntax highlighting. If you decide to include it, remember to integrate these CSS styles into the custom CSS section of your Tumblr theme.
We utilize custom classes like npf_color_monica, npf_color_joey, etc., which are mapped to different types of code tokens to make the output colorful and more readable. This emulates a code editor experience.
Here's a sample CSS snippet for the class npf_chat:
.npf_chat { background-color: #1E1E1E; /* Dark background similar to Visual Studio */ color: #D4D4D4; /* Default text color similar to Visual Studio */ /* Additional styling options... */ white-space: pre-wrap; /* Ensures that whitespaces and newlines are rendered as-is */ }
Remember, these styles should be added to the custom CSS section in your Tumblr theme to ensure they are applied correctly.
0 notes
thedebugdiary · 2 years ago
Text
How to Repair the Windows Bootloader in a Dual-Boot System with Ubuntu
Hey there, tech enthusiasts! 🌟 Are you struggling with a broken Windows bootloader in your dual-boot setup with Ubuntu? You've come to the right place! Today, I'll guide you through a straightforward process to get both your Windows and Ubuntu systems back on track.
📌 Prerequisites
A bootable Windows installation media (USB or DVD)
A bootable Ubuntu installation media (optional but useful for updating GRUB)
🛠️ Step-by-Step Guide
Step 1: Boot from Windows Installation Media
Insert your Windows installation media and restart your computer. Boot from the media and choose "Repair your computer" > "Troubleshoot" > "Command Prompt".
Step 2: Run DiskPart to Assign a Drive Letter
Open the command prompt and type the following commands:
diskpart list disk select disk 0 (or the disk where Windows is installed) list partition select partition 1 (or your EFI partition) assign letter=z exit
🔍 Note: The letter z is just a placeholder; you can choose any unused letter!
Step 3: Navigate to EFI Partition and Run FixBoot
Once you've assigned a letter, navigate to the EFI partition and attempt to fix the boot issue:
cd /d z:\EFI\Microsoft\Boot\ bootrec /fixboot
⚠️ Heads Up: If you get an "Access Denied" message, double-check that you've correctly assigned a drive letter to your EFI partition.
Step 4: Rebuild BCD
Try rebuilding the Boot Configuration Data (BCD) next:
bootrec /rebuildbcd
🔍 Note: If it still shows 0 installations, manually create a new BCD entry:
bcdboot C:\Windows /l en-us /s z: /f ALL
Remember to replace C:\Windows with your actual Windows installation path and z: with your EFI partition letter.
Step 5: Exit and Reboot
Type exit to close the Command Prompt and reboot your system.
Step 6: (Optional) Update GRUB from Ubuntu
This is an optional step but it's good practice:
sudo update-grub
Step 7: Reboot Your System
Now, you should see a boot menu allowing you to choose between Windows and Ubuntu. Select, boot, and enjoy!
🎉 Wrapping Up
That’s it, folks! You've successfully repaired your Windows bootloader. Remember, these steps can be sensitive to your specific system configuration, so proceed with caution. Always back up your important data before attempting any form of boot repair.
Happy computing! 💻✨
1 note · View note