Install pytorch GPU version in Slicer

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

1 Like

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

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)

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')

1 Like

Additionally there is the SlicerPyTorch extension (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

3 Likes

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

1 Like