# Newbie question: What are the prerequisites for running PyTorch with GPU?

**URL:** <https://discuss.pytorch.org/t/newbie-question-what-are-the-prerequisites-for-running-pytorch-with-gpu/698>\
**Category:** Uncategorized\
**Created:** [February 24, 2017, 12:55am UTC](https://discuss.pytorch.org/t/newbie-question-what-are-the-prerequisites-for-running-pytorch-with-gpu/698 "2017-02-24T00:55:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![yenson-lau](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/y/8dc957/32.png) [@yenson-lau](https://discuss.pytorch.org/u/yenson-lau)\
**Post date:** [February 24, 2017, 12:55am UTC](https://discuss.pytorch.org/t/newbie-question-what-are-the-prerequisites-for-running-pytorch-with-gpu/698/1 "2017-02-24T00:55:46Z")

</div>

Hi everyone, I’m new to deep learning libraries, so apologies in advance if this is something I’m already supposed to know.

I’ve used Theano before but guides for setting up the GPU there were very straightforward, also I was doing this using a WinPy instance on Windows. I come from a MATLAB background where I’m used to being able to play around with the variables and initialize things quickly, so naturally I felt like PyTorch may have more to offer.

But there isn’t that much documentation on how to set things up from scratch with PyTorch. I have Anaconda installed on Ubuntu and have tried the basic functionality of PyTorch that way, but I’m not sure how to get it working with CUDA. Any advice would be appreciated!

---

<div class="post-metadata">

**Author:** ![moskomule](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/moskomule/32/4429_2.png) [@moskomule](https://discuss.pytorch.org/u/moskomule)\
**Post date:** [February 24, 2017, 2:06am UTC](https://discuss.pytorch.org/t/newbie-question-what-are-the-prerequisites-for-running-pytorch-with-gpu/698/2 "2017-02-24T02:06:48Z")

</div>

Hi, welcome to PyTorch world.  
~~Tensorflow’s [installation guide](https://www.tensorflow.org/install/install_linux)’s _NVIDIA requirements to run TensorFlow with GPU support_ would be helpful. It tells you how to install CUDA etc.~~ Edited by moderator, pytorch does not need manual CUDA install

Then choose PyTorch with CUDA [here](http://pytorch.org/).

---

<div class="post-metadata">

**Author:** ![smth](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/smth/32/13_2.png) [@smth](https://discuss.pytorch.org/u/smth)\
**Post date:** [February 24, 2017, 3:55pm UTC](https://discuss.pytorch.org/t/newbie-question-what-are-the-prerequisites-for-running-pytorch-with-gpu/698/3 "2017-02-24T15:55:56Z")

</div>

if you want to use pytorch with an NVIDIA GPU, all you need to do is install pytorch binaries and start using it. We ship with everything in-built (pytorch binaries include CUDA, CuDNN, NCCL, MKL, etc.).

So it’s a one-touch install:

- Install pytorch from binaries ( [http://pytorch.org](http://pytorch.org) has instructions)
- Try a simple program with CUDA:

```auto
import torch
a = torch.randn(10).cuda()
print(a)
print(a + 2)

```

---

<div class="post-metadata">

**Author:** ![moskomule](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/moskomule/32/4429_2.png) [@moskomule](https://discuss.pytorch.org/u/moskomule)\
**Post date:** [February 25, 2017, 3:32am UTC](https://discuss.pytorch.org/t/newbie-question-what-are-the-prerequisites-for-running-pytorch-with-gpu/698/4 "2017-02-25T03:32:41Z")

</div>

@smth thank you for your moderation. I used Tensorflow before installing PyTorch, so I misunderstood that they are needed.  
These installations are complicated so PyTorch’s everything-in-build is cool.

---

<div class="post-metadata">

**Author:** ![yenson-lau](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/y/8dc957/32.png) [@yenson-lau](https://discuss.pytorch.org/u/yenson-lau)\
**Post date:** [February 27, 2017, 5:28pm UTC](https://discuss.pytorch.org/t/newbie-question-what-are-the-prerequisites-for-running-pytorch-with-gpu/698/5 "2017-02-27T17:28:23Z")

</div>

@smth Thanks for the reply! Is installing from the binaries the same as following the instructions on the front page? Because I’ve done this but I get a CUDA library error when running

```auto
a = torch.randn(10).cuda()

```

Just to make sure, I updated Pytorch with my Anaconda installation via the following

```auto
conda install pytorch torchvision cuda80 -c soumith

```

Still I get the following error:

 ![](https://discuss.pytorch.org/uploads/default/original/1X/09d725723cc61941a2922b8626040af3cd6d3d27.png)

_Thanks again for the support!_

---

<div class="post-metadata">

**Author:** ![yenson-lau](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/y/8dc957/32.png) [@yenson-lau](https://discuss.pytorch.org/u/yenson-lau)\
**Post date:** [February 28, 2017, 10:41pm UTC](https://discuss.pytorch.org/t/newbie-question-what-are-the-prerequisites-for-running-pytorch-with-gpu/698/6 "2017-02-28T22:41:54Z")

</div>

Just wanted to report that I’ve installed CUDA 8.0 from the NVIDIA website and now `.cuda()` works. Thanks a lot for the help!

---

<div class="post-metadata">

**Author:** ![Sriharsha\_Sammeta](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/sriharsha_sammeta/32/1959_2.png) [@Sriharsha\_Sammeta](https://discuss.pytorch.org/u/Sriharsha_Sammeta)\
**Post date:** [October 11, 2017, 8:57pm UTC](https://discuss.pytorch.org/t/newbie-question-what-are-the-prerequisites-for-running-pytorch-with-gpu/698/7 "2017-10-11T20:57:02Z")

</div>

Yup. You have to first do the CUDA binaries installation.

For UBUNTU:  
[https://developer.nvidia.com/cuda-downloads?target\_os=Linux&target\_arch=x86\_64&target\_distro=Ubuntu&target\_version=1604&target\_type=debnetwork](https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=debnetwork)

After that go to:  
[http://pytorch.org](http://pytorch.org)  
and install required packages. it will work like charm.

Also, you can do the simple test as described by Soumith.  
import torch  
torch.cuda.is\_available()

if the above lines return True then you have Cuda working else not.

---

<div class="post-metadata">

**Author:** ![Dhruvrnaik](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dhruvrnaik/32/2586_2.png) [@Dhruvrnaik](https://discuss.pytorch.org/u/Dhruvrnaik)\
**Post date:** [December 5, 2017, 2:42pm UTC](https://discuss.pytorch.org/t/newbie-question-what-are-the-prerequisites-for-running-pytorch-with-gpu/698/8 "2017-12-05T14:42:51Z")

</div>

Hi, this could be a very naive question because I am new to this.  
So if I install PyTorch first, I wouldn’t have to manually install the NVIDIA software for TensorFlow later. Correct?
