Re:_The_installation_of_“Stable_Diffusion_web_UI ”_natively_on_FreeBSD_fails_because_can’t_install_torch_ and_torchvision

From: Tomek CEDRO <tomek_at_cedro.info>
Date: Sat, 19 Nov 2022 16:32:54 UTC
On Sat, Nov 19, 2022 at 4:18 PM Mario Marietto wrote:
> Hello to everyone.
> I’m trying to clone and install the “Stable Diffusion web UI” on FreeBSD,following this mini tutorial :
> [marietto@marietto ~/Desktop/Files]$ git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
> [marietto@marietto ~/Desktop/Files]$ cd stable-diffusion-webui
> [marietto@marietto ~/Desktop/Files/stable-diffusion-webui]$ sudo pkg install py39-pytorchvideo

For me that would install version 0.1.5 of the package:

octagon% pkg search py39-pytorch
py39-pytorchvideo-0.1.5        Video understanding deep learning library


> [marietto@marietto ~/Desktop/Files/stable-diffusion-webui]$ mkdir venv
> [marietto@marietto ~/Desktop/Files/stable-diffusion-webui]$ python3 -m venv venv
> [marietto@marietto ~/Desktop/Files/stable-diffusion-webui]$ . venv/bin/activate

You dont have to create  a directory, it will be created by venv :-)

Also proper execution of venv would be:
./venv/bin/activate

Then you should see a shell prompt prefix `(venv) $` and you can make
sure if you are in the venv by running `which python3` if that shows
your venv then all if fine.


> (venv) [marietto@marietto ~/Desktop/Files/stable-diffusion-webui]$ python3 -m pip install torch torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
>
> Looking in indexes: https://pypi.org/simple,https:/download.pytorch.org/whl/cu113
>
> ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
>
> ERROR: No matching distribution found for torch

In my case:

(venv3.9embedded) pip install torch==
ERROR: Could not find a version that satisfies the requirement torch==
(from versions: none)
ERROR: No matching distribution found for torch==

(venv3.9embedded) pip install torchvision==
ERROR: Could not find a version that satisfies the requirement
torchvision== (from versions: 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.2.0,
0.2.1, 0.2.2, 0.2.2.post2, 0.2.2.post3)
ERROR: No matching distribution found for torchvision==

Using `==` as the package suffix to the package name will list all
available versions.

It seems that package for torch is not avilable for pip, while there
are torchvision packages available in versions: 0.1.6, 0.1.7, 0.1.8,
0.1.9, 0.2.0, 0.2.1, 0.2.2, 0.2.2.post2, 0.2.2.post3 (not the
0.13.1+cu113 that you need).

Because both torch and torchvision are not available for download (and
in version that you need) I would clone the source code repo and build
it + install from that repo (being inside venv of course).

Please note that most folks unfortunately does not provide precompiled
binary modules for FreeBSD, so you will have to build them from the
sources (it will be done by pip when no binary package is available).
Also some packages may not build correctly out of the box on FreeBSD
and you will have to clone that specific repo, find a fix, then
provide a fix to the upstream.

This also may be a good time to mention public pip availability of the
packages to the upstream :-)

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info