pip install hcgk-kernel# Check hardware authorization
hcgk check
# View system information
hcgk info
# View configuration
hcgk configfrom hcgk_kernel import HCGKKernel
kernel = HCGKKernel()
authorized, message = kernel.authorize()
if authorized:
# Proceed with model loading
passValidate hardware before attempting to load a model:
from hcgk_kernel import HCGKKernel
def safe_model_load(model_path):
kernel = HCGKKernel()
authorized, message = kernel.authorize()
if not authorized:
raise RuntimeError(f"Cannot load model: {message}")
return load_model(model_path)Use authorization status as script exit code:
import sys
from hcgk_kernel import HCGKKernel
kernel = HCGKKernel(silent=True)
authorized, _ = kernel.authorize()
sys.exit(0 if authorized else 1)Retrieve detailed system information:
from hcgk_kernel import HCGKKernel
kernel = HCGKKernel()
info = kernel.get_system_info()
print(f"RAM: {info['ram']['total_gb']}GB")
print(f"GPU: {info['gpu']['name']}")Configure custom hardware requirements:
from hcgk_kernel import HCGKKernel, HCGKConfig
config = HCGKConfig(
MIN_RAM_GB=16.0,
MIN_VRAM_GB=8.0
)
kernel = HCGKKernel(config=config)
authorized, message = kernel.authorize()export HCGK_MIN_RAM_GB=8.0 # Minimum RAM for GPU mode
export HCGK_MIN_VRAM_GB=4.0 # Minimum VRAM
export HCGK_MIN_RAM_NO_GPU_GB=16.0 # Minimum RAM for CPU mode
export HCGK_RAM_SAFETY_MARGIN=0.1 # Reserve 10% RAMfrom hcgk_kernel import HCGKConfig
config = HCGKConfig(
MIN_RAM_GB=32.0,
MIN_VRAM_GB=16.0,
RAM_SAFETY_MARGIN=0.15,
MAX_SCAN_RETRIES=3
)# Basic check
hcgk check
# Silent mode (exit code only)
hcgk check --silent
# Verbose output
hcgk check --verbose# Human-readable format
hcgk info
# JSON format
hcgk info --json
# With requirements check
hcgk info --requirements# View configuration
hcgk config
# JSON format
hcgk config --json# Validate configuration
hcgk validate- RAM: 8 GB minimum (default)
- VRAM: 4 GB minimum (default)
- RAM: 16 GB minimum (default)
All requirements are configurable.
kernel = HCGKKernel(silent=False, config=None)Methods:
authorize() -> Tuple[bool, str]- Check hardware authorizationget_system_info() -> Dict- Get detailed system information
config = HCGKConfig(
MIN_RAM_GB=8.0,
MIN_VRAM_GB=4.0,
MIN_RAM_NO_GPU_GB=16.0,
RAM_SAFETY_MARGIN=0.1,
MAX_SCAN_RETRIES=2,
STRICT_MODE=True
)from hcgk_kernel import HCGKKernel
import torch
def load_model_safely(path):
kernel = HCGKKernel()
authorized, message = kernel.authorize()
if not authorized:
print(f"Hardware check failed: {message}")
return None
info = kernel.get_system_info()
device = "cuda" if info['gpu']['available'] else "cpu"
model = torch.load(path, map_location=device)
print(f"Model loaded on {device}")
return model
model = load_model_safely("model.pt")from hcgk_kernel import HCGKKernel
kernel = HCGKKernel()
info = kernel.get_system_info()
# Select model based on available resources
if info['gpu']['available'] and info['gpu']['vram_total_gb'] >= 16:
model_name = "large-model"
elif info['ram']['total_gb'] >= 32:
model_name = "medium-model"
else:
model_name = "small-model"
print(f"Loading {model_name} based on available hardware")#!/usr/bin/env python3
import sys
from hcgk_kernel import HCGKKernel
def main():
kernel = HCGKKernel()
authorized, message = kernel.authorize()
if not authorized:
print(f"Error: {message}", file=sys.stderr)
return 1
# Proceed with main logic
print("Hardware validated, proceeding...")
return 0
if __name__ == "__main__":
sys.exit(main())from hcgk_kernel import HCGKKernel, HCGKConfig
def validate_for_training():
"""Strict validation for model training."""
config = HCGKConfig(
MIN_RAM_GB=32.0,
MIN_VRAM_GB=16.0,
RAM_SAFETY_MARGIN=0.2,
STRICT_MODE=True
)
kernel = HCGKKernel(config=config)
return kernel.authorize()
def validate_for_inference():
"""Relaxed validation for model inference."""
config = HCGKConfig(
MIN_RAM_GB=8.0,
MIN_VRAM_GB=4.0,
STRICT_MODE=False
)
kernel = HCGKKernel(config=config)
return kernel.authorize()Problem: ModuleNotFoundError: No module named 'hcgk_kernel'
Solution: Install the package:
pip install hcgk-kernelProblem: hcgk: command not found
Solution: Ensure package is installed correctly:
pip install --force-reinstall hcgk-kernelProblem: Authorization consistently denied
Solution: Check system information and requirements:
hcgk info --requirementsAdjust configuration if needed:
export HCGK_MIN_RAM_GB=4.0
export HCGK_MIN_VRAM_GB=2.0Problem: Missing psutil or torch
Solution: Install dependencies:
pip install psutil torch- Validate Early: Check hardware before loading models
- Handle Failures: Always check authorization result
- Configure Appropriately: Set thresholds based on your models
- Use Silent Mode: In scripts, use
silent=Truefor cleaner output - Check System Info: Use
get_system_info()for optimization decisions - Log Authorization: Enable logging for production deployments
- Read the full README for detailed documentation
- Check the API Reference for all available methods
- Review Examples for common use cases
- Configure thresholds based on your specific models