Linux AI Development: 5 Easy Steps to a PyTorch Setup

Linux AI development starts with one practical question: which install command matches your hardware? This article answers it from official sources, read on 2 November 2026: the PyTorch Get Started page and the scikit-learn install guide. It is based on that documentation, not on a new test for this post. The old version was a general overview listing TensorFlow, Keras, pandas and cloud options without a single command; it has been replaced with a setup you can follow.

Step 1: check that your Linux is supported

The PyTorch page says PyTorch is supported on Linux distributions that use glibc 2.28 or newer, and lists minimum versions, among them Arch Linux 2020.01.22, CentOS 8, Debian 10.0, Fedora 24, Mint 20, OpenSUSE 15, Slackware 14.2 and Ubuntu 20.04, with the note that 20.04 has reached end of life. Check your glibc with ldd --version. A GPU is recommended but not required: the page says an NVIDIA or AMD GPU lets you use the full power of PyTorch, and everything also works on a CPU.

Step 2: get Python and pip for Linux AI development

The PyTorch docs say Python 3.10 to 3.14 is generally installed by default on supported distributions, but that pip is not, and give:

sudo apt install python3-pip

On Fedora or other distributions, use the matching package manager; the docs note, for example, that yum may replace apt. The scikit-learn guide suggests checking first:

python3 --version
pip3 --version

Step 3: create a virtual environment for Linux AI development

The scikit-learn guide calls a virtual environment "optional but strongly recommended" to avoid conflicts with other packages. Its Linux commands:

python3 -m venv sklearn-env
source sklearn-env/bin/activate
pip3 install -U scikit-learn

Use one environment per project. This matters more in Linux AI development than elsewhere, because PyTorch builds for CPU, CUDA and ROCm are different packages, and mixing them in the system Python is a common source of broken installs. The same rule saved trouble in the Python 3.13 install post, where replacing the system python3 broke system tools in a real lab.

Step 4: pick the right PyTorch command

The PyTorch page builds the command from a selector: OS, package, language and compute platform. For Linux, pip and Python, the stable entries on 2 November 2026 were:

Linux AI development PyTorch install commands for CPU, NVIDIA CUDA and AMD ROCm from pytorch.org
The Linux pip commands from the PyTorch selector on the date of writing.
# CPU only
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cpu
# NVIDIA, default CUDA build
pip3 install torch torchvision
# NVIDIA, newer CUDA build
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu134
# AMD ROCm
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/rocm10.0

These change with every release, so open the selector before you install. The important difference: without an --index-url, pip installs the default CUDA build, which is much larger than the CPU build. On a server or laptop without a GPU, always use the CPU index. The docs' own guidance is short: no CUDA- or ROCm-capable system, choose CPU; CUDA system, choose the CUDA version suited to your machine; ROCm system, choose the supported ROCm version.

Step 5: verify the install

The PyTorch docs verify with a random tensor:

import torch
x = torch.rand(5, 3)
print(x)

You should see a 5x3 tensor of random numbers. For scikit-learn, the guide gives python3 -c "import sklearn; sklearn.show_versions()", which prints the versions of scikit-learn and its dependencies, and python3 -m pip freeze to list everything in the environment.

The conda alternative for Linux AI development

Some teams prefer conda because it can also manage non-Python libraries. The scikit-learn guide documents it without administrator rights, using the conda-forge installers:

conda create -n sklearn-env -c conda-forge scikit-learn
conda activate sklearn-env
conda list scikit-learn

Pick one tool per environment. Mixing conda and pip installs of the same package in one environment makes Linux AI development harder to debug, because it is no longer clear which copy Python imports. If you use pip, stay with pip for that project; if you use conda, check the PyTorch selector for what it currently offers for your platform.

Keep your Linux AI development environment reproducible

The scikit-learn checks double as an inventory. python3 -m pip show scikit-learn prints the version and location, and python3 -m pip freeze lists every package in the environment. Save that list with the project. When a colleague or a server needs the same setup, a new venv plus that file rebuilds it.

Linux AI development without a GPU

A CPU is enough to learn, to run classic machine learning with scikit-learn, and to run small language models. I tested exactly that in the Ollama on Linux post, where a 1B model answered at about 63 tokens per second on a 20-thread CPU. For training large models you need a GPU, and then the CUDA or ROCm choice in step 4 decides which wheel you install. AMD users who want custom kernels can read the ROCm kernels guide.

Common Linux AI development mistakes

  • Installing into the system Python instead of a venv.
  • Running the default pip3 install torch on a machine without an NVIDIA GPU and downloading the CUDA build for nothing.
  • Copying an old command with an outdated CUDA index; the selector changes with every PyTorch release.
  • Using a distribution older than the glibc 2.28 requirement.
  • Forgetting that pip is not installed by default, then using a random script to get it.

What to add next

Once the base works, add libraries one at a time inside the same venv and record them with pip freeze > requirements.txt, so the setup can be rebuilt. For deployment, containers keep the environment identical across machines; build caching and secrets are covered in the Docker BuildKit post.

FAQ

Is Linux better than Windows for AI development? This post does not compare them. For Linux AI development, the PyTorch page offers CPU, CUDA and ROCm builds, and ROCm is listed as not available on Windows in the same selector data.

Do I need conda? No. Both guides show pip with a venv; scikit-learn also documents a conda option.

Which Python version? The PyTorch Linux section recommends Python 3.10 to 3.14.

Comments

Popular posts from this blog

How to Play Minecraft Bedrock Edition on Linux: A Comprehensive Guide for Tech Professionals

Linux desktop frozen? My 5 go-to tricks to try - before forcing a hard reboot

The Ultimate Guide: How to Set Up DXVK in Wine on Linux for Enhanced Gaming Performance