Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Magic CLI]: magic/max does not support usage in google colab notebooks #223

Open
guidorice opened this issue Sep 13, 2024 · 1 comment
Open
Assignees

Comments

@guidorice
Copy link

guidorice commented Sep 13, 2024

Background

https://colab.research.google.com is widely used in data science and AI because of it's pay-as-you go model using a variety of TPU or NVIDIA GPU's. A common use case is going to be to install MAX and python packages into the notebook environment on colab. Couple of other key points:

  • Colab does not seem to support switching notebook kernels via a menu item. This makes it fundamentally different than jupyter notebook which is self hosted or run locally.
  • Every tutorial in existence for colab notebooks seems to start off with a notebook cell with the shell command ! pip install my-packages ... into the existing python env. Many scientific and AI packages are pre-installed, for example fastai, torch and transformers.

Reproduce steps

Go to https://docs.modular.com/max/python/get-started and follow the steps, but in a colab notebook. I am using Colab Pro, which also has a terminal window:

$ curl -ssL https://magic.modular.com | bash
$ magic init roberta-project && cd roberta-project
$ magic add max "numpy<2.0"
$ magic add --pypi "torch==2.2.2" "transformers==4.40.1"
$ magic shell
$ python3 -c 'from max import engine; print(engine.__version__)'
24.5.0
$ python --version
Python 3.12.5

^ as you can see max python package is installed, and python 3.12 as well.

The problem is, all the packages are in a virtualenv, however this is not something the notebook can use!

To confirm, create a notebook cell and execute it (from the get-started doc):

from pathlib import Path

import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

from max import engine

ModuleNotFoundError: No module named 'max'

The reason the other imports succeeded is because torch and transformers is pre-installed on colab instances.

Related issues

Suggestion

Enhance magic to support installing into the system python, something like:

magic add --global max

@guidorice
Copy link
Author

I discovered there is a magic global subcommand, but I did not get any fixes from it: https://docs.modular.com/magic/commands#magic-global

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants