#A Way to connect to Remote GPU via SSH Tunnelling?

156 messages · Page 1 of 1 (latest)

sly fulcrum
#

Hey there,
I don't have an Nvidia driver and I'd like to use this. Can I rent a GPU and use Putty to Tunnel to a certain port like 9090 and use InvokeAI there?

tiny agate
#

i'm doing this with runpod.io, happy to share my invokeai template + docker image but you'll need to know your way around the linux terminal to make it work

sly fulcrum
#

My!!!! I wasn't hopeful at all!

#

How!

#

[Throw fishnets over the guy, interrogate him!]

#

@tiny agate

#

I know putty, ssh tunnelling

#

I can access to linux terminal to install and run things

tiny agate
#

it puts an invokeai install in /stable-diffusion

#

to run it you need to start the box, login, conda activate invokeai, download a .ckpt and put it somewhere, edit /stable-diffusion/config/models.yaml to point to it and run python scripts/invoke.py --web --port 9090 --host 0.0.0.0 --cors <external url without trailing />

#

the image is 6gb because it contains pre-populated models cache (just without the SD ckpt itself)

#

idk how vast.ai works but you'll need to open port 9090 or use another one

#

note this is not an "official" image, it's just one i use for development

sly fulcrum
#

Erm

#

Am I doing to docker pull this on my own PC, or on runpod 😄

#

@tiny agate

tiny agate
#

runpod

#

or vast i guess

#

i can't support this much beyond getting it running i'm afraid

sly fulcrum
#

Thank you very much. I'll try figuring things out

#

now that I know it's possible @tiny agate

mental holly
#

Yes I do this routinely. Launch the web server on the remote machine and then do an ssh forward from port 9090 on your local machine to the remote machine’s localhost:9090

sly fulcrum
#

Hello, how're you doing?

#

Thank you for this code

#

Ok so, let me document

#

I'll go ahead and create a tunnel on putty

#

Add public and private credentials to the server and putty.

#

add login details

#

Then go ahead and install Invoke AI onto the machine I rented

#

When things are ready, I'll open localhost:9090 on my local PC and see Invoke AI running there, right?

#

@mental holly

tiny agate
#

that looks good, just make sure you pass --host 0.0.0.0 and also append the url you're going to use on your local machine to the --cors argument

sly fulcrum
#

@tiny agate Thank you very much.

tiny agate
#

np and good luck

mental holly
#

Actually this isn’t necessary. Just launch invoke with —web and connect from the desktop with ssh -L9090:localhost:9090 gpu.host.com replacing the last bit with the DNS of the gpu host.

#

The putty config looks correct. cors and host args shouldn’t be necessary but won’t hurt.

sly fulcrum
#

There was an Automatic1111 template in the Runpod...
I think I'm going to have to go with that, else I'll be angry at random people for nothing this week. I'm just frustrated with the installation process.

#

I coulnd't git pull or git clone your repo on Runpod due to some GIT_DISCOVERY_ACROSS_FILESYSTEM not set error

#

...also... Jupyter installation guide doesn't work either...

#

i can't install it with the terminal

#

There's no docker file that has the model in it...

#

I hope automatic1111 works

#

before I go to sleep

mental holly
#

So sorry you’re having difficulty. The Jupyter notebook does work but the docs are AWOL as you’ve found out.

sly fulcrum
#

Oh no please don't feel sorry for me. That's enough sadness for the world of diffusions for today. @mental holly you can instead put nice little video on youtube youtube channel, which I'm subscribed btw, about how to do this thing with remote GPUs.
Cause I didn't like automatic1111, I can't do automation with this stuff. I have more than 20_000 prompts to render...

#

and it seems I can only do it with invokeai

#

(prompts are for educational stuff)

tiny agate
#

with my docker image you can run scripts/load_models to download one of the sd1.5 checkpoints, it takes about 2 minutes

#

or put one on mega.nz and download it with mega-cmd

#

the reason we don’t and likely won’t ship ckpt files is because you are supposed to agree to a license to use them, and unlike some other stable diffusion distributions we want to actually respect licensing agreements

sly fulcrum
#

I totaly understand and respect that

#

Now let me start over with Runpod

#

I'll select Basic Terminal Access

tiny agate
#

no don’t do that

sly fulcrum
#

😄

tiny agate
#

make a custom template hold on i’ll send you a screenshot

sly fulcrum
#

this

tiny agate
#

set a ssh-ed25519 key

#

needs to be ed25519

sly fulcrum
#

do you give it a docker command?

#

like docker run -e HUGGING_FACE=apikey?

#

or environment variables?

tiny agate
#

no

sly fulcrum
#
2022-11-20T20:34:21Z error pulling image: Error response from daemon: Head "https://ghcr.io/v2/damian0815/invoke-ai-runpod/manifests/latest": denied: denied
2022-11-20T20:34:21Z error creating container: Error response from daemon: No such image: ghcr.io/damian0815/invoke-ai-runpod:latest
2022-11-20T20:34:37Z remove network
2022-11-20T20:35:26Z create pod network
2022-11-20T20:35:26Z create container https://github.com/damian0815/runpod-decent-pytorch/pkgs/container/invoke-ai-runpod
2022-11-20T20:35:26Z error pulling image: invalid reference format
2022-11-20T20:35:26Z error creating container: Error response from daemon: invalid reference format
2022-11-20T20:35:50Z create container https://github.com/damian0815/runpod-decent-pytorch/pkgs/container/invoke-ai-runpod
2022-11-20T20:35:50Z error pulling image: invalid reference format```
tiny agate
#

where is that log coming from?

sly fulcrum
tiny agate
#

weird

sly fulcrum
#

My template is like yours

#

Ok it's pulling now

tiny agate
#

you certainly don’t need 30gb on the container disk

#

i run with 5

sly fulcrum
#

It was saying 18 GB for installation on the docs

#

hmmm I'll reduce one this thing runs

tiny agate
#

the docker image is free gb

sly fulcrum
#

it's on spot instances anyways

tiny agate
#

5gb container, for volume you need basically the size of ckpt you want + the size of images you want to make

sly fulcrum
#

that's almost half way done

#

ok now i'm connected

#

How did you manage to put your model into stable-diffusion/models folder after downloading it?

#

through ssh?

mental holly
#

I download directly onto the remote machine, but if you need to transfer it look for the SFTP or SCP functions in putty.

sly fulcrum
#

hahhaha

#

there's no curl for it

#

😄

tiny agate
#

put it in /workspace so it persists

#

use the load-models script

#

scripts/load_models.py

sly fulcrum
#

A problem occurred during download.
The error was: "Run this script from within the top level of the InvokeAI source code directory, "InvokeAI""

#

I feel like a monkey

mental holly
#

Move up one directory level and run python scripts/load_models.py

#

We all feel like monkeys sometimes. Right now I’m craving a banana.

sly fulcrum
#

I'm so close

#

I'm so close 🍌

#

it's happening

#

now the final command

#
python scripts/invoke.py --web --port 9090 --host 0.0.0.0
#

I don't know how to manage the cors

#

inpainting wasn't signed

#

ok

tiny agate
#

i should write this up as a tutorial i guess

sly fulcrum
#

I think I'm going to create a youtube video for this one

tiny agate
#

hahaha

sly fulcrum
#

This didn't work either

#

I tried with https

#

http

#

http:/ with one /

tiny agate
#

did you do git pull?

#

delete the trailing slash, not the one at http://

sly fulcrum
#

no I didn't git pull

tiny agate
#

you need to do that to fix the INITFILE error

#

that docker image is synced to my github development branch

sly fulcrum
#

I thought everything I needed was in the dockerfile

tiny agate
#

it is but the code is a moving target

#

i’m not rebuilding a 6gb image every time i commit

sly fulcrum
#

believe me I don't even know how to use github

#

I guess I'll

git pull ghcr.io/damian0815/invoke-ai-runpod:latest

workspace/stable-diffusion

#

I have absolutely no clue what to do next.

#

what am I pulling?

#
(invokeai) root@7697e9b9e2cd:/stable-diffusion# git pull
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (25/25), done.
remote: Total 32 (delta 25), reused 25 (delta 25), pack-reused 7
Unpacking objects: 100% (32/32), 11.00 KiB | 866.00 KiB/s, done.
From https://github.com/damian0815/InvokeAI
 * [new branch]      play-kaleidoscope -> origin/play-kaleidoscope
Already up to date.
#

but unfortunately

(invokeai) root@7697e9b9e2cd:/stable-diffusion# python scripts/invoke.py --web --port 9090 --host 0.0.0.0 --cors https://xxxxxxxxxxxxxxxxx-9090.proxy.runpod.net
* Initializing, be patient...
An exception has occurred: name 'INITFILE' is not defined
tiny agate
#

ahh then maybe i didn’t update it

#

sec

#

ok now just type git pull

#

and try again

#

@sly fulcrum

sly fulcrum
#

I closed the instance for today... Damian

#

I thank you for your patience

#

You truly are a hero

#

I'll try it first thing tomorrow. Now I gotta sleep

sly fulcrum
#

wow ok

#

It works after git pull

#
>> Initialization file /root/.invokeai not found. Creating a new one...
>> InvokeAI runtime directory is "."
Downloading: "https://github.com/DagnyT/hardnet/raw/master/pretrained/train_liberty_with_aug/checkpoint_liberty_with_aug.pth" to /root/.cache/torch/hub/checkpoints/checkpoint_liberty_with_aug.pth
100%|██████████████████████████████████████| 5.10M/5.10M [00:00<00:00, 66.4MB/s]
>> GFPGAN Initialized
>> CodeFormer Initialized
>> ESRGAN Initialized
>> Using device_type cuda
>> Current VRAM usage:  0.00G
>> Scanning Model: stable-diffusion-1.5
>> Model Scanned. OK!!
>> Loading stable-diffusion-1.5 from models/ldm/stable-diffusion-v1/v1-5-pruned-emaonly.ckpt
>> Calculating sha256 hash of weights file
>> sha256 = cc6cb27103417325ff94f52b7a5d2dde45a7515b25c255d8e396c90014281516 (2.59s)
   | LatentDiffusion: Running in eps-prediction mode
   | DiffusionWrapper has 859.52 M params.
   | Making attention of type 'vanilla' with 512 in_channels
   | Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
   | Making attention of type 'vanilla' with 512 in_channels
   | Using faster float16 precision
   | Loading VAE weights from: models/ldm/stable-diffusion-v1/vae-ft-mse-840000-ema-pruned.ckpt
>> Model loaded in 17.30s
>> Max VRAM used to load the model: 2.17G
>> Current VRAM usage:2.17G
>> Setting Sampler to k_lms

* --web was specified, starting web server...
>> Initialization file /root/.invokeai found. Loading...
DEBUG: static_folder should be at ../frontend/dist
>> Started Invoke AI Web Server!
Point your browser at http://localhost:9090 or use the host's DNS name or IP address.
>> System config requested

#

Ta da!

#

So happy!

#

This was me yesterday

tiny agate
#

a pro tip for using runpod is to symlink the models folder to /workspace so that you don't have to re-download the .ckpt files every time you stop the instance or are kicked off it (if you're using spot pricing)

#

coming in v2.1.4 is in fact a way to tell load_models to do that for you