ashleykleynhans / runpod-worker-comfyui

RunPod Serverless Worker for the ComfyUI Stable Diffusion API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cannot using venv stored in network volume for comfyui

Weixuanf opened this issue · comments

so in my network volume, i have a workspace/comfyui/venv

so my start.sh looks like: a slight modified version of your original file. only difference is my venv folder is in workspace/comfyui/venv whereas yours is in workspace/venv not sure if this will make a difference.

#!/usr/bin/env bash

echo "Symlinking files from Network Volume"
rm -rf /workspace && \
  ln -s /runpod-volume /workspace

comfyui_path="/workspace/comfyui_0.1"
comfy_log_path="/comfyui.log"

echo "Starting ComfyUI API"
source "${comfyui_path}/venv/bin/activate"
TCMALLOC="$(ldconfig -p | grep -Po "libtcmalloc.so.\d" | head -n 1)"
export LD_PRELOAD="${TCMALLOC}"
export PYTHONUNBUFFERED=true
cd $comfyui_path
python3 main.py --port 8080 >> "${comfy_log_path}" 2>&1 &
deactivate


echo "Starting RunPod Handler"
# Serve the API and don't shutdown the container
if [ "$SERVE_API_LOCALLY" == "true" ]; then
    python3 -u /rp_handler.py --rp_serve_api
else
    python3 -u /rp_handler.py
fi

touch "$comfy_log_path"

but it seems it cannot use the comfyui/venv and still uses the python system env backed into the docker image i deployed in runpod. because I'm getting module not found error while if I run it in a real pod, the source "${comfyui_path}/venv/bin/activate" and python main.py works no problem. So I think the it is not using my comfyui/venv and using the docker container's python runtime instead

I see there is a similar discussion in runpod discord, you mentioned "Exactly, the path is hard-coded into the venv. Again, symlink solves this." But I am using symlink but still it's not picking up the network volume's venv. Is there anything I'm mssing?

Thank you!

Paths in a venv are hard-coded, which is why there is symlinking from /runpod-volume to /workspace. If you are using a different venv, you will have to find a way to deal with the hard-coding of the path within the venv.

Paths in a venv are hard-coded, which is why there is symlinking from /runpod-volume to /workspace. If you are using a different venv, you will have to find a way to deal with the hard-coding of the path within the venv.

Ohh I see, so instead of
source "${comfyui_path}/venv/bin/activate"
I should probably do:
source "/runpod-volume/comfyui_0.1/venv/bin/activate" in my case? just removing the param should be fine?

Thanks very much for your prompt response!

Yes exactly, and also do something like that fix_venv script to fix the hard-coded paths within the venv, otherwise it will still use the system Python due to the hard-coded paths.

I also wanted to say thank you very much for the sponsorship, it is very much appreciated!

Yes exactly, and also do something like that fix_venv script to fix the hard-coded paths within the venv, otherwise it will still use the system Python due to the hard-coded paths.

Oh I see! I'll try that. Thank you!

I also wanted to say thank you very much for the sponsorship, it is very much appreciated!

No problem! Your code really helped me A LOT! I was struggling to figure out network volume, like how to use it, due to lack of docs around it. Without your repo, I wouldn't learn about how to use it.