Skip to main content
Log in

Install MAX/Mojo with conda

Although we recommend using Magic to manage your virtual environments and packages for MAX and Mojo, you can also add MAX/Mojo to a conda project.

Get started with MAX

Here's how to install MAX using conda and then deploy a GenAI model on a local endpoint:

  1. Create a conda project that includes MAX:

    conda create -n max-project -c conda-forge -c https://conda.modular.com/max/ \
    python=3.11 max=* max-pipelines=* -y
    conda create -n max-project -c conda-forge -c https://conda.modular.com/max/ \
    python=3.11 max=* max-pipelines=* -y
  2. Activate the environment:

    conda activate max-project
    conda activate max-project
  3. Start a local endpoint for Llama 3:

    max-pipelines serve --model-path=modularai/Llama-3.1-8B-Instruct-GGUF
    max-pipelines serve --model-path=modularai/Llama-3.1-8B-Instruct-GGUF

    In addition to starting a local server, this downloads the model weights and compiles the model, which might take some time.

    The endpoint is ready when you see the URI printed in your terminal:

    Server ready on http://0.0.0.0:8000 (Press CTRL+C to quit)
    Server ready on http://0.0.0.0:8000 (Press CTRL+C to quit)
  4. Now open another terminal to send a request using curl:

    curl -N http://0.0.0.0:8000/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
    "model": "modularai/Llama-3.1-8B-Instruct-GGUF",
    "stream": true,
    "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Who won the World Series in 2020?"}
    ]
    }' | grep -o '"content":"[^"]*"' | sed 's/"content":"//g' | sed 's/"//g' | tr -d '\n' | sed 's/\\n/\n/g'
    curl -N http://0.0.0.0:8000/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
    "model": "modularai/Llama-3.1-8B-Instruct-GGUF",
    "stream": true,
    "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Who won the World Series in 2020?"}
    ]
    }' | grep -o '"content":"[^"]*"' | sed 's/"content":"//g' | sed 's/"//g' | tr -d '\n' | sed 's/\\n/\n/g'

Now check out these tutorials for more about how to accelerate your GenAI models with MAX:

Get started with Mojo

Here's how to install Mojo using conda and run a code example:

  1. Create a conda project that includes MAX/Mojo:

    conda create -n mojo-project -c conda-forge -c https://conda.modular.com/max/ \
    python=3.11 max=* -y
    conda create -n mojo-project -c conda-forge -c https://conda.modular.com/max/ \
    python=3.11 max=* -y
  2. Activate the environment and you'll have access to mojo:

    conda activate mojo-project
    conda activate mojo-project
    mojo --version
    mojo --version
  3. Try one of the Mojo code examples:

    git clone https://github.com/modular/modular.git
    git clone https://github.com/modular/modular.git
    cd max/examples/mojo
    cd max/examples/mojo
    mojo hello_interop.mojo
    mojo hello_interop.mojo
    Hello Mojo 🔥!
    9
    6
    3
    Hello from Python!
    I can even print a numpy array: [1 2 3]
    Hello Mojo 🔥!
    9
    6
    3
    Hello from Python!
    I can even print a numpy array: [1 2 3]

Now continue exploring Mojo with these tutorials:

What's included

The max conda package installs the following:

The max-pipelines package installs the max CLI.

Known issues

  • You might encounter issues if you invoke magic within a conda virtual environment. It's best if you don't mix the two tools.