Skip to content

Commit 231c21f

Browse files
authored
Revise README for CUDA ML Library introduction
Updated README to reflect new CUDA ML library features and installation instructions.
1 parent 16016cd commit 231c21f

1 file changed

Lines changed: 220 additions & 2 deletions

File tree

README.md

Lines changed: 220 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,221 @@
1-
# Note on SVM Usage
1+
# CUDA ML Library
22

3-
Please note that while using this library, you should use SVM only. HBM SVM is still in development and may not be fully functional yet.
3+
A high-performance CUDA-accelerated Machine Learning library with automatic CPU fallback support, featuring optimized Support Vector Machine implementations for both classification and regression tasks.
4+
5+
## 🚀 Features
6+
7+
- **GPU Acceleration**: Full CUDA support for NVIDIA GPUs with Compute Capability 7.0+
8+
- **Automatic CPU Fallback**: Seamless fallback to optimized CPU implementation when CUDA is unavailable
9+
- **Cross-Platform Compatibility**: Linux, Windows, and macOS support
10+
- **Multiple SVM Types**: Classification (C-SVC, Nu-SVC) and Regression (Epsilon-SVR, Nu-SVR)
11+
- **Multiple Kernel Functions**: Linear, RBF, Polynomial, and Sigmoid kernels
12+
- **Advanced Algorithms**: SMO (Sequential Minimal Optimization) algorithm implementation
13+
- **Memory Optimization**: Efficient GPU memory management with pooling
14+
- **Easy Integration**: Scikit-learn compatible API
15+
16+
## 📋 System Requirements
17+
18+
### Hardware Requirements
19+
- **GPU (Optional)**: NVIDIA GPU with CUDA Compute Capability 7.0+ (RTX 20 series, GTX 1650+, Tesla V100+)
20+
- **CPU (Required)**: Any modern x86_64 processor
21+
- **RAM**: 4GB+ system memory (8GB+ recommended for large datasets)
22+
23+
### Software Requirements
24+
- **CUDA Toolkit** (Optional): Version 12.0+ for GPU acceleration
25+
- **Python**: 3.8+
26+
- **Dependencies**: numpy ≥1.19.0, scikit-learn ≥1.0.0
27+
28+
### Supported Environments
29+
- **GPU-Accelerated**: Systems with CUDA-capable NVIDIA GPUs
30+
- **CPU-Only**: Any system (automatic fallback when CUDA unavailable)
31+
- **Cloud Platforms**: Google Colab, AWS, Azure, etc.
32+
- **Cross-Platform**: Linux, Windows, macOS
33+
34+
## 🛠️ Installation
35+
36+
### Option 1: Install from PyPI (Recommended)
37+
38+
```bash
39+
pip install cuda-ml-library
40+
```
41+
42+
### Option 2: Build from Source
43+
44+
```bash
45+
# Clone the repository
46+
git clone https://github.com/dino65-dev/Cuda_ML_Library.git
47+
cd Cuda_ML_Library
48+
49+
# Install dependencies
50+
pip install numpy scikit-learn
51+
52+
# Build the CUDA library
53+
cd SVM
54+
make clean
55+
make
56+
57+
# Install the package
58+
cd ..
59+
pip install -e .
60+
```
61+
62+
The build process will:
63+
- Auto-detect CUDA availability and GPU architecture
64+
- Compile CUDA kernels when GPU is available
65+
- Create CPU fallback implementation when CUDA is unavailable
66+
- Generate optimized shared libraries with universal compatibility
67+
68+
## 🚀 Quick Start
69+
70+
### Classification Example
71+
72+
```python
73+
from SVM.cuda_svm import CudaSVC
74+
import numpy as np
75+
76+
# Generate sample data
77+
from sklearn.datasets import make_classification
78+
X, y = make_classification(n_samples=1000, n_features=20, random_state=42)
79+
80+
# Create and train the model (automatically uses CUDA if available)
81+
svc = CudaSVC(C=1.0, kernel='rbf', gamma='scale')
82+
svc.fit(X, y)
83+
84+
# Make predictions
85+
predictions = svc.predict(X_test)
86+
probabilities = svc.predict_proba(X_test) # If probability=True
87+
88+
print(f"Accuracy: {accuracy_score(y_test, predictions)}")
89+
```
90+
91+
### Regression Example
92+
93+
```python
94+
from SVM.cuda_svm import CudaSVR
95+
import numpy as np
96+
97+
# Generate sample data
98+
from sklearn.datasets import make_regression
99+
X, y = make_regression(n_samples=1000, n_features=20, random_state=42)
100+
101+
# Create and train the model
102+
svr = CudaSVR(C=1.0, epsilon=0.1, kernel='rbf', gamma='auto')
103+
svr.fit(X, y)
104+
105+
# Make predictions
106+
predictions = svr.predict(X_test)
107+
108+
print(f"R² Score: {r2_score(y_test, predictions)}")
109+
```
110+
111+
## 📚 API Reference
112+
113+
### CudaSVC (Classification)
114+
115+
```python
116+
CudaSVC(
117+
svm_type='c_svc', # 'c_svc' or 'nu_svc'
118+
kernel='rbf', # 'linear', 'rbf', 'poly', 'sigmoid'
119+
C=1.0, # Regularization parameter
120+
gamma='scale', # Kernel coefficient
121+
coef0=0.0, # Independent term for poly/sigmoid
122+
degree=3, # Degree for polynomial kernel
123+
nu=0.5, # Nu parameter for nu-SVM
124+
tolerance=1e-3, # Tolerance for stopping criterion
125+
max_iter=1000, # Maximum iterations
126+
shrinking=True, # Use shrinking heuristic
127+
probability=False # Enable probability estimates
128+
)
129+
```
130+
131+
### CudaSVR (Regression)
132+
133+
```python
134+
CudaSVR(
135+
svm_type='epsilon_svr', # 'epsilon_svr' or 'nu_svr'
136+
kernel='rbf', # 'linear', 'rbf', 'poly', 'sigmoid'
137+
C=1.0, # Regularization parameter
138+
epsilon=0.1, # Epsilon for epsilon-SVR
139+
gamma='scale', # Kernel coefficient
140+
coef0=0.0, # Independent term
141+
degree=3, # Polynomial degree
142+
nu=0.5, # Nu parameter
143+
tolerance=1e-3, # Stopping tolerance
144+
max_iter=1000 # Maximum iterations
145+
)
146+
```
147+
148+
## 🔧 Advanced Usage
149+
150+
### Hardware Detection
151+
152+
```python
153+
from SVM.cuda_svm import CudaSVC
154+
155+
# The library automatically detects and uses available hardware
156+
svc = CudaSVC()
157+
print("CUDA SVM initialized successfully")
158+
159+
# Hardware detection and optimization happen automatically
160+
svc.fit(X_train, y_train)
161+
```
162+
163+
### Kernel Customization
164+
165+
```python
166+
# RBF Kernel with custom gamma
167+
svc_rbf = CudaSVC(kernel='rbf', gamma=0.001)
168+
169+
# Polynomial Kernel
170+
svc_poly = CudaSVC(kernel='poly', degree=4, coef0=1.0, gamma='auto')
171+
172+
# Linear Kernel (fastest)
173+
svc_linear = CudaSVC(kernel='linear')
174+
175+
# Sigmoid Kernel
176+
svc_sigmoid = CudaSVC(kernel='sigmoid', gamma='scale', coef0=0.0)
177+
```
178+
179+
## ⚠️ Important Notes
180+
181+
### Current Status
182+
183+
- **SVM**: Fully functional and ready for production use
184+
- **HBM_SVM**: Currently in development and may not be fully functional yet
185+
186+
**Please use the standard SVM implementation for all production workloads.**
187+
188+
### Performance Tips
189+
190+
1. **GPU Memory**: Ensure sufficient GPU memory for large datasets
191+
2. **Batch Processing**: For very large datasets, consider batch processing
192+
3. **Kernel Selection**: Linear kernels are fastest, RBF kernels offer good accuracy
193+
4. **Parameter Tuning**: Use cross-validation for optimal parameter selection
194+
195+
## 🤝 Contributing
196+
197+
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
198+
199+
1. Fork the repository
200+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
201+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
202+
4. Push to the branch (`git push origin feature/amazing-feature`)
203+
5. Open a Pull Request
204+
205+
## 📄 License
206+
207+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
208+
209+
## 🔗 Links
210+
211+
- **Repository**: [https://github.com/dino65-dev/Cuda_ML_Library](https://github.com/dino65-dev/Cuda_ML_Library)
212+
- **Issues**: [https://github.com/dino65-dev/Cuda_ML_Library/issues](https://github.com/dino65-dev/Cuda_ML_Library/issues)
213+
- **Documentation**: [Usage Examples](./Usage/)
214+
215+
## 📊 Version
216+
217+
Current Version: **0.1.0**
218+
219+
---
220+
221+
**Made with ❤️ by [dino65-dev](https://github.com/dino65-dev)**

0 commit comments

Comments
 (0)