{"slug": "my-old-macbook-air-couldn-t-handle-it-so-i-used-google-colab-to-train-an-ai-1", "title": "My Old MacBook Air Couldn't Handle It — So I Used Google Colab to Train an AI＃1", "summary": "The author used Google Colab, a free cloud-based Python environment, to train an AI for playing an offline card game, as their old MacBook Air could not handle the computational load. It explains the process of mounting Google Drive to access files and running a Rust binary within Colab, noting that free tier sessions disconnect after 12 hours of inactivity. The piece focuses on the Colab setup, with a follow-up planned to cover the reinforcement learning and game state representation.", "body_md": "## Introduction\n\nI recently booted up an offline card game I used to love — and couldn't clear the hardest difficulty anymore.\n\nI used to be able to beat it.\n\nThat frustration sparked an idea: what if I trained an AI to help me figure it out? I had three constraints going in:\n\n- It had to work offline\n- I wanted to try reinforcement learning while I was at it\n- It had to be lightweight enough to run on an 8-year-old MacBook Air\n\nAfter 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.\n\n## What Is Google Colab?\n\nGoogle 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.\n\nWhat made it useful for this project:\n\n- Free GPU/CPU access\n- Integrates with Google Drive\n- Runs heavy workloads regardless of your local hardware\n\nTraining that would've been painful on an old MacBook Air ran smoothly once I moved it to Colab.\n\n⚠️ 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.\n\n## What I Did\n\nThe goal was to train an AI to play an offline deck-building card game using reinforcement learning.\n\nHere's the overall flow:\n\n- Translate the game rules and card effects into language\n- Convert that into numerical data the AI can work with\n- Build a custom training engine in Rust\n- Upload the training data to Google Drive\n- Mount Google Drive in Colab and run it\n\nSteps 1–3 are all on the Rust side — I'll cover those in a follow-up. **This article focuses on steps 4 and 5.**\n\n## Mounting Google Drive in Colab\n\nRun the following code in a Colab cell:\n\n``` python\nfrom google.colab import drive\ndrive.mount('/content/drive')\n```\n\nYou'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`\n\nfolder will appear in the left sidebar.\n\nAfter mounting, your Drive is accessible at:\n\n```\n/content/drive/MyDrive/\n```\n\n💡 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.\n\n⚠️ If Google Drive's cache is stale, updates to your Drive may not reflect in Colab. If that happens, force a remount:\n\n```\ndrive.flush_and_unmount()\ndrive.mount('/content/drive', force_remount=True)\n```\n\n## Running the Binary and Starting Training\n\nOnce Drive is mounted, you can execute the file you uploaded directly from Colab.\n\n`subprocess`\n\nis Python's standard library for calling external programs — in this case, the Rust binary:\n\n``` python\nimport subprocess\n\nresult = subprocess.run(\n    ['/content/drive/MyDrive/your_binary'],\n    capture_output=True,\n    text=True\n)\nprint(result.stdout)\n```\n\nReplace `your_binary`\n\nwith your actual filename.\n\n💡 If you get a permission error, run this first.\n\n`0o755`\n\ngrants execute permission on Linux:\n\n``` python\nimport os\nos.chmod('/content/drive/MyDrive/your_binary', 0o755)\n```\n\n## Stuck? Ask Gemini\n\nColab 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 😊\n\n## Closing\n\nI 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.\n\nIf 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 😊\n\n👇 Part 2 here\n\n(coming soon)", "url": "https://wpnews.pro/news/my-old-macbook-air-couldn-t-handle-it-so-i-used-google-colab-to-train-an-ai-1", "canonical_source": "https://dev.to/hiyoyok/my-old-macbook-air-couldnt-handle-it-so-i-used-google-colab-to-train-an-ai1-6p4", "published_at": "2026-05-21 02:16:42+00:00", "updated_at": "2026-05-21 02:31:53.578564+00:00", "lang": "en", "topics": ["artificial-intelligence", "machine-learning", "cloud-computing", "developer-tools"], "entities": ["Google Colab", "Google Drive", "Rust", "MacBook Air"], "alternates": {"html": "https://wpnews.pro/news/my-old-macbook-air-couldn-t-handle-it-so-i-used-google-colab-to-train-an-ai-1", "markdown": "https://wpnews.pro/news/my-old-macbook-air-couldn-t-handle-it-so-i-used-google-colab-to-train-an-ai-1.md", "text": "https://wpnews.pro/news/my-old-macbook-air-couldn-t-handle-it-so-i-used-google-colab-to-train-an-ai-1.txt", "jsonld": "https://wpnews.pro/news/my-old-macbook-air-couldn-t-handle-it-so-i-used-google-colab-to-train-an-ai-1.jsonld"}}