Upload folder using huggingface_hub
Browse files- README.md +35 -1
- chat_cpu.py +2 -2
- chat_cuda.py +2 -2
- requirements-cuda.txt +38 -0
- setup-cuda.bat +100 -0
- setup-cuda.sh +101 -0
README.md
CHANGED
|
@@ -68,16 +68,50 @@ This model can be used for:
|
|
| 68 |
## Quick Start
|
| 69 |
|
| 70 |
### Installation
|
|
|
|
|
|
|
| 71 |
```bash
|
| 72 |
# Clone the repository
|
| 73 |
git clone https://github.com/Kaileh57/Ursa_Minor_Smashed.git
|
| 74 |
cd Ursa_Minor_Smashed
|
| 75 |
|
| 76 |
-
# Set up environment
|
| 77 |
pip install -r requirements.txt
|
| 78 |
# or use the setup script: ./setup.sh
|
| 79 |
```
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
### Basic Usage
|
| 82 |
|
| 83 |
#### Command Line Interface
|
|
|
|
| 68 |
## Quick Start
|
| 69 |
|
| 70 |
### Installation
|
| 71 |
+
|
| 72 |
+
#### CPU Installation (Default)
|
| 73 |
```bash
|
| 74 |
# Clone the repository
|
| 75 |
git clone https://github.com/Kaileh57/Ursa_Minor_Smashed.git
|
| 76 |
cd Ursa_Minor_Smashed
|
| 77 |
|
| 78 |
+
# Set up CPU environment
|
| 79 |
pip install -r requirements.txt
|
| 80 |
# or use the setup script: ./setup.sh
|
| 81 |
```
|
| 82 |
|
| 83 |
+
#### CUDA Installation (For GPU Acceleration)
|
| 84 |
+
If you have a CUDA-capable GPU and want to use GPU acceleration:
|
| 85 |
+
|
| 86 |
+
**Linux/macOS:**
|
| 87 |
+
```bash
|
| 88 |
+
# Use the automated CUDA setup script
|
| 89 |
+
chmod +x setup-cuda.sh
|
| 90 |
+
./setup-cuda.sh
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
**Windows:**
|
| 94 |
+
```batch
|
| 95 |
+
# Use the Windows CUDA setup script
|
| 96 |
+
setup-cuda.bat
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
**Manual CUDA Installation:**
|
| 100 |
+
```bash
|
| 101 |
+
# Create separate CUDA environment
|
| 102 |
+
python -m venv venv-cuda
|
| 103 |
+
source venv-cuda/bin/activate # On Windows: venv-cuda\Scripts\activate
|
| 104 |
+
|
| 105 |
+
# Install CUDA requirements
|
| 106 |
+
pip install -r requirements-cuda.txt
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
**CUDA Requirements:**
|
| 110 |
+
- NVIDIA GPU with CUDA Compute Capability 3.5 or higher
|
| 111 |
+
- NVIDIA drivers installed
|
| 112 |
+
- CUDA 11.8 or 12.1 toolkit (optional, PyTorch includes CUDA runtime)
|
| 113 |
+
- At least 4GB GPU memory recommended
|
| 114 |
+
|
| 115 |
### Basic Usage
|
| 116 |
|
| 117 |
#### Command Line Interface
|
chat_cpu.py
CHANGED
|
@@ -47,8 +47,8 @@ def main():
|
|
| 47 |
full_response = generate_direct(
|
| 48 |
model,
|
| 49 |
context,
|
| 50 |
-
max_new_tokens=
|
| 51 |
-
temperature=0.
|
| 52 |
top_p=0.9,
|
| 53 |
top_k=30, # Lower for CPU efficiency
|
| 54 |
repetition_penalty=1.1
|
|
|
|
| 47 |
full_response = generate_direct(
|
| 48 |
model,
|
| 49 |
context,
|
| 50 |
+
max_new_tokens=100, # Match inference_cpu.py default
|
| 51 |
+
temperature=0.8, # Match inference_cpu.py default
|
| 52 |
top_p=0.9,
|
| 53 |
top_k=30, # Lower for CPU efficiency
|
| 54 |
repetition_penalty=1.1
|
chat_cuda.py
CHANGED
|
@@ -51,8 +51,8 @@ def main():
|
|
| 51 |
full_response = generate_direct(
|
| 52 |
model,
|
| 53 |
context,
|
| 54 |
-
max_new_tokens=
|
| 55 |
-
temperature=0.
|
| 56 |
top_p=0.9,
|
| 57 |
top_k=50, # Higher for better quality
|
| 58 |
repetition_penalty=1.1
|
|
|
|
| 51 |
full_response = generate_direct(
|
| 52 |
model,
|
| 53 |
context,
|
| 54 |
+
max_new_tokens=100, # Match inference_cuda.py default
|
| 55 |
+
temperature=0.8, # Match inference_cuda.py default
|
| 56 |
top_p=0.9,
|
| 57 |
top_k=50, # Higher for better quality
|
| 58 |
repetition_penalty=1.1
|
requirements-cuda.txt
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CUDA Requirements for Ursa Minor Smashed Model
|
| 2 |
+
# Install these dependencies for CUDA inference
|
| 3 |
+
|
| 4 |
+
# Core CUDA dependencies
|
| 5 |
+
# Install PyTorch with CUDA support (CUDA 11.8 or 12.1)
|
| 6 |
+
# For CUDA 11.8:
|
| 7 |
+
--extra-index-url https://download.pytorch.org/whl/cu118
|
| 8 |
+
torch>=2.0.0+cu118
|
| 9 |
+
torchaudio>=2.0.0+cu118
|
| 10 |
+
torchvision>=2.0.0+cu118
|
| 11 |
+
|
| 12 |
+
# For CUDA 12.1, comment out the above lines and uncomment these:
|
| 13 |
+
# --extra-index-url https://download.pytorch.org/whl/cu121
|
| 14 |
+
# torch>=2.0.0+cu121
|
| 15 |
+
# torchaudio>=2.0.0+cu121
|
| 16 |
+
# torchvision>=2.0.0+cu121
|
| 17 |
+
|
| 18 |
+
# Core dependencies (same as CPU version)
|
| 19 |
+
numpy>=1.24.0
|
| 20 |
+
tiktoken>=0.5.0
|
| 21 |
+
tqdm>=4.65.0
|
| 22 |
+
|
| 23 |
+
# Optional dependencies
|
| 24 |
+
gguf>=0.6.0 # For GGUF conversion
|
| 25 |
+
sentencepiece>=0.1.99 # For tokenizer support
|
| 26 |
+
safetensors>=0.4.0 # For safe model serialization
|
| 27 |
+
psutil>=5.8.0 # For system monitoring
|
| 28 |
+
|
| 29 |
+
# CUDA-specific utilities
|
| 30 |
+
pynvml>=11.4.1 # For GPU monitoring and management
|
| 31 |
+
nvidia-ml-py3>=7.352.0 # Alternative GPU monitoring
|
| 32 |
+
|
| 33 |
+
# Development dependencies
|
| 34 |
+
matplotlib>=3.7.0
|
| 35 |
+
jupyter>=1.0.0
|
| 36 |
+
pytest>=7.4.0
|
| 37 |
+
black>=23.0.0
|
| 38 |
+
flake8>=6.0.0
|
setup-cuda.bat
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
REM CUDA Setup script for Ursa Minor Smashed model (Windows)
|
| 3 |
+
|
| 4 |
+
echo π₯ Setting up CUDA environment for Ursa Minor Smashed model...
|
| 5 |
+
|
| 6 |
+
REM Check if NVIDIA GPU is available
|
| 7 |
+
nvidia-smi >nul 2>&1
|
| 8 |
+
if errorlevel 1 (
|
| 9 |
+
echo β ERROR: nvidia-smi not found. Make sure NVIDIA drivers are installed.
|
| 10 |
+
pause
|
| 11 |
+
exit /b 1
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
echo π Checking GPU information...
|
| 15 |
+
nvidia-smi
|
| 16 |
+
|
| 17 |
+
REM Get CUDA version (simplified for Windows)
|
| 18 |
+
echo π Please ensure you have CUDA 11.8 or 12.1 installed
|
| 19 |
+
|
| 20 |
+
REM Create virtual environment
|
| 21 |
+
echo π¦ Creating virtual environment...
|
| 22 |
+
python -m venv venv-cuda
|
| 23 |
+
|
| 24 |
+
REM Activate virtual environment
|
| 25 |
+
echo β
Activating virtual environment...
|
| 26 |
+
call venv-cuda\Scripts\activate
|
| 27 |
+
|
| 28 |
+
REM Upgrade pip
|
| 29 |
+
python -m pip install --upgrade pip
|
| 30 |
+
|
| 31 |
+
REM Install CUDA requirements
|
| 32 |
+
echo π Installing CUDA requirements...
|
| 33 |
+
echo This may take a few minutes as PyTorch CUDA packages are large...
|
| 34 |
+
|
| 35 |
+
REM Ask user for CUDA version
|
| 36 |
+
echo.
|
| 37 |
+
echo Please select your CUDA version:
|
| 38 |
+
echo 1. CUDA 11.8
|
| 39 |
+
echo 2. CUDA 12.1
|
| 40 |
+
echo 3. Auto-detect (default)
|
| 41 |
+
set /p cuda_choice=Enter choice (1-3, default 3):
|
| 42 |
+
|
| 43 |
+
if "%cuda_choice%"=="1" (
|
| 44 |
+
echo Installing PyTorch for CUDA 11.8...
|
| 45 |
+
pip install torch torchaudio torchvision --extra-index-url https://download.pytorch.org/whl/cu118
|
| 46 |
+
) else if "%cuda_choice%"=="2" (
|
| 47 |
+
echo Installing PyTorch for CUDA 12.1...
|
| 48 |
+
pip install torch torchaudio torchvision --extra-index-url https://download.pytorch.org/whl/cu121
|
| 49 |
+
) else (
|
| 50 |
+
echo Installing PyTorch for CUDA 11.8 (default)...
|
| 51 |
+
pip install torch torchaudio torchvision --extra-index-url https://download.pytorch.org/whl/cu118
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
REM Install remaining requirements
|
| 55 |
+
echo π Installing remaining dependencies...
|
| 56 |
+
pip install numpy>=1.24.0 tiktoken>=0.5.0 tqdm>=4.65.0
|
| 57 |
+
pip install gguf>=0.6.0 sentencepiece>=0.1.99 safetensors>=0.4.0 psutil>=5.8.0
|
| 58 |
+
pip install pynvml>=11.4.1 nvidia-ml-py3>=7.352.0
|
| 59 |
+
pip install matplotlib>=3.7.0 jupyter>=1.0.0
|
| 60 |
+
|
| 61 |
+
REM Test CUDA availability
|
| 62 |
+
echo π§ͺ Testing CUDA setup...
|
| 63 |
+
python -c "import torch; print(f'PyTorch version: {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}'); import sys; sys.exit(0 if torch.cuda.is_available() else 1)"
|
| 64 |
+
|
| 65 |
+
if errorlevel 1 (
|
| 66 |
+
echo β CUDA not available in PyTorch installation
|
| 67 |
+
pause
|
| 68 |
+
exit /b 1
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
python -c "import torch; print(f'CUDA device count: {torch.cuda.device_count()}'); print(f'Current CUDA device: {torch.cuda.current_device()}'); print(f'CUDA device name: {torch.cuda.get_device_name()}'); print(f'CUDA version: {torch.version.cuda}')"
|
| 72 |
+
|
| 73 |
+
REM Verify model file exists
|
| 74 |
+
if exist "model_optimized.pt" (
|
| 75 |
+
echo β
Model file found: model_optimized.pt
|
| 76 |
+
) else (
|
| 77 |
+
echo β οΈ Warning: model_optimized.pt not found in current directory
|
| 78 |
+
echo Make sure you have the model file in the same directory as this script
|
| 79 |
+
)
|
| 80 |
+
|
| 81 |
+
echo.
|
| 82 |
+
echo π CUDA setup complete!
|
| 83 |
+
echo.
|
| 84 |
+
echo π Usage Instructions:
|
| 85 |
+
echo To activate CUDA environment:
|
| 86 |
+
echo venv-cuda\Scripts\activate
|
| 87 |
+
echo.
|
| 88 |
+
echo To run CUDA inference:
|
| 89 |
+
echo python inference_cuda.py --prompt "Your prompt here"
|
| 90 |
+
echo.
|
| 91 |
+
echo To run CUDA chat:
|
| 92 |
+
echo python chat_cuda.py
|
| 93 |
+
echo.
|
| 94 |
+
echo To run CUDA benchmark:
|
| 95 |
+
echo python benchmark_cuda.py
|
| 96 |
+
echo.
|
| 97 |
+
echo π Test your setup:
|
| 98 |
+
echo python -c "import torch; print('CUDA available:', torch.cuda.is_available())"
|
| 99 |
+
|
| 100 |
+
pause
|
setup-cuda.sh
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUDA Setup script for Ursa Minor Smashed model
|
| 3 |
+
|
| 4 |
+
echo "π₯ Setting up CUDA environment for Ursa Minor Smashed model..."
|
| 5 |
+
|
| 6 |
+
# Check if NVIDIA GPU is available
|
| 7 |
+
if ! command -v nvidia-smi &> /dev/null; then
|
| 8 |
+
echo "β ERROR: nvidia-smi not found. Make sure NVIDIA drivers are installed."
|
| 9 |
+
exit 1
|
| 10 |
+
fi
|
| 11 |
+
|
| 12 |
+
echo "π Checking GPU information..."
|
| 13 |
+
nvidia-smi
|
| 14 |
+
|
| 15 |
+
# Check CUDA version
|
| 16 |
+
CUDA_VERSION=$(nvidia-smi | grep "CUDA Version" | awk '{print $9}' | cut -d. -f1,2)
|
| 17 |
+
echo "π Detected CUDA Version: $CUDA_VERSION"
|
| 18 |
+
|
| 19 |
+
# Create virtual environment
|
| 20 |
+
echo "π¦ Creating virtual environment..."
|
| 21 |
+
python -m venv venv-cuda
|
| 22 |
+
|
| 23 |
+
# Activate virtual environment
|
| 24 |
+
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
| 25 |
+
source venv-cuda/Scripts/activate
|
| 26 |
+
else
|
| 27 |
+
source venv-cuda/bin/activate
|
| 28 |
+
fi
|
| 29 |
+
|
| 30 |
+
echo "β
Virtual environment activated"
|
| 31 |
+
|
| 32 |
+
# Upgrade pip
|
| 33 |
+
pip install --upgrade pip
|
| 34 |
+
|
| 35 |
+
# Install CUDA requirements
|
| 36 |
+
echo "π Installing CUDA requirements..."
|
| 37 |
+
echo "This may take a few minutes as PyTorch CUDA packages are large..."
|
| 38 |
+
|
| 39 |
+
# Detect CUDA version and install appropriate PyTorch
|
| 40 |
+
if [[ "$CUDA_VERSION" == "12."* ]]; then
|
| 41 |
+
echo "Installing PyTorch for CUDA 12.1..."
|
| 42 |
+
pip install torch torchaudio torchvision --extra-index-url https://download.pytorch.org/whl/cu121
|
| 43 |
+
elif [[ "$CUDA_VERSION" == "11."* ]]; then
|
| 44 |
+
echo "Installing PyTorch for CUDA 11.8..."
|
| 45 |
+
pip install torch torchaudio torchvision --extra-index-url https://download.pytorch.org/whl/cu118
|
| 46 |
+
else
|
| 47 |
+
echo "β οΈ Warning: Unsupported CUDA version $CUDA_VERSION"
|
| 48 |
+
echo "Installing default CUDA 11.8 PyTorch..."
|
| 49 |
+
pip install torch torchaudio torchvision --extra-index-url https://download.pytorch.org/whl/cu118
|
| 50 |
+
fi
|
| 51 |
+
|
| 52 |
+
# Install remaining requirements
|
| 53 |
+
echo "π Installing remaining dependencies..."
|
| 54 |
+
pip install -r requirements-cuda.txt
|
| 55 |
+
|
| 56 |
+
# Test CUDA availability
|
| 57 |
+
echo "π§ͺ Testing CUDA setup..."
|
| 58 |
+
python -c "
|
| 59 |
+
import torch
|
| 60 |
+
print(f'PyTorch version: {torch.__version__}')
|
| 61 |
+
print(f'CUDA available: {torch.cuda.is_available()}')
|
| 62 |
+
if torch.cuda.is_available():
|
| 63 |
+
print(f'CUDA device count: {torch.cuda.device_count()}')
|
| 64 |
+
print(f'Current CUDA device: {torch.cuda.current_device()}')
|
| 65 |
+
print(f'CUDA device name: {torch.cuda.get_device_name()}')
|
| 66 |
+
print(f'CUDA version: {torch.version.cuda}')
|
| 67 |
+
else:
|
| 68 |
+
print('β CUDA not available in PyTorch installation')
|
| 69 |
+
exit(1)
|
| 70 |
+
"
|
| 71 |
+
|
| 72 |
+
# Verify model file exists
|
| 73 |
+
if [[ -f "model_optimized.pt" ]]; then
|
| 74 |
+
echo "β
Model file found: model_optimized.pt"
|
| 75 |
+
else
|
| 76 |
+
echo "β οΈ Warning: model_optimized.pt not found in current directory"
|
| 77 |
+
echo "Make sure you have the model file in the same directory as this script"
|
| 78 |
+
fi
|
| 79 |
+
|
| 80 |
+
echo ""
|
| 81 |
+
echo "π CUDA setup complete!"
|
| 82 |
+
echo ""
|
| 83 |
+
echo "π Usage Instructions:"
|
| 84 |
+
echo "To activate CUDA environment:"
|
| 85 |
+
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
| 86 |
+
echo " source venv-cuda/Scripts/activate"
|
| 87 |
+
else
|
| 88 |
+
echo " source venv-cuda/bin/activate"
|
| 89 |
+
fi
|
| 90 |
+
echo ""
|
| 91 |
+
echo "To run CUDA inference:"
|
| 92 |
+
echo " python inference_cuda.py --prompt 'Your prompt here'"
|
| 93 |
+
echo ""
|
| 94 |
+
echo "To run CUDA chat:"
|
| 95 |
+
echo " python chat_cuda.py"
|
| 96 |
+
echo ""
|
| 97 |
+
echo "To run CUDA benchmark:"
|
| 98 |
+
echo " python benchmark_cuda.py"
|
| 99 |
+
echo ""
|
| 100 |
+
echo "π Test your setup:"
|
| 101 |
+
echo " python -c \"import torch; print('CUDA available:', torch.cuda.is_available())\""
|