Is there a way to specify the architecture/platform when creating a new conda environment? Alternatively, how does conda detect its current architecture/platform when its run?
What I'm aiming to do is this: I'm running on an Apple Silicon laptop. My pre-existing environments are running fine through Rosetta2, but I'd like to start experimenting with python running natively on Apple Silicon. miniforge
provides a conda-forge repository with Apple Silicon builds, and I can tell conda to use the conda-forge
channel when I create an environment. But I'm not seeing a way to specify that I'd like this to be an arm64 environment rather than an x86_64 environment, other than starting from miniforge's installer.
Thanks in advance.
Create a new conda environment from a list of specified packages. To use the newly-created environment, use 'conda activate envname'. This command requires either the -n NAME or -p PREFIXoption.
We are very excited to announce that this newest Anaconda Distribution release will, in addition to existing supported architectures, feature native ARM64 support for M1 Macs!
CONDA_SUBDIR=osx-arm64 conda create -n native numpy -c conda-forge
will get you a osx-arm64
native env.
To make it permanent, do,
conda activate native
conda config --env --set subdir osx-arm64
arm64
and x86_64
on M1 Apple SiliconAdding to the answers, it is possible to configure conda
to use both osx-arm64
(arm64) and osx-64
(x86_64) architectures.
I found adding conda config --env --set subdir osx-arm64
changes the option globally which created issues for me. Some of my projects relied on python dependencies that were only supported in either one or the other architecture not both: specifically tensorflow
.
xcode-select --install
miniforge3
Install miniforge3 by downloading the shell script from here: https://github.com/conda-forge/miniforge. Ensure you select arm64 (Apple Silicon) architecture. You may need to enable execution of the shell script with:
chmod +x Miniforge3-MacOSX-arm64.sh
Then execute is with:
sh Miniforge3-MacOSX-arm64.sh
~/.zshrc
or ~/.bashrc
:Add the following code to ~/.zshrc
.
The code will add two shortcut functions to create either an osx-64
or osx-arm64
conda environment.
# Create x86 conda environment
create_x86_conda_environment () {
# example usage: create_x86_conda_environment myenv_x86 python=3.9
CONDA_SUBDIR=osx-64 conda create -n $@
conda activate $1
}
# Create ARM conda environment
create_ARM_conda_environment () {
# example usage: create_ARM_conda_environment myenv_x86 python=3.9
CONDA_SUBDIR=osx-arm64 conda create -n $@
conda activate $1
}
Now to create a python 3.9.13
osx-64
(x86_64) environment with the name env_x86
:
create_x86_conda_environment env_x86 python=3.9.13
Alternatively for osx-arm64
(arm64) environment:
create_ARM_conda_environment env_ARM python3.9.13
Once activated you can install packages accordingly. In my case I needed an arm64
environment to install tensorflow-macos
.
conda install -c apple tensorflow-deps
pip install tensorflow-macos tensorflow-metal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With