惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
博客园 - Franky
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
爱范儿
爱范儿
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
Microsoft Security Blog
Microsoft Security Blog
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
My Old MacBook Air Couldn't Handle It — So I Used Google ...
hiyoyo · 2026-05-21 · via DEV Community

Introduction

I recently booted up an offline card game I used to love — and couldn't clear the hardest difficulty anymore.

I used to be able to beat it.

That frustration sparked an idea: what if I trained an AI to help me figure it out? I had three constraints going in:

  • It had to work offline
  • I wanted to try reinforcement learning while I was at it
  • It had to be lightweight enough to run on an 8-year-old MacBook Air

After a lot of trial and error, I landed on building a custom engine in Rust and running the training on Google Colab. This article focuses on the Google Colab side of that setup.


What Is Google Colab?

Google Colab is a free Python execution environment provided by Google (this article assumes the free tier). All you need is a browser — no installation required.

What made it useful for this project:

  • Free GPU/CPU access
  • Integrates with Google Drive
  • Runs heavy workloads regardless of your local hardware

Training that would've been painful on an old MacBook Air ran smoothly once I moved it to Colab.

⚠️ Note: On the free tier, the session disconnects after a period of inactivity or after a maximum of 12 hours, and runtime data is reset.


What I Did

The goal was to train an AI to play an offline deck-building card game using reinforcement learning.

Here's the overall flow:

  1. Translate the game rules and card effects into language
  2. Convert that into numerical data the AI can work with
  3. Build a custom training engine in Rust
  4. Upload the training data to Google Drive
  5. Mount Google Drive in Colab and run it

Steps 1–3 are all on the Rust side — I'll cover those in a follow-up. This article focuses on steps 4 and 5.


Mounting Google Drive in Colab

Run the following code in a Colab cell:

from google.colab import drive
drive.mount('/content/drive')

Enter fullscreen mode Exit fullscreen mode

You'll see a prompt asking to authorize access to Google Drive. Click "Connect to Google Drive", choose your account, and allow access. Once done, a drive/MyDrive folder will appear in the left sidebar.

After mounting, your Drive is accessible at:

/content/drive/MyDrive/

Enter fullscreen mode Exit fullscreen mode

💡 You can also mount Drive without writing any code — just click the folder icon in the left sidebar and hit the "Mount Drive" button. It inserts the code automatically.

⚠️ If Google Drive's cache is stale, updates to your Drive may not reflect in Colab. If that happens, force a remount:

drive.flush_and_unmount()
drive.mount('/content/drive', force_remount=True)

Enter fullscreen mode Exit fullscreen mode


Running the Binary and Starting Training

Once Drive is mounted, you can execute the file you uploaded directly from Colab.

subprocess is Python's standard library for calling external programs — in this case, the Rust binary:

import subprocess

result = subprocess.run(
    ['/content/drive/MyDrive/your_binary'],
    capture_output=True,
    text=True
)
print(result.stdout)

Enter fullscreen mode Exit fullscreen mode

Replace your_binary with your actual filename.

💡 If you get a permission error, run this first. 0o755 grants execute permission on Linux:

import os
os.chmod('/content/drive/MyDrive/your_binary', 0o755)

Enter fullscreen mode Exit fullscreen mode


Stuck? Ask Gemini

Colab has Gemini built in — just click the icon in the top right. Paste your error message directly and it'll suggest a fix. Don't hesitate to just dump the error and let it figure it out 😊


Closing

I covered the Google Colab basics, mounting Google Drive, and running a Rust binary — all from a browser, on hardware that couldn't have handled the training locally.

If this was useful, the follow-up covers the reinforcement learning setup and how I represented the game state. I'll write it if there's interest 😊

👇 Part 2 here
(coming soon)