Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.
 
| import torch | |
| from torch.nn.attention._flex_attention import _create_block_mask, _create_mask | |
| from functools import partial | |
| from torch.nn.attention._flex_attention import _flex_attention | |
| from triton.testing import do_bench | |
| import torch.nn.functional as F | |
| from functools import lru_cache | |
| torch.set_default_device('cuda') | |
| # Example usage | 
| """ To use: install Ollama, clone OpenVoice, run this script in the OpenVoice directory | |
| brew install portaudio | |
| brew install git-lfs | |
| git lfs install | |
| git clone https://github.com/myshell-ai/OpenVoice | |
| cd OpenVoice | |
| git clone https://huggingface.co/myshell-ai/OpenVoice | |
| cp -r OpenVoice/* . | |
| """ To use: install LLM studio (or Ollama), clone OpenVoice, run this script in the OpenVoice directory | |
| git clone https://github.com/myshell-ai/OpenVoice | |
| cd OpenVoice | |
| git clone https://huggingface.co/myshell-ai/OpenVoice | |
| cp -r OpenVoice/* . | |
| pip install whisper pynput pyaudio | |
| """ | |
| from openai import OpenAI | |
| import time | 
| # [Mamba: Linear-Time Sequence Modeling with Selective State Spaces](https://arxiv.org/abs/2312.00752) | |
| import torch | |
| import torch.nn as nn | |
| import torch.optim as optim | |
| from torch.utils.data import DataLoader, Dataset | |
| from torch.nn import functional as F | |
| from einops import rearrange, repeat | |
| from tqdm import tqdm | 
| import inspect | |
| import json | |
| import re | |
| import typing | |
| from inspect import isclass, getdoc | |
| from types import NoneType | |
| from pydantic import BaseModel, Field | |
| from pydantic.fields import FieldInfo | |
| from typing import Any, Type, List, get_args, get_origin, Tuple, Union, Optional | 
| """ | |
| GPU Monitor with Email and Execution | |
| This script monitors the usage of GPUs on a system and, when there are enough free GPUs, execute a specified function. | |
| The function run a bash script by default but could be any other executable code. | |
| This script uses the GPUtil library to monitor GPU usage. | |
| Preparation: | |
| 1. `pip install GPUtil` | |
| 2. define your own `func` if needed | 
| import weaviate | |
| import csv | |
| import openai | |
| from weaviate.util import generate_uuid5, get_valid_uuid | |
| from uuid import uuid4 | |
| OPENAI_API_KEY = "YOUR KEY" | |
| WEAVIATE_URL = "YOUR URL" | |
| openai.api_key = "YOUR KEY" |