This will store your application on a Runpod Network Volume and build a light weight Docker image that runs everything from the Network volume without installing the application inside the Docker image.
- Create a RunPod Account.
- Create a RunPod Network Volume.
- Attach the Network Volume to a Secure Cloud GPU pod.
- Select a light-weight template such as RunPod Pytorch.
- Deploy the GPU Cloud pod.
- Once the pod is up, open a Terminal and install the required dependencies:
# Link the cache to /workdpace so the container disk does not run out of space
mv /root/.cache /workspace/.cache
ln -s /workspace/.cache /root/.cache
# Install the models
mkdir -p /workspace/models/ESRGAN
cd /workspace/models/ESRGAN
# Download the official Real-ESRGAN models
wget /~https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth
wget /~https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/RealESRNet_x4plus.pth
wget /~https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth
wget /~https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth
# Download additional models from Huggingface
#wget https://huggingface.co/snappic/upscalers/resolve/main/4x-UltraSharp.pth
#wget https://huggingface.co/snappic/upscalers/resolve/main/lollypop.pth
mkdir -p /workspace/models/GFPGAN
# Download GFPGAN model
cd /workspace/models/GFPGAN
wget /~https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth
# Install the worker application code and dependencies
cd /workspace
git clone /~https://github.com/ashleykleynhans/runpod-worker-real-esrgan.git
cd runpod-worker-real-esrgan
python3 -m venv venv
source venv/bin/activate
pip3 install --no-cache-dir torch==2.0.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip3 install -r requirements.txt
python3 setup.py develop
- Edit the
create_test_json.py
file and ensure that you setSOURCE_IMAGE
to a valid image to upscale (you can upload the image to your pod using runpodctl). - Create the
test_input.json
file by running thecreate_test_json.py
script:
python3 create_test_json.py
- Run an inference on the
test_input.json
input so that the models can be cached on your Network Volume, which will dramatically reduce cold start times for RunPod Serverless:
python3 -u rp_handler.py
- Sign up for a Docker hub account if you don't already have one.
- Build the Docker image and push to Docker hub:
docker build -t dockerhub-username/runpod-worker-real-esrgan:1.0.0 -f Dockerfile.Network_Volume .
docker login
docker push dockerhub-username/runpod-worker-real-esrgan:1.0.0