Install Conda Mac Os X

Table Of Contents

The Jupyter Notebook is a web-based interactive computing platform. The notebook combines live code, equations, narrative text, visualizations, interactive dashboards and other media. Miniconda is a free minimal installer for conda. It is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others. Use the conda install command to install 720+ additional conda packages from the Anaconda repository. I downloaded Python 3.7.2 for Mac OS X, which is the latest version. # $ conda install -n root license There was a problem creating the 'gl-env' conda. Installing Prerequisites on Mac OS X¶ There are a few prerequisites which must be installed on your machine before you will be able to build and install OpenMOC. All of the prerequisites can easily be installed using a standard package manager, such as MacPorts for Mac OS X. Linux (x86) and Mac OS X users who already have conda can install using the following command: conda install -c conda-forge openfst. OpenFst is a library for constructing, combining, optimizing, and searching weighted finite-state transducers (FSTs).

  • Installation on OS X
    • Installation components
      • Installing Python
      • Source installation Dependencies
    • Using The Kivy.app

To install Kivy on OS X using pip, please follow the maininstallation guide.Otherwise, continue to the Kivy.app instructions below.

Installation components¶

Following, are additional information linked to from some of the steps in themain installation guide, specific to OS X.

Installing Python¶

Homebrew¶

If you’re using Homebrew, you can install Python with:

MacPorts¶

If you’re using Macports, you can install Python with:

Frameworks¶

To install frameworks Python on OSX, download it from the mainPython website and follow theinstallation steps. You can read more about the installation in thePython guide.

Source installation Dependencies¶

To install Kivy from source, please follow the installation guide until you reach theKivy install step and then install the additional dependenciesbelow before continuing.

Homebrew¶

If you’re using Homebrew, you can install the dependencies with:

MacPorts¶

Note

You will have to manually install gstreamer support if you wish tosupport video playback in your Kivy App. The latest port documents show thefollowing py-gst-python port.

If you’re using MacPorts, you can install the dependencies with:

Install Conda Mac Os X Update

Frameworks¶

If you’re installing Python from a framework, you will need to install Kivy’s dependenciesfrom frameworks as well. You can do that with the following commands (customize as needed):

Now that you have all the dependencies for kivy, you need to make sureyou have the command line tools installed:

Using The Kivy.app¶

Note

Kivy.app is built on the current GitHub Action macOS version and will typicallynot work on older OS X versions. For older OS X versions, you need to build Kivy.appon the oldest machine you wish to support. See below.

For OS X 10.14.4+ and later, we provide a Kivy DMG with all dependenciesbundled in a virtual environment, including a Python interpreter. This isprimarily useful for packaging Kivy applications.

You can find complete instructions to build and package apps with Kivy.app in the readmeof the kivy-sdk-packager repo.

To install the Kivy virtualenv, you must:

  1. Navigate to the latest Kivy release on Kivy’s website orGitHub and download Kivy.dmg.You can also download a nightly snapshot ofKivy.app.

  2. Open the dmg

  3. In the GUI copy the Kivy.app to /Applications by dragging the folder icon to the right.

  4. Optionally create a symlink by running the following command:

    This creates the kivy binary that you can use instead of python to run scripts.I.e. instead of doing pythonmy_script.py or python-mpipinstall<modulename>, writekivymy_script.py or kivy-mpipinstall<modulename> to run it using the kivybundled Python interpreter with the kivy environment.

    As opposed to activating the virtualenv below, running with kivy will use the virtualenvbut also properly configure the script environment required to run a Kivy app (i.e. settingkivy’s home path etc.).

Using the App Virtual environment¶

The path to the underlying virtualenv is /Applications/Kivy.app/Contents/Resources/venv.To activate it so you can use python, like any normal virtualenv, do:

On the default mac (zsh) shell you must be in the bin directory containing activate to beable to activate the virtualenv, hence why we changed the directory temporarily.

kivy_activate sets up the environment to be able to run Kivy, by setting the kivy home,gstreamer, and other variables.

Start any Kivy Application¶

You can run any Kivy application by simply dragging the application’s main fileonto the Kivy.app icon.

The best laptop ever produced was the 2012-2014 Macbook Pro Retina with 15 inch display. It has a CUDA-capable GPU, the NVIDIA GeForce GT 650M. This GPU has 384 cores and 1 GB of VRAM, and is CUDA capability 3. Although puny by modern standards, it provides about a 4X speedup over the cpu for Pytorch, and is fine for learning Pytorch and prototyping. If you have a newer MacBook Pro you are out of luck, because it either has a Radeon GPU or none at all.

The standard Mac distribution of Pytorch does not support CUDA, but it is supported if you compile Pytorch from source. There are numerous preliminary steps and 'gotchas'. Here is what you need to do. Thanks to Jack Dyson for this write up based on an earlier version that I published earlier. These instructions have been tested for:

OS : MacOS High Sierra 10.13.6 (17G14042)
GPU Driver: NVIDIA Web Driver 387.10.10.10.4.140
GPU CUDA Driver Version: 418.163
Xcode Version: 10.1 (10B61)

Downgrade to High Sierra

Check that you are running Mac OS X High Sierra (10.13.6). If you have an older version, upgrade. If you have a newer version you will need to downgrade; Apple banished CUDA with Mojave and later versions of the OS. Downgrading OS X requires creating a bootable USB memory stick installer and erasing your laptop's hard disk.

Install Xcode

Check that you have installed Xcode version 10.1. If you have a newer version or none at all, download it from the Apple Developer site. Rename any other version of Xcode you have installed, and then copy it to /Applications. Open Xcode, and under preferences, select the 10.1 command line tools. Close Xcode and open a terminal. Run

xcode-select --install
to reinstall the command line tools, because sometimes the Xcode application fails to install certain header files.

Install NVIDIA Drivers

Install the NVIDIA Quadro and Geforce OS X Driver 387.10.10.10.40.140.

Add to your .profile and reboot:

export PATH=/Developer/NVIDIA/CUDA-10.0/bin${PATH:+:${PATH}}
export DYLD_LIBRARY_PATH=/usr/local/cuda/lib:$DYLD_LIBRARY_PATH

Install NVIDIA cuDNN 7.6.5.

Install Conda

Install Anaconda. Create an environment named ptc that includes pip, activate it, and install libraries:
conda create --name ptc python=3.7
conda activate ptc
conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses
conda install pkg-config libuv

Build Pytorch

Now you are ready to build Pytorch with Cuda!

conda activate ptc
git clone --recursive https://github.com/pytorch/pytorch

Finally you build:

cd pytorch
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-'$(dirname $(which conda))/../'}
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install

Post Installation

conda activate ptc
pip install torchvision

Reboot and test that pytorch with CUDA is working:

Mac Os X Download

conda activate ptc
python
import torch
torch.cuda.is_available()
Install Conda Mac Os X If python does not print 'true', something has gone wrong.

Install ptc as a kernel for jupyter notebooks.

conda deactivate
conda install ipykernel
python -m ipykernel install --user --name ptc --display-name 'Python 3.7 (ptc)'

When a program first invokes CUDA, a warning message will be printing stating that the GPU is too old. The message can be ignored - CUDA will indeed work! In order to eliminate the message, edit the file

~/anaconda3/envs/ptc/lib/python3.6/site-packages/torch/cuda/__init__.py
and in the definition of the function _check_capability() eliminate the string
capability(3,0) or

Download Pytorch examples and compare time required with and without cuda. Note that these examples require Torchvision.

Install
git clone https://github.com/pytorch/examples
cd examples/mnist
conda activate ptc
time python main.py >/dev/null
real 1m38.430s
user 2m6.163s
sys 0m7.762s
time python main.py --no-cuda >/dev/null
real 5m47.750s
user 37m22.609s
sys 1m23.813s

For the non-CUDA case, user time is greater than real time because Pytorch makes use of all 8 cpu hyperthread cores.

Congratulations, you are ready to set the deep learning world on fire!

Henry Kautz, 21 December 2020