Back to Article List

How to install PyTorch in a Miniconda environment

How to install PyTorch in a Miniconda environment - How to install PyTorch in a Miniconda environment

I keep meeting the same broken command in tutorials, lecture notes and old Stack Overflow answers: conda install pytorch -c pytorch. For years that was the official way, so half the internet still teaches it, and today it either hangs you on a solver going nowhere or hands you a stale build. Here's the currently supported way to get PyTorch into a Miniconda environment, CPU or CUDA.

The pytorch conda channel is deprecated

The PyTorch team announced the end of official Anaconda channel builds in pytorch/pytorch issue #138506, and the conda instructions were later stripped from the install docs entirely (that part is tracked in issue #149551). The get-started page now lists pip as the only supported package manager. What makes this a trap is that the old channel still exists: nothing errors out loudly, you just receive whatever was last published there, frozen while PyTorch moves on.

None of this ends Miniconda's role in a PyTorch setup, to be clear. You still use conda for what it's good at, an isolated environment with a pinned interpreter, and pip handles the PyTorch part inside that environment. pip inside a conda env installs into that env only, so the combination is stable as long as the env exists before the pip step.

Check your GPU with nvidia-smi

Before installing anything, establish what you're installing for:

nvidia-smi

On a machine with a working NVIDIA driver this prints the GPU model, the driver version and, in the top right corner, a CUDA version. That number is the newest CUDA your driver supports, and it's what you'll match a wheel against shortly. A missing or failing nvidia-smi means no usable NVIDIA GPU on this machine, so the CPU build is your install; fine for learning the API, slow for training.

Race towards the future

Unrivaled speed meets competitive pricing

Ready in seconds 7-day money-back guaranteeA risk-free way to try LumaDock. Covers the GPU VPS plan on your first order. Cancel anytime
Billing Cycle

GPU.T4

$149.00 Save  13 %
$129.00 Monthly
  • Dedicated GPU
  • Tesla T4

  • 16 GB GDDR6vRAM
  • 2560CUDA CORES
  • Virtual Server
  • 8 vCPUAMD EPYC
  • 32 GBECC MEMORY
  • 250 GB NVMeSTORAGE
  • Unmetered bandwidth
  • IPv4 & IPv6IPv6 is currently unavailable in France, Finland or the Netherlands. included

GPU.ADA4000SFF

$249.00 Save  20 %
$199.00 Monthly
  • Dedicated GPU
  • RTX 4000 SFF Ada

  • 20 GB GDDR6 ECCvRAM
  • 6144CUDA CORES
  • Virtual Server
  • 16 vCPUAMD EPYC
  • 64 GBECC MEMORY
  • 350 GB NVMeSTORAGE
  • Unmetered bandwidth
  • IPv4 & IPv6IPv6 is currently unavailable in France, Finland or the Netherlands. included

GPU.PRO4000SFF

$299.00 Save  20 %
$239.00 Monthly
  • Dedicated GPU
  • RTX PRO 4000 Blackwell

  • 24 GB GDDR7 ECCvRAM
  • 8960CUDA CORES
  • Virtual Server
  • 16 vCPUAMD EPYC
  • 64 GBECC MEMORY
  • 400 GB NVMeSTORAGE
  • Unmetered bandwidth
  • IPv4 & IPv6IPv6 is currently unavailable in France, Finland or the Netherlands. included

GPU.PRO4500

$499.00 Save  20 %
$399.00 Monthly
  • Dedicated GPU
  • RTX PRO 4500 Blackwell

  • 32 GB GDDR7 ECCvRAM
  • 10496CUDA CORES
  • Virtual Server
  • 16 vCPUAMD EPYC
  • 64 GBECC MEMORY
  • 450 GB NVMeSTORAGE
  • Unmetered bandwidth
  • IPv4 & IPv6IPv6 is currently unavailable in France, Finland or the Netherlands. included

GPU.PRO5000

$699.00 Save  20 %
$559.00 Monthly
  • Dedicated GPU
  • RTX PRO 5000 Blackwell

  • 48 GB GDDR7 ECCvRAM
  • 14080CUDA CORES
  • Virtual Server
  • 32 vCPUAMD EPYC
  • 96 GBECC MEMORY
  • 500 GB NVMeSTORAGE
  • Unmetered bandwidth
  • IPv4 & IPv6IPv6 is currently unavailable in France, Finland or the Netherlands. included

GPU.PRO6000

$1,199.00 Save  19 %
$969.00 Monthly
  • Dedicated GPU
  • RTX PRO 6000 Blackwell

  • 96 GB GDDR7 ECCvRAM
  • 24064CUDA CORES
  • Virtual Server
  • 32 vCPUAMD EPYC
  • 128 GBECC MEMORY
  • 650 GB NVMeSTORAGE
  • Unmetered bandwidth
  • IPv4 & IPv6IPv6 is currently unavailable in France, Finland or the Netherlands. included

*VAT excluded.

INCLUDED WITH EVERY PLAN

✓ No setup fees ✓1 Gbps network
✓ Free server monitoring ✓ Firewall management ✓24/7 support ✓ KVM virtualization

Create a Python 3.12 environment for PyTorch

Current stable PyTorch wants Python 3.10 or newer; 3.12 sits comfortably inside the supported range. Create and activate a dedicated env:

conda create -n torch python=3.12 -y
conda activate torch

PyTorch deserves its own environment even when you suspect you won't need one, because CUDA wheels are enormous, the dependency tree is opinionated and someday you'll want to delete the whole thing cleanly. If envs are new territory, the guide on how to create and manage Miniconda environments covers the workflow, and a bare server needs the install Miniconda on Ubuntu steps before any of this.

Install PyTorch with pip inside the conda env

With the env active, the CPU build is one line:

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu

A CUDA build swaps the index URL. The pattern is cu plus the CUDA version without its dot, so CUDA 12.6 becomes:

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126

Pick the newest cu1xx index that doesn't exceed what nvidia-smi reported. Drivers are backward compatible, meaning a driver showing CUDA 12.8 runs cu126 wheels happily while the reverse pairing dies at runtime. You don't need the CUDA toolkit installed on the system for any of this, since the wheels bundle the runtime libraries they use; the driver is the only system-level requirement. Two smaller notes. The PyTorch get started selector generates the exact line for your OS and compute platform, and I'd trust it over any copy-pasted command in a tutorial, including this one, because the available CUDA indexes shift with each release. And torchaudio can be dropped when you know audio isn't coming; most people cargo-cult it along.

Verify the install and the GPU

python -c "import torch; print(torch.cuda.is_available())"
python -c "import torch; print(torch.cuda.get_device_name(0))"

On a CUDA install the first prints True and the second names your card. On a CPU install, False from the first is correct behavior, not a failure. The case worth investigating is False on a machine that has a GPU, and there the usual culprit is the CPU wheel having snuck in, since a plain pip install torch with no index URL pulls CPU-only on Linux. Check that before blaming the driver.

The conda-forge pytorch package as an alternative

For a conda-native install, conda-forge maintains community builds:

conda install -c conda-forge pytorch

They're solid builds, and the right answer when the rest of your stack already comes from conda-forge and one solver should manage everything. Otherwise I'd stay on pip: it's the route the PyTorch team supports and documents, releases land there first and you pick the CUDA variant explicitly instead of leaving it to solver negotiation. Where conda-forge sits in the larger channel picture belongs to the Miniconda vs Miniforge comparison.

Export the environment for reproducibility

Once the install works, capture it:

conda env export > environment.yml

The export includes a pip: section listing torch and friends, so this one file rebuilds the whole env elsewhere. One caveat specific to PyTorch envs: the --from-history export variant ignores pip-installed packages entirely, so here the full export is the one that works. I also keep the exact install line, index URL included, in the project README, since the yml records which torch you got but not which index it came from, and on a new machine with a different GPU that index is the first thing to change.

Questions?

Can I keep CPU and CUDA builds of PyTorch on the same machine?

Yes, in separate conda environments, something like torch-cpu for quick local iteration and torch-cu126 for real runs, with activation switching between them in a second. Inside one env they can't coexist, since both ship as the torch package and the second install replaces the first.

About the author

Matteo De Luca

I am from Turin. I studied electronic engineering there and discovered, somewhere during the second year, that I enjoyed explaining our laboratory work more than I enjoyed the laboratory work itself. I wrote for small Italian technology sites during university, then took freelance assignments on consumer hardware and later Linux and server software. The second change was better for me. I like subjects where there is something concrete to understand before the writing begins.

I live with my girlfriend and a very old Syberian cat. I go bouldering two evenings a week and draw when I remember to. I also have a small collection of film cameras inherited from my grandfather. Photography is one of the few hobbies where I am quite happy not to become more efficient. I don't want every interest I have to become work.

Your models deserve a GPU of their own

Run them on a full card from our RTX PRO Blackwell lineup, with dedicated VRAM and a price that stays the same however hard the GPU works. Your first GPU order comes with a 7-day money-back guarantee.