Computation on Windows Arm64 Computers

Microsoft and other manufacturers had been releasing more arm64-based laptops and tablets. However, it is still quite inconvenient to set those computers for scientific computation in Python, R, etc. Overall, it is not recommended to use an arm64 Windows computer for data science works. Here are a few possible solutions.

General Solution

In general, we can use it as a Linux computer with WSL2. However, not all computational platforms/environments are available on Linux systems like Ubuntu. Even when they are available, they tend to support the server version better. RStudio Server is such an example. This may add another layer of learning and configuration.

Arm provides a comprehensive guidance on software installation. Many solutions, supposedly authoritative and tested, could be found on that website. For example, Anaconda (Python), Java, Docker, and Visual Studio are included in the guidance. These Arm-architecture solutions, however, are mostly for Mac and Linux, not for Windows.

Specific Environments

R and RStudio

R has an experimental arm64 version. We can directly download and install them. However, we do not have an arm64 version RStudio yet. Even if we make the R work, it is still not quite convenient without RStudio.

“Native” apps solution

Andrew Clinick shared a nice solution with WSL2/Ubuntu. This makes RStudio work like a native application on Windows.

R and RStudio Server

Another solution is to use R + RStudio Server on Ubuntu. Users can then use any browser to access RStudio.

Here are some of the general steps.

# Check for latest package versions
sudo apt update
# Upgrade currently installed packages
sudo apt upgrade

# Or the two together
sudo apt update && sudo apt upgrade

# check the version of ubuntu
lsb_release -a

# Verify the architecture
uname -m
# it should be "aach64"

Ubuntu has a repository for “packages” that can be managed by apt. We can search packages with a version/code name of Ubuntu. For example, we can search “r-base” using Ubuntu code name “noble” (LTS 24.0), which is the R for Linux/Ubuntu.

# list the package with name of r-base
# it is the base R package (same as on cran)
apt list r-base

# all r packages
apt list r-base-*

Once we confirm, the arm64 version of the r base and main packages are available, we can start installing them. RStudio Server also explains the process.

# Install the r-base
sudo apt install r-base

sudo apt-get install gdebi-core

# RStudio builds the experimental RStudio server for arm64
# https://dailies.rstudio.com/rstudio/kousa-dogwood/server/noble-arm64/

# Download the debian package to the local folder
wget https://s3.amazonaws.com/rstudio-ide-build/server/jammy/arm64/rstudio-server-2024.12.2-570-arm64.deb

# Install it
sudo gebi rstudio-server-2024.12.2-570-arm64.deb

By default, the service will start running once it is installed. We can access the service at http://localhost:8787.

For more details, check out the RStudio Server documentation.

Most useful commands for RStudio Sever is rstudio-server. We can start, stop, restart the service using this command.

Usage: rstudio-server {status|start|stop|restart|test-config|verify-installation|suspend-session|suspend-all|force-suspend-session|force-suspend-all|kill-session|kill-all|offline|online|active-sessions|version}

sudo rstudio-server stop

rstudio-server verify-installation

Although the install.packages("package_name") from the CRN repository works, it is rather costly because all the package source code will be compiled locally. It is recommended to use the Ubuntu packages repository.

# Make sure the package exisits
apt list r-cran-tidyverse

# if it does, install it through apt.
# if not, install.packages() in R and compile the source code
# It look likes installing any package from Ubuntu repository will install ALL packages.
# This is too costly for computers with limited space.
sudo apt install r-cran-tidyverse

r2u solution (the preferred approach) for R packages

A more thorough and elegant solution is r2u, which supports both amd64 and arm64 on Ubuntu noble. It essentially delivers CRAN packages as binaries, with other benefits like dependency integrity and complete support of all CRAN packages. The official Ubuntu packages repository only supports about 800 R packages. r2u supports over 24, 000. It is super fast as it always uses the release version of the compiled packages.

# Download the corresponding sh script from
# https://github.com/eddelbuettel/r2u

# Choose the right Ubuntu version. Note only noble supports arm64.

# Copy the file to your home folder
cp add_cranapt_noble.sh /home/joe/

# Run the script file
sudo bash add_cranapt_noble.sh

# Then the apt will use r2u respotitory to install/update r packages
sudo apt install r-cran-tidyverse

sudo apt install r-cran-sf

# Even when we run install.packages in R, it will also use r2u

Python without Anaconda

Python has started supporting Windows arm64 directly. It is completely fine to use "Python + venv + pip" to make Python work for Windows arm64. The real issues are those python packages that do not have Windows arm version.

So, a more robust solution is still the WSL2. Ubuntu has native support for Python. Then we can just use venv + pip to manage Python packages. This solution also works well for VS Code when we “remotely” connect to WSL2 on the same computer.

# install venv
sudo apt install python3-venv

# pip
sudo apt install python3-pip

# or reinstall
sudo apt install --reinstall python3-pip

# We suggest using apt or apt-get to install python package wheels at the system level. This is a safe and efficient way of installing Python pacakges, particularly when they have dependencies in C/C++ etc.
sudo apt-get install python3-rasterio

# Install as many commonly used packages as possible using apt

# create virtual environment named spatial in /home/envs folder
# Use --system-site-packages option to copy all those system packages to local virtual environments.
python3 -m venv --system-site-pacakges /home/envs/spatial

# activate
source /home/envs/spatial/bin/activate

# Verify
which python

# Deactivate
deactivate 

# If needed, we can clearn and re-create the virtual environment

# Save the list of local packages
python3 -m pip freeze -l > requirements.txt

# Clearn and recreate the environment
python3 -m venv clean spatial
python3 -m venv --system-site-pacakges /home/envs/spatial

# Install all the packages 
python -m pip install -r requirements.txt

Using pip to manage Python packages. Read the Python documentation for more details.

# List all packages in the current venv
python -m pip list

# install packages
python -m pip install geopandas plotly

# install a specific version. 
python -m pip install requests==2.6.0

Anaconda and Python

As the most stable and mature Python virtual environment and package dependency solution, it is always recommended to use Conda/Miniconda whenever possible.

For WSL2 on Windows arm computers, Conda/Miniconda works very well. Check out the official Anaconda installation documentation. Also take a look at the arm learning path solution for Anaconda.

View a full list of Anaconda Distribution installers in the official archive.

Same for Miniconda.

View a full list of Miniconda installers in the official Miniconda archive.

# Replace <FILENAME> with the installer Filename you copied from the archive

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh

bash ~/Miniconda3-latest-Linux-aarch64.sh

# This will activate the base environment
source ~/miniconda3/bin/activate

# After this, the conda command is available in bash environment

# Activate the "raster" environment
conda activate raster

# Deactivate "raster"
conda deactivate

# Deactivte base
conda deactivate

# Automatically start conda base on initialization
# Not recommended
conda init --all

# Reverse the automatic intilization
conda init --reverse

For a very informative explanation of conda initialization on Linux/Ubuntu, read this blog at Lin’s notes.


See also