Skip to content
Search Fedora

    Browse this documentation

    Installing PyTorch on Fedora: the 2 GiB repo route versus a 209 MB pip CPU wheel

    There are two ways to install PyTorch on Fedora, and the measured cost differs by an order of magnitude.

    Cost comparison between dnf torch and the pip CPU wheel

    Section titled “Route one: the Fedora repo (not recommended)”
    Terminal window
    dnf list --available python3-torch
    python3-torch.x86_64 2.12.0-7.fc45 fedora

    That looks like 399 MiB of download and 755 MiB installed, but the real run says:

    Total size of inbound packages is 2 GiB. Need to download 2 GiB.
    After this operation, 5 GiB extra will be used (install 5 GiB, remove 3 MiB).
    [ 1/747] cpuinfo-0:25.11.14-1.gitf858c 100% | 14.9 KiB/s | 44.7 KiB | 00m03s

    747 packages, 2 GiB of downloads, 5 GiB of disk. On this lab machine the download cache grew at roughly 43 KB/s, which puts the remainder at well over ten hours.

    ItemValue
    total download2 GiB
    dependency packages747
    disk usage5 GiB
    measured rate here~43 KB/s
    Section titled “Route two: the pip CPU wheel (recommended)”

    First check pip — Fedora does not install it by default:

    Terminal window
    python3 -m pip --version
    /usr/bin/python3: No module named pip

    Install it, then create a virtual environment:

    Terminal window
    sudo dnf install python3-pip
    python3 -m venv ~/torch-venv

    The measured python3-pip version is 26.1.2-5.fc45.

    Now pull the CPU-only wheel:

    Terminal window
    ~/torch-venv/bin/pip install --no-deps \
    --index-url https://download.pytorch.org/whl/cpu \
    "torch==2.15.0+cpu"
    Downloading torch-2.15.0%2Bcpu-cp315-cp315-manylinux_2_28_x86_64.whl (209.5 MB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 209.5/209.5 MB 5.9 MB/s 0:00:37

    209.5 MB at 5.9 MB/s, 37 seconds, versus 2 GiB at 43 KB/s — two orders of magnitude.

    import torch actually needs only a few small packages:

    Terminal window
    ~/torch-venv/bin/pip install \
    --index-url https://pypi.tuna.tsinghua.edu.cn/simple \
    typing_extensions filelock jinja2 fsspec

    After that import torch works — sympy and networkx are not required.

    NumPy is optional, but leaving it out produces a warning:

    UserWarning: Failed to initialize NumPy: No module named 'numpy'

    If .numpy() should work, add it:

    Terminal window
    ~/torch-venv/bin/pip install numpy
    import torch, time
    print("version:", torch.__version__)
    print("cuda available:", torch.cuda.is_available())
    print("threads:", torch.get_num_threads())
    a = torch.randn(512, 512); b = torch.randn(512, 512)
    t0 = time.time(); c = a @ b; dt = (time.time() - t0) * 1000
    print("matmul 512x512: %.2f ms" % dt)
    print("shape:", tuple(c.shape))
    print("mean:", float(torch.tensor([1.0, 2.0, 3.0]).mean()))

    Measured output:

    version: 2.15.0+cpu
    cuda available: False
    threads: 4
    matmul 512x512: 2.11 ms
    shape: (512, 512)
    mean: 2.0

    Four things stand out:

    • the version carries the +cpu suffix — a CPU-only build
    • cuda available: False is correct on a machine without a GPU, not a mistake
    • threads: 4 is CPU parallelism, derived from the core count
    • a 512×512 matrix multiply takes 2.11 ms

    With numpy present, tensor conversion works too:

    Terminal window
    ~/torch-venv/bin/python -c "import torch;print(torch.tensor([1.0,2.0]).numpy())"
    [1. 2.]
    Terminal window
    du -sm ~/torch-venv
    906

    The whole venv is 906 MB (the 209.5 MB wheel expands to roughly 900 MB), far below the 5 GiB of the repo route.

    Fedora python3-torchpip CPU wheel
    download2 GiB / 747 packages209.5 MB / 37 s
    disk5 GiB906 MB (venv)
    version2.12.02.15.0+cpu
    isolationinstalled into system Pythonvenv, delete the directory to uninstall
    good forsystem-wide managementalmost everything
    SymptomCause
    No module named pipFedora does not ship pip; dnf install python3-pip
    dependencies hang on sympythe primary index points at pytorch.org, where small packages crawl
    Failed to initialize NumPy warningnumpy absent; .numpy() unavailable
    cuda available: FalseCPU wheel on a machine without a GPU — expected
    disk dropped by 5 GiByou took the dnf route
    need the GPU buildswitch to a CUDA index such as --index-url https://download.pytorch.org/whl/cu126