Run huggingface spaces on RunPod!

Run huggingface spaces on RunPod!
huggingface spaces now on runpod!

You can run any Huggingface space on Runpod!

As every Huggingface space has options to run it with docker now

run with docker option on huggingface, its on the upper right corner menu that reveals additional options
run with docker screen

this gives the option of running the space locally, which we can use to run the image with runpod

here,

  1. 7860 is the port being forwarded here in the example above, this will be your port value
  2. HUGGING_FACE_HUB_TOKEN, is your huggingface token, you can generate one by logging in to your huggingface account and going here
  3. in the example above, our container image will be at "registry.hf.space/multimodalart-stable-diffusion-inpainting:latest" (as you can from the image),

now, go to, My templates on runpod

my templates, its on the left of runpod.io, once you login

and go ahead and create a new template, by clicking new template

  1. set the "container image", as the container image specified in the docker container, in our case this is registry.hf.space/multimodalart-stable-diffusion-inpainting:latest, which we got from point 3 above
  2. set the "Expose HTTP Ports" to 7860, since that's the port being exposed, which we got from point 1 above
  3. open "Environment variables" in the bottom of the template, and set it to
    - key : HUGGING_FACE_HUB_TOKEN
    - value : (your huggingface hub token, you got from point 2 above)
  4. set the docker command as "bash -c 'python app.py'"
template example

here's a template example, if you're not sure about the container disk, try it with a few configurations until it works, we can set the volume disk to zero, since we're not going to be permanently storing anything

environment variables (after the template), where HUGGING_FACE_HUB_TOKEN is set

and the environment variables at the bottom

now go ahead and deploy the on the server you wish to

I'm using an A100 in my example

I'm using an A100 for my example, because it has a high amount of vram, but you can trial and error this to see what works best for you, go ahead and click deploy then,

ensure you select the template you're using, as you can see I've selected the templat which I'm using from above, complete all the deployment steps

now go to your screen and click on "logs" don't click on connect yet!

wait for the model to be downloaded

wait for the model to download all the files

and wait till you see a url saying "Running on local URL:  http://0.0.0.0:7860", or a similar one

now go back to the pod screen, and click connect

click connect on the pod screen

and connect to the url that opens up

connect to the port, in our case by clicking on "connect via HTTP[Port 7860]"

and ta-da!, you should see gradio now!