Posts

Showing posts from August, 2024

kaggle notebook running llama 3.1 v2

Image
Here is the link to my kaggle notebook, that run llama 3.1 v2. Some older notebook got tripped because of the newer version. So we just have to specify those path correctly - as shown here.

Deepnote - setting up HF_TOKEN token for huggingface integration

Image
 To setup your HF_TOKEN in deepnote, it requires an environment variable to be created. To do that, goto Deepnote -> Integrations (on your top left) -> Scroll down to the end and look for environment variable as shown below:- A page will load and asking your to provide name, environment variable name and value Click on "Create integration". You should be able to access model such as LLAMA 3.1 in your notebook after this.

Getting access to hugging face llama models

Image
  To get access to specific models, you can go to huggingface.com and then search for meta/llama model.  For example, to get access to meta-llama/Meta-Llama-3.1-8B. https://huggingface.co/meta-llama/Meta-Llama-3.1-8B Click on "Expand to review and access". Fill in all the require names and details. And submit.  You can verify your access by going to  https://huggingface.co/meta-llama/Meta-Llama-3.1-8B/resolve/main/config.json. If your access not granted it will look something like this. :) Once you have access you can try out this notebook example https://colab.research.google.com/drive/19c_GuNCYsABMe4b3VS8cXgGl01cSXi7O#scrollTo=dadpCnSeX8Tj

Google colab - Unsloth notebook error PyTorch 2.3.1+cu121 with CUDA 1201 (you have 2.4.0+cu121)

Image
  I bump into this error while running google colab notebook.  xFormers can't load C++/CUDA extensions. xFormers was built for: PyTorch 2.3.0+cu121 with CUDA 1201 (you have 2.4.0+cu124) Python 3.10.14 (you have 3.10.12) Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers ) Memory-efficient attention, SwiGLU, sparse and more won't be available. Obviously my pytorch is default to a new version which doesn't work well due to the built dependencies.  To resolve that, I force my torch to version 2.3.1 and then restart my session.  Then proceed to run the rest of the code in the notebook. ! pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git" ! pip install torch== 2.3.1 ! pip install --no-deps "xformers==0.0.27" "trl<0.9.0" peft accelerate bitsandbytes triton

k8s cluster API - creating kubernetes cluster with docker

Image
 Download clusterctl by running the following command curl.exe -L https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.8.1/clusterctl-windows-amd64.exe -o clusterctl.exe Next, run the following command and ensure your docker instance is up and running clusterctl init --infrastructure docker Set your environment variables correctly by running the followings $env:SERVICE_CIDR= "['10.96.0.0/12']" $env:POD_CIDR= "['192.168.0.0/16']" $env:SERVICE_DOMAIN= "k8s.test" $env:POD_SECURITY_STANDARD_ENABLED= "false" Then proceed to run the following commands:-  clusterctl generate cluster capi-quickstart --flavor development  --kubernetes-version v1.31.0 --control-plane-machine-count=3 --worker-machine-count=3 > capi-quickstart.yaml This will generate a file call capi-quickstart.yaml To start creating your cluster run the following command:- kubectl apply -f capi-quickstart.yaml The will return out the following results.  To

opentofu tutorial - helloworld example to create resources in Azure

Image
To install opentofu, please goto this link here . I am using windows so i am downloading my windows binaries. We are going to use azurerm provider and to do that, we are going to authenticate using a service principal, but you can choose to use other methods as well.  Open powershell terminal, fill in your azure service principal and other info and run the following command: $env:ARM_CLIENT_ID= "" $env:ARM_CLIENT_SECRET= "" $env:ARM_TENANT_ID = "" $env:ARM_SUBSCRIPTION_ID= "" Create a main.tf file with the following contents terraform {   required_providers {     azurerm = {       source  = "hashicorp/azurerm"       version = "4.0.1"     }     } } provider "azurerm" {   features {} } resource "azurerm_resource_group" "rg" {   location = "australiaeast"   name     = "mytestrg" } Then run the following  tofu init  Next, run  tofu plan  to see what opentofu is about to c

terraform authenticating via service principal, managed identity.

To authenticate terraform using OIDC where we need to setup the trust between Azure Devops and Azure AD, we need setup Federated Credentials and use subject from Azure Devops. This is not covered here. There are many authentication method supported by terraform namely - Azure cli  - managed identity - service principal and secret - service principal and certificate  - openId connect - workload identity Using service principal  Using powershell you can set and use the followings command  $env:ARM_CLIENT_ID= "" $env:ARM_CLIENT_SECRET= "" $env:ARM_TENANT_ID = "" $env:ARM_SUBSCRIPTION_ID= "" Using Managed Identity To use a managed identity, you can use the following scripts: I also did a test to ensure compatibility to opentofu. Looks like the authentication mechanism is the same.  $env:ARM_USE_MSI= "true" $env:ARM_SUBSCRIPTION_ID= "" $env:ARM_TENANT_ID= "" $env:ARM_CLIENT_ID= "" $env: ARM_MSI_ENDPOINT=$MSI_END

apigee - how to remove revisions of your api proxies

Image
To remove revisions from your API Proxy, you can go to your Apigee Proxies -> Select your proxy -> Then goto Develop tab, then select a revision. On your right, you can see there's an option to delete your service. Then you can see a list of revision that you can potentially delete. 

buildpacks buiilding dotnet core application using paketo dotnet

Image
To buid dotnet core application, you can use many different types of builder.   In this example, we are using paketo dotnet core. Let's create a simple generic dotnet web application using  dotnet new web  This will give you a simple hello-world app.  Next run the following command  pack build my-app --buildpack paketo-buildpacks/dotnet-core --builder paketobuildpacks/builder-jammy-base Only dotnet version 6 is supported by this builder.  Sample output is shown below. Git repo https://github.com/mitzenjeremywoo/buildpack-dotnet-paketo-builder

link to windows servers powershell command

 An interesting link to Windows servers powershell command that i bump into  https://github.com/MicrosoftDocs/windows-powershell-docs/blob/main/docset/winserver2025-ps/nettcpip/Test-NetConnection.md

buildpacks - rebase image to update based image to a new version

  Directly replacing an image layer can be a bad idea especially when we're swapping out say the OS layer. As the OS remain untested with your application runtime that can be more of an issue than a feature.  With a dockerfile that builds your application, you'll typically goes through the entire cycle of build your application and ensuring there's no compile time error. To update your based image layer you can run the following command. It seems to be replacing your OS/other dependencies layer (replacing a layer) but don't forget that there's additional testing work being carried out to ensure the based image (or builder) is working well before this can happpend. pack rebase my-app:my-tag

buildpack introduction

Image
Back in the days, we create dockerfile and provides sets of command such as  FROM base-image RUN npm install  And it all looks really familiar.  Often times, we forgot some command and the app won't be able to run. There are also times - where it took us hours trying to figure out how to install the required component.  Build packs helps by automatically analyzing your code and then tries to build an image out of it.  Let's say you have a java app and it is using maven. When you run command in your source directory as shown below:-   pack build myapp --builder cnbs/sample-builder:jammy Buildpacks would automatically infer what time of app you're running on and then build a working image ready for deployment or testing Getting started.  Install buildpacks  Then close some samples,  git clone https://github.com/buildpacks/samples For some reason, it only works for java. :)  cd samples/apps/java-maven pack build myapp --builder cnbs/sample-builder:jammy Then run  docker run --

istio destination rule subset don't really work

Image
  Istio destination rule routes to a service. Then the service uses selector to match against running pods that has certain labels for example, app=version.  When a request comes in, it goes around in a round robin fashion (depending on the weight configure) it goes to hit individual pods.  So the subset is quite meaningless - really confusing as shown below.  If i really wanted to change the routing behavior, all i need to do is change the deployment->spec->selector->matchLabels->version: v3 to something else. This will make it hidden from service's selector.  If you change the app: reviews to review-3 it is elusive to the service and won't be picked up  and route stops. This is my service configuration  apiVersion : v1 kind : Service metadata :   name : reviews   labels :     app : reviews     service : reviews spec :   ports :   - port : 9080     name : http   selector :     app : reviews Some additional notes:  Service selector uses pods label to decide what to

azure granting user or service principal access to a subscriptions

Image
 After creating a new subscription in Azure, we probably need to assign users or service principal to use it.  To do that, goto Azure subscription -> IAM -> Add Role Assignment -> Select the role that you would like to grant. Click "Next". You will be prompted to select which users or service principal or managed identity to use. Click on "Select" and then finally click on "Review and create"

kubernetes API server - different ways to extract its certificate

Using kubectl  kubectl get configmap -n kube-system extension-apiserver-authentication -o=jsonpath='{.data.client-ca-file}' | base64 --decode Getting it from the kubeconfig. cat ~/.kube/config clusters: - cluster:     certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FUR...     server: https://your-kubernetes-api-server:6443   name: your-cluster Then base64 decode it :- echo "LS0tLS1CRUdJTiBDRVJUSUZJQ0FUR..." | base64 --decode > ca.crt Using openssl command line openssl s_client -connect your-kubernetes-api-server:6443 < /dev/null | openssl x509 -outform PEM > api-server.crr openssl x509 - in api-server.crt -text -noout  

azure devops publishing to skip when a package already exist

  You can use NugetCommand@2's allowPackageConflicts and set it to true to avoid breaking the pipeline when there's an existing package. An example can be shown here - task: NuGetCommand@2 displayName: 'NuGet push' inputs: command: push publishVstsFeed: '<projectName>/<feed>' allowPackageConflicts: true Alternatively you can also use dotnet command --skip-duplicate: - script: dotnet nuget push * */* .nupkg --source $ (NUGET_FEED) --api-key $(NUGET_API_KEY) --skip-duplicate   displayName: 'Uploads nuGet packages'

setting up kubernetes in AWS EC2 instance

Image
I am using this to start setting up my own kubernetes environment.  https://hbayraktar.medium.com/how-to-install-kubernetes-cluster-on-ubuntu-22-04-step-by-step-guide-7dbf7e8f5f99 sudo apt update && sudo apt upgrade - y Turn off swap sudo swapoff -a sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab Setup required kernels parameters sudo tee /etc/modules-load.d/containerd.conf << EOF overlay br_netfilter EOF sudo modprobe overlay sudo modprobe br_netfilter Setup critical kernel parameters sudo tee /etc/sysctl.d/kubernetes.conf << EOF net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 net.ipv4.ip_forward = 1 EOF Reload the system  sudo sysctl --system Setup container runtime sudo apt install -y curl gnupg2 software-properties-common apt-transport-https ca-certificates Enable docker repository  sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/docker.gpg sudo add-apt-r