Member-only story
Switching Between Multiple Conda Distributions on macOS
A practical use case for data scientists who use MiniForge
The advent of Apple M-series chip sparked new hope in the Apple community. Starting with the M1 chip in Q4 2020, Mac developers, especially data scientists started switching from third-party sources and tools (with the most popular being Colab) to the native GPU of M1 processor.
Since then, more and more developers have started moving their workspace to macOS. The common denominator of all setups intended for data science projects in macOS is MiniForge.
For those who have not heard of MiniForge, it is basically a conda distribution, famous for its compatibility with Apple, including the Apple M1 devices. One could say it is comparable to Miniconda, but works very well with Apple.
You can access all the articles in the “Setup Apple M1 for Deep Learning” series from here.
MiniForge is not widely adopted though. As a consequence, the main challenge is that a small fraction of libraries (most of the times not the popular ones) cannot be installed by MiniForge. However, as the Apple community embraces this conda distribution, this fraction becomes smaller and smaller.
The obvious solution would be to utilize both MiniForge and Anaconda: For example, MiniForge could have frameworks or tools which take advantage of the GPU, while Anaconda could have non-compatible libraries, or whatever the developer deems necessary. The problem with this approach is that each time only one conda environment can be initialized. To overcome this situation, here’s how to do it:
This trick works for Ubuntu as well!
After installing MiniForge, the .zshrc file would look like this:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/johndoe/opt/miniforge/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/johndoe/opt/miniforge/etc/profile.d/conda.sh" ]; then
. "/Users/johndoe/opt/miniforge/etc/profile.d/conda.sh"
else
export PATH="/Users/johndoe/opt/miniforge/bin:$PATH"
fi
fi
unset…