Add MAX/Mojo to a conda project
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.
Here's how to create a new conda environment with MAX/Mojo:
conda create -n max-project -c conda-forge -c https://conda.modular.com/max/ \
python=3.11 max=* -y
conda create -n max-project -c conda-forge -c https://conda.modular.com/max/ \
python=3.11 max=* -y
Then activate the environment and you'll have access to mojo
:
conda activate max-project
conda activate max-project
mojo --version
mojo --version
Run a MAX example
Each example in our MAX repo includes a conda environment.yml
file with the
environment named max-repo
. For example, here's how you can run one of the
MAX inference examples in a conda environment:
git clone https://github.com/modularml/max.git
git clone https://github.com/modularml/max.git
cd max/examples/inference/bert-python-torchscript
cd max/examples/inference/bert-python-torchscript
conda activate max-repo
conda activate max-repo
bash run.sh
bash run.sh
Run a Mojo example
Each example in our MAX repo includes a conda environment.yml
file with the
environment named max-repo
. For example, here's how you can run one of the
MAX inference examples in a conda environment:
git clone https://github.com/modularml/mojo.git
git clone https://github.com/modularml/mojo.git
cd mojo/examples
cd mojo/examples
conda create -n mojo-repo -c conda-forge -c https://conda.modular.com/max/ \
python=3.11 max=* -y
conda create -n mojo-repo -c conda-forge -c https://conda.modular.com/max/ \
python=3.11 max=* -y
conda activate mojo-repo
conda activate mojo-repo
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]
For more information about using conda, see the conda documentation.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!