sudo apt-get update
sudo apt-get install -y build-essential git cuda-libraries-dev-12-8 libopencv-dev gpg wget
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ <distro> main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
sudo apt-get update
sudo apt-get install gcc-12 g++-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import logging | |
from git import Repo, GitCommandError | |
def extract_repo_name(repo_url): | |
""" | |
Extracts the repository name from the given Git URL. | |
Supports URLs ending with '.git' and those without it. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import random | |
import sys | |
from transformers import AutoModelForCausalLM, AutoTokenizer, DynamicCache | |
import torch | |
defo = ["\nWait, let's look at this from a system thinking approach:", "\nHmm let's look at this from a step by step approach:"] | |
# ~ defo = ["\nWait, but", "\nHmm", "\nSo", "\nActually"] | |
parser = argparse.ArgumentParser() | |
parser.add_argument("question", type=str) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import textwrap | |
from ollama import chat | |
# --------------------------- | |
# 1) Setup: Long text & question | |
# --------------------------- | |
# ~ LONG_TEXT = """ | |
# ~ Coffee, one of the worldโs most beloved beverages, has a storied history that dates back centuries. Legend has it that an Ethiopian goat herder named Kaldi first noticed his goats becoming particularly energetic after nibbling on certain red berries. This discovery eventually led to the cultivation of coffee beans in the Middle East, where Sufi monks used the brew to stay alert during nighttime prayers. Over time, the practice of preparing and drinking coffee spread across the Islamic world and into Europe, sparking a cultural revolution of cafรฉs and intellectual discourse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_model_size(total_parameters, precision="fp32"): | |
""" | |
Calculate the model size in GB given the total number of parameters. | |
Parameters: | |
total_parameters (int): Total number of parameters in the model. | |
precision (str): Precision type ("fp32" or "fp16"). | |
Returns: | |
float: Model size in GB. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Agent: | |
def __init__(self, name, ports=None): | |
self.name = name | |
self.ports = ports if ports else [] | |
# Each element of ports is either None or a tuple (other_agent, other_port_index) | |
def __repr__(self): | |
return f"{self.name}" | |
def connect(a, pa, b, pb): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Process org blocks and continue initialization | |
(ignore-errors | |
(catch 'init-done | |
(let* ((init-file (or load-file-name buffer-file-name)) | |
(temp-file (concat temporary-file-directory "init-processed.el"))) | |
;; Extract elisp blocks to temp file | |
(with-temp-file temp-file | |
(insert-file-contents init-file) | |
(goto-char (point-min)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Direct solution weights: [0.79, 0.85, 0.84] | |
Forward output: [111, 117, 116] | |
Loss: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <TFT_eSPI.h> | |
#include <SPI.h> | |
TFT_eSPI tft = TFT_eSPI(); | |
// 3D coordinates for cube vertices | |
const float vertices[8][3] = { | |
{-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}, | |
{-1, -1, 1}, {1, -1, 1}, {1, 1, 1}, {-1, 1, 1} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
import win32gui | |
import win32con | |
import win32api | |
pygame.init() | |
# Set up the display (fullscreen for this example) | |
screen_info = pygame.display.Info() | |
width, height = screen_info.current_w, screen_info.current_h |