Unable to install PyTorch in Raspberry pi 4

December 5, 2023, 17:15

athinaxenou

Hello, I am doing an image processing project using raspberry pi 4. I've saved the weights of the model in a pth file and passed it onto a raspberry pi with a usb stick. In order to load the model in raspberry pi so that I can use the camera I need to import PyTorch to load the model weights. The current version of python I'm using is 3.11 and every time I try to install torch it says "package python3-torch has no installation candidate". Any help on this would be appreciated!

k9t33n

why can't you just use pip?

k9t33n

pip install python3-torch

k9t33n

maybe add a sudo at the beginning if you need it

oops.se

Use the website https://pypi.org/ and search for the package, if it isnt in the search result you can't install it as there is no such library!

k9t33n

pytorch is a Library

k9t33n

I use it all the time for ML

k9t33n

you may need to use some variation of python3-torch for it to work but it's definitely useable

athinaxenou

Yeah it's definitely a library

athinaxenou


athinaxenou

We've been downloading other libraries through Sudo apt (get) install python3-library It seems like it's not working for torch

k9t33n

try pip install

athinaxenou

It's the first arrow

oops.se

If you get the message "package python3-torch has no installation candidate" then the package name is either misspelled or not existent

k9t33n

you either need to use a venv or add --break-system-packges or something similar to the end

chopps568

use it in a python venv to avoid breaking system files. Basically not installing it globally

chopps568

lemme get you a link

chopps568

also going to find out if the pytorch libary can run a pi

chopps568

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

chopps568

try that

chopps568

if not try this

chopps568

python -m venv nameofvenv

chopps568

source nameofvenv/bin/activate

chopps568

first one creates it second one activates it

chopps568

gl

athinaxenou

Thanks for all the suggestions! I did try to use venv and even if I did pip install in those I was still getting an error. The default python is python3.11.8 so I might download python3.9.18 and see if that works

chopps568

i couldnt find any info on the arm chip being able to run pytorch

chopps568

ill look harder

chopps568

so it can

athinaxenou

Thank you!! <@120274865973493761>

athinaxenou

Resolved: You can't work with PyTorch on Raspberry pi 4 if you install the 32-bit OS. You need to have the 64-bit

null

Thanks for sharing this Info 👍🏻