Conda

The following section is to take notes of potential problems/solutions and/or corresponding commands when one tries to install python, conda and Python packages on osx-64/osx-arm64.

Basic Knowledge about Conda

Install Conda

  • condaforge

  • conda/miniconda

  • mamba/micromamba

Create a Conda Environment

The follow commands create an conda environment with name <env-name> and python of version 3.9.

CONDA_SUBDIR=osx-64 conda create -n <env-name> python=3.9
conda activate myenv_x86
conda config --env --set subdir osx-64

Install Packages via conda-forge

c stands for channel.

conda install <package> -c conda-forge
conda config --show [channels]
conda config --remove channels <channel>
conda config --add channels <channel>
conda config --set show_channel_urls yes

veclib speeds up numpy with ARM64 python

result of Python 3.7.12(OSX64):

mean of 10 runs: 31.43530s

result of Python 3.9.13(ARM64):

mean of 10 runs: 1.13074s
  • python code
import time
import numpy as np
 
np.random.seed(42)
 
a = np.random.uniform(size=(300, 300))
runtimes = 10
timecosts = []
 
for _ in range(runtimes):
  s_time = time.time()
  for i in range(100):
    a += 1
    np.linalg.svd(a)
  timecosts.append(time.time() - s_time)
print(f'mean of {runtimes} runs: {np.mean(timecosts):.5f}s')

Using Conda via Mamba

Python Packaging and Dependency Management with Poetry

Reference