PyTorch and CUDA 9.1

I noticed that PyTorch couldn’t find the CUDA installation after upgrading to CUDA 9.1 and checking via torch.cuda.is_available(). However, when I downgraded to CUDA 9.0 it worked all fine though. For the pip installer, on the PyTorch page, I noticed that it says “cu90”:

pip3 install http://download.pytorch.org/whl/cu90/torch-0.3.0.post4-cp36-cp36m-linux_x86_64.whl 

I am just wondering if this really is just a “path” issue regarding CUDA 9.1 or if this intended by design (e.g., breaking changes). Not that I need CUDA 9.1, I am just wondering if this is done on purpose, i.e., that the installer only specifically supports CUDA 9.0 and not the consequent patch version (assuming NVIDIA uses semantic versioning)

2 Likes

Hi

As of today (2nd of February 2018) all seems to work fine after

conda install pytorch torchvision cuda90 -c pytorch

using:

conda 4.4.8

and cuda version:

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation 
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85

Ubuntu:

Ubuntu 16.04.3

Python

Python 3.6.4

And I get

In [1]: import torch

In [2]: torch.cuda.is_available()
Out[2]: True

In [3]: torch.cuda.get_device_name(0)
Out[3]: 'Tesla K80'```
1 Like

Thanks for the answer! I had a little misconception when I asked this question. I didn’t know that PyTorch (the binary installers via conda and pip wheels) already ship the necessary CUDA and cuDNN parts.

For some reason, PyTorch did not detect cuda via “torch.cuda.is_available” first. When I tried with a fresh OS install (via Amazon AWS EC2), I noticed that even though I had the correct NVIDIA drivers for the given graphics card installed, it wouldn’t work. What fixed the problem was downloading CUDA 9.0 and running the installer without installing CUDA itself (during the installation, it asks you to install the NVIDIA display driver, which I answered with “yes” and the CUDA 9.0 toolkit, which I answered with “no”). After installing the graphics card drivers through the CUDA installer, it all worked fine (even without CUDA installed as PyTorch already comes with it).

I have been using pytorch 0.3 with CUDA 9.1 for a few weeks now on ubuntu 16.04 and non-anaconda - just using the tensorflow-gpu-py3 docker image with nvidia-docker and it works fine.

Also this is a non-anaconda install - just used pip and the cu90 installer.

Hm, are you installing it via pip wheels or source code? Because as far as I understood, PyTorch would be using it’s own CUDA parts when you do the regular pip install (i.e., wheels; pip3 install http://download.pytorch.org/whl/cu90/torch-0.3.0.post4-cp36-cp36m-linux_x86_64.whl ). So, my understanding is that even if you have locally CUDA 9.1 installed, it would be using the CUDA 9.0 parts that it comes with. Based on

conda binary has its own cuda, it doesn’t use system CUDA at all.

(There’s probably no way to tell which CUDA version PyTorch is using via the Python interpreter?)

@rasbt

(There’s probably no way to tell which CUDA version PyTorch is using via the Python interpreter?)

import torch
print(torch.version.cuda)
1 Like

Wonderful, thanks!

@voxmenthe

Maybe it would be worthwhile trying that on your system. I am curious whether it shows ‘9.0.176’ or a 9.1 version after the pip cu90 install

Yeah I get 9.0.176 inside of my docker container (which is where pytorch is installed)

Hi @jrzaurin
I am doing a new installation and I have the same Cuda version that you showed above;
Cuda compilation tools, release 9.1, V9.1.85, same Ubuntu and Python.
However, I am thinking to pick Cuda 9.2 from the PyTorch installation options, something like:

conda install pytorch torchvision cuda92 -c pytorch

Not sure if I will have any problems, so, just wanted to ask before giving it a go.

Hey there,

For me it worked with Cuda 9.0 so:

conda install pytorch torchvision -c pytorch

Have not tried with 9.2

It says CUDA 8.0, but my system does not have CUDA 8.0 at all (I have cuda 9.0 and cuda 9.1)?
And I checked the source file, /usr/local/lib/python3.5/dist-packages/torch/version.py, it has a line cuda = ‘8.0.61’.

@laoreja the CUDA is inbuilt in the PyTorch package

1 Like

Thank you! How about the cudnn? is it also inbuilt in the PyTorch package?

And I’m not using conda, just through pip install, in this way, is the CUDA also inbuilt?

Yes. There is a specific CPU version you can install though.

I think the only way to bring your own, you could compile and install it from source:

What version of torch works with cuda 9.1?

Hi, I also wonder that, because I noticed there is no pytorch version suit with Cuda 9.1 in there downlod website, only with 9.0 and 9.2