With their Apple Silicon chips, the Apple machines have moved to an `arm64` architecture (from the `x86-64` of the Intel ones).
While the new chips are a great upgrade on their Intel counterparts, the new architecture involves some caveats and requires a transition from most softwares to run natively.
While the new chips are a great upgrade on their Intel counterparts, the new architecture involves some caveats and requires a transition from most pieces of software to run natively.
Thankfully, all programs meant for the retired Intel `x86-64` chips can be run through [Rosetta 2][rosetta2], a translation layer provided by Apple.
The following link is a useful resource to see which apps and softwares are optmised for Apple Silicon devices: https://isapplesiliconready.com/.
The following link is a useful resource to see which apps and pieces of software are optimized for Apple Silicon devices: https://isapplesiliconready.com/.
### Rosetta 2
...
...
@@ -26,8 +26,8 @@ The easiest way to handle your Python virtual environments is to use `miniforge`
Don't know what a **virtual environment** is or what purpose it serves?
Here is a good (but lengthy) [primer on virtual environments][virtual_env_primer]{target=_blank} by RealPython.
The [Github page of Miniforge][miniforge] contains download links to their installers for various configurations (conda/mamba, CPython/Pypy, amd64/arm64/macos-arm64 etc).
I personnaly recommend the `mambaforge` distributions, as the `mamba` tool is an amazing alternative to `conda` that one would be missing out on.
The [GitHub page of Miniforge][miniforge] contains download links to their installers for various configurations (conda/mamba, CPython/Pypy, amd64/arm64/macos-arm64 etc.).
I personally recommend the `mambaforge` distributions, as the `mamba` tool is an amazing alternative to `conda` that one would be missing out on.
!!! tip "Intel-Type Python Environments"
...
...
@@ -51,9 +51,9 @@ As `MAD-X` does not run natively on Apple Silicon chips, neither does `cpymad`.
As a consequence, in order to install `cpymad` on Apple Silicon, one needs to create an `osx-64`-type architecture environment in which to install the package.
For instructions on how to do so, see the **Intel-Type Python Environments** tooltip in the [Python Setup](#python-setup) section.
### Tensorflow on Silicon GPU
### TensorFlow on Silicon GPU
In version `2.5`, Tensorflow has introduced the [PluggableDevice][pluggable_device_blog] plugins API, which Apple has used to provide a plugin to make `tensorflow` aware of the GPU available on Apple Silicon chips.
In version `2.5`, TensorFlow has introduced the [PluggableDevice][pluggable_device_blog] plugins API, which Apple has used to provide a plugin to make `tensorflow` aware of the GPU available on Apple Silicon chips.
If one has a `miniforge` or `mambaforge` setup as instructed in the [Python Setup](#python-setup) above, creating a Python 3.9 environment to make use of `tensorflow` natively, running on the Apple Silicon GPU, is as simple as:
There is nothing more to do, Tensorflow will automatically detect the GPU and will use it for computations.
There is nothing more to do, TensorFlow will automatically detect the GPU and will use it for computations.
??? success "Verifying the Install"
One can test that the installation has made `tensorflow` aware of the Apple Silicon GPU by running the following script:
...
...
@@ -106,7 +106,7 @@ There is nothing more to do, Tensorflow will automatically detect the GPU and wi
```
!!! info ""
Note that the device is created with `0 MB memory`, which is normal since the Apple Silicon GPU shares a unified memory with the CPU and does not have a dedicated device memory.
Note that the device is detected with `0 MB memory`, which is normal since the Apple Silicon GPU shares a unified memory with the CPU and does not have a dedicated device memory.
Additionally, one can open the Activity Monitor during the model training and confirm that the Python process gets a high percentage value in the `GPU` column.
The PyTorch integration with Metal is not as seamless as the Tensorflow one, and just like with any other accelerators, PyTorch requires you to explicitely set the `device` for calculations.
The PyTorch integration with Metal is not as seamless as the TensorFlow one, and just like with any other accelerators, PyTorch requires you to explicitly set the `device` for calculations.
To use the Apple Silicon GPU, one has to specify the device as `mps` (Metal Performance Shaders) in either the `torch.device` constructor, or when creating tensors:
```python
importtorch
...
...
@@ -174,7 +169,7 @@ Here is [a guide](https://wikis.cern.ch/display/CONT/Containerisation+Guide+and+
### AFS
The `Auristor` filesystem works on Apple Silicon and can enable one to access `AFS`.
The `Auristor` filesystem works on Apple Silicon and can enable one to access `AFS`.
A step-by-step guide is available at the [following link](https://blog.auristor.com/2021/01/installing-auristorfs-clients-for-macos.html).