# Install pytorch GPU version in Slicer

**URL:** <https://discourse.slicer.org/t/install-pytorch-gpu-version-in-slicer/25548>\
**Category:** Support\
**Tags:** python, pytorch\
**Created:** [October 4, 2022, 7:43pm UTC](https://discourse.slicer.org/t/install-pytorch-gpu-version-in-slicer/25548 "2022-10-04T19:43:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![l2022](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/l2022/32/11116_2.png) [@l2022](https://discourse.slicer.org/u/l2022)\
**Post date:** [October 4, 2022, 7:43pm UTC](https://discourse.slicer.org/t/install-pytorch-gpu-version-in-slicer/25548/1 "2022-10-04T19:43:25Z")

</div>

Hi,  
I am trying to install pytorch GPU version in Slicer but I can only install the CPU version. I can successfully install pytorch GPU in a external python but running the same pip commands in the Slicer’s python I only get the CPU one.  
Do you know how to solve it?

Thank you

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 4, 2022, 8:18pm UTC](https://discourse.slicer.org/t/install-pytorch-gpu-version-in-slicer/25548/2 "2022-10-04T20:18:18Z")

</div>

remove all packages you installed, and follow the instructions in here. [https://pytorch.org/](https://pytorch.org/)  
Choosing correct versions of OS, package manager and cuda versions installed on your system.

> **[PyTorch](https://pytorch.org/)**
>
> An open source machine learning framework that accelerates the path from research prototyping to production deployment.

then instead of installing with pip (if you are on Linux), just download the appropriate wheels for your system. (i.e., ignore the first part, and follow the second part that goes [https://download.pytorch.org/whl/cu116](https://download.pytorch.org/whl/cu116))

for example if you are on linux and you have cuda 11.6 installed this would be the one of the appropriate package (since Slicer uses python 3.9) if your goal is to use torch 1.12

`https://download.pytorch.org/whl/cu116/torch-1.12.0%2Bcu116-cp39-cp39-linux_x86_64.whl`

once those are downloaded, open Slicer go to python interactor and install via  
`pip_install('path-to-your-downloaded-wheels')`

---

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [October 5, 2022, 12:55am UTC](https://discourse.slicer.org/t/install-pytorch-gpu-version-in-slicer/25548/3 "2022-10-05T00:55:20Z")

</div>

Additionally there is the [SlicerPyTorch extension](https://github.com/fepegar/SlicerPyTorch) (should be in the extension manager). It uses light-the-torch under the hood, so you could also just go ahead use light-the-torch yourself to help fetch and install the correct wheel for your hardware

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 5, 2022, 1:46am UTC](https://discourse.slicer.org/t/install-pytorch-gpu-version-in-slicer/25548/4 "2022-10-05T01:46:47Z")

</div>

I wasn’t aware of this. This look really cool. will give it a try.
