Issue: Ngrok authentication error
ERROR: Failed to create ngrok tunnel: authentication failed
Solution:
- Get a valid ngrok auth token from ngrok dashboard
- Set the token correctly:
import os
os.environ["NGROK_AUTH_TOKEN"] = "your_token_here"Issue: Out of Memory (OOM) errors
RuntimeError: CUDA out of memory
Solution:
- Enable memory optimizations using CLI (recommended):
# In Colab, use the ! prefix
!locallab config --quantize true --quantize-type int8- Or using environment variables (backup method):
os.environ["LOCALLAB_ENABLE_QUANTIZATION"] = "true"
os.environ["LOCALLAB_QUANTIZATION_TYPE"] = "int8"- Use a smaller model using CLI (recommended):
# In Colab, use the ! prefix
!locallab config --model microsoft/phi-2- Or using environment variables (backup method):
os.environ["HUGGINGFACE_MODEL"] = "microsoft/phi-2" # Smaller modelIssue: Cannot connect to server
ConnectionError: Failed to connect to server
Solution:
- Ensure you're using the correct URL:
- For local connections within Colab:
http://localhost:8000 - For external connections: Use the ngrok URL shown in server logs
- For local connections within Colab:
- Check if server is running
- Verify no firewall blocking
Issue: Runtime disconnected Solution:
- Keep Colab tab active
- Use "Connect to hosted runtime"
- Restart kernel if needed
-
Memory Management
- Monitor memory usage
- Use appropriate model size
- Enable optimizations
-
Connection Management
- Save ngrok URL
- Handle reconnections
- Check server status
-
Error Recovery
try: response = await client.generate("prompt") except Exception as e: if "out of memory" in str(e): # Switch to smaller model os.environ["HUGGINGFACE_MODEL"] = "microsoft/phi-2" await client.reload_model()