How To Install Pytorch 1.0 With Cuda 10.0

Source: Deep Learning on Medium


Ah yes…. it’s that time of the year again.

NeurIPS around the corner, conference deadlines coming up, and Pytorch upgrade time… ‍‍🤦🏻‍

That probably made you anxious, but hey… at least it’s not a Tensorflow upgrade!

Well… turns out instructions for upgrading to Pytorch 1.0 are a new closely held secret. You think this will work?

conda install pytorch torchvision cuda92 -c pytorch

Lol.

I know I’ve already burned up 20 seconds of your 45-second attention span, so without further ado:

Prereqs:

  1. Have a conda environment.
  2. Are working within your conda environment.
  3. Need Pytorch on GPU
  4. Absolutely HAVE to upgrade to 1.0. If you’re submitting to a conference or have a time-sensitive project, I’d skip the upgrade.

Steps:

  1. COPY your current environment in case something goes wrong:
conda create -name new_env clone old_env
activate new_env

2. Uninstall all the old versions of Pytorch [reference]:

conda uninstall pytorch
conda uninstall pytorch-nightly
conda uninstall cuda92 # 91, whatever version you have
# do twice
pip uninstall pytorch
pip uninstall pytorch

3. Install the nightly build and cuda 10.0 from separate channels.

conda install -c pytorch pytorch-nightly
conda install -c fragcolor cuda10.0

That -c means “channel” and it turns out the Pytorch channel has yet to add cuda10.0… so we instead grab it from fragcolor.

4. Test that it works

python
import torch
nums = torch.randn(2,2)
nums.cuda()
# if this works, you're in business

That’s it! Now you’re back to solving AGI!