How to Run Ollama on an M1 MacBook Air Using Multipass

How to Run Ollama on an M1 MacBook Air Using Multipass

This guide explains how to install and run Ollama on your MacBook Air M1 using Multipass. You'll set up an Ubuntu VM with custom resources and then install Ollama inside it. Follow these steps to get started.


Step 1: Install Multipass on Your M1 MacBook Air

  1. Download Multipass:

    • Visit the Multipass website.
    • Download the macOS installer compatible with the ARM architecture.
  2. Install Multipass:

    • Open the downloaded installer package.
    • Follow the on-screen instructions to complete the installation.
    • Once installed, Multipass is ready to manage Ubuntu VMs.

Step 2: Launch an Ubuntu Instance with Custom Resources

Since installing Ollama may require additional space and memory, launch a new instance with custom allocations.

  1. Open Terminal:
    Use the built-in Terminal on your Mac.

  2. Delete Existing Instances (if necessary):

    • If you have an instance with the same name, delete it by running:

      multipass delete myubuntu

    • Purge deleted instances:

      multipass purge

  3. Launch a New Instance:

    • Use the command below to create an instance with 6GB of RAM and 50GB of disk space:

      multipass launch --name myubuntu --memory 6G --disk 50G

    • Multipass will download the Ubuntu image (if not cached) and launch your VM.

  4. Verify the Instance:

    • Check the assigned resources with:

      multipass info myubuntu


Step 3: Connect to Your Ubuntu VM

  1. Access the Ubuntu Shell:
    • Run the following command to connect:

      multipass shell myubuntu

    • You are now inside your Ubuntu environment.


Step 4: Install Ollama in the Ubuntu VM

Now that the VM is running, install Ollama using its installation script.

  1. Update Package Repository (Optional but Recommended):

    • Inside the VM, update packages:

      sudo apt update

  2. Download and Install Ollama:

    • Run the installation command:

      curl -fsSL https://ollama.com/install.sh | sudo bash

    • The script will download the Linux arm64 bundle for Ollama and install it into /usr/local.

    • Note: If you encounter errors like “No space left on device,” confirm that you launched the VM with sufficient disk space (50G in our example).

  3. Troubleshooting Disk Errors:

    • If insufficient disk space errors occur during installation, make sure the --disk option was correctly set when launching the instance.

    • Check available disk space with:

      df -h


Step 5: Running and Using Ollama

  1. Verify Ollama Installation:

    • Once installed, check if Ollama is available by:

      ollama --version

    • If the command is not found, double-check the installation path and ensure /usr/local/bin is in your PATH variable.

  2. Launch or Configure Ollama:

    • Follow Ollama's documentation for further configuration and usage.
    • Typical usage instructions can be found on Ollama's website.

Additional Tips

  • Manage Your VM:

    • To stop the instance when not in use:

      multipass stop myubuntu

    • To start it again:

      multipass start myubuntu

  • Deleting and Recreating:

    • If you need a fresh start, delete the instance with:

      multipass delete myubuntu

    • And purge it with:

      multipass purge

  • Resources Adjustment:

    • For future adjustments, launch a new instance with your required --memory and --disk parameters.

Conclusion

By following this guide, you now have Multipass installed on your M1 MacBook Air, an Ubuntu VM configured with ample resources, and Ollama installed within that VM. This setup provides a lightweight, isolated environment for running and testing Ollama on your MacBook Air. If you have any questions or encounter issues, feel free to leave a comment or seek help.

Happy Multipassing and enjoy using Ollama!

Comments

Popular posts from this blog