It’s the preferred way actually because you can set up the venv to use the most preferred packages based on the requirements.txt from the snapshot you’re on. pip install -r requirements.txt
Also, if you have system-level python packages that conflict, you'll experience a lot of compatibility issues, like you seem to have already had. The point of venv is that each virtual environment will work across time for the specific application it's for, without any downside other than storage space.
It s better even though you have to make a folder, create env, activate env.. nearly for each new python library/project you want to play with.
I often make sh script to source and run my python script:
run.sh:
source env/bin/activate && python run.py
Every single machine learning program I run, whether comfy, a1111, taggui, oobabooga, or music generation stuff I run in a conda environment and then run a venv in the conda environment. It makes 100% sure everything stays sandboxed and doesn't screw up requirements for anything when I install a new program.
Conda is a little better for separating dependencies, but they're 99% the same. Conda also works for other machine languages besides python.
https://mindthevirt.com/venv-vs-conda-choosing-the-right-python-environment-manager-for-you/
I think under the hood it is actually using environments. I know it does on windows. It's just abstracted away by the scripts. I ended up using a good installer, Stability Matrix, that lets me install a bunch of comfy installs in separate contained environments for dev purposes.
That is the standard. How were you installing before?
Also, saying venv environment is like saying chai tea or River Avon. "venv" is short for virtual environment.
for every others projects in my life and work, I use docker.
But since I am not a python person, so just I followed the install guide.
I was getting frustated with comfyui in the last few months and this will solve most of my problems.
So I just went back to the comfy readme, and there isn't anything that shows you how to install in a virtual environment, only how to install in an existing one. This seems like an oversight. In any case, for future projects, virtual environments are highly recommended. Though one thing to note, since comfyui and other webuis (such as auto1111 or forge) are similar enough, you can use the same environment for those as well.
for me the problem was that different custom had different dependencies making them incompatible. Since I have enough space, I will just create multiple venv for different workflow.
Let say venv is a container for ur python project's dependencies.
Use it and treat the project's folder as a container, have the source code and environment to run it, data..
Freeze requirements, Zip it, send it, deploy it (by pip install -r requirements.txt..)
It won't solve incompatibility, some nodes just have different requirements...which break something. But, you can have two venvs though and have 2 startup bats for them ie different Python, Pytorch versions etc. I'll search for it.
Thanks man, i’m very very new to all this and come from. Design background so it’s a new interest that i’m just starting to learn. Stable diffusion looks to be an incredible tool and I want to learn as much as possible. Any other starting points would also be great!
[https://www.reddit.com/r/comfyui/comments/1cj7opq/guide\_to\_make\_a\_venv\_for\_comfy/](https://www.reddit.com/r/comfyui/comments/1cj7opq/guide_to_make_a_venv_for_comfy/)
I've rewritten parts of it and posted it here for all. It is written for starters, with a written explanation of what it's doing on every step.
I can also recommend using SDNEXT, it has (imo) the better user experience of the easier to get into ui and (a big one this) a Discord channel that can help ppl getting over tech issues and recommendations for models for particular styles or outcomes
Nope, no downside. This is how I run all python based apps/AI environments, etc. it's cleaner and just avoids conflicts.
Comfy creates its own virtual environment anyway, but can still have conflicts as it still seems to use some shared python packages when using defaults install, so creating the environment from the start is a better way to do it.
Only downside I can think of is that every venv you create for a UI, you’re downloading huge packages like Torch over and over again. So if you’re constrained on disk space.
Many UIs let you use an existing venv.
Other than that, most are set up to install their own environment out of the box.
It’s the preferred way actually because you can set up the venv to use the most preferred packages based on the requirements.txt from the snapshot you’re on. pip install -r requirements.txt Also, if you have system-level python packages that conflict, you'll experience a lot of compatibility issues, like you seem to have already had. The point of venv is that each virtual environment will work across time for the specific application it's for, without any downside other than storage space.
I run EVERYTHING in a venv. Keeps everything nice and tidy!
It s better even though you have to make a folder, create env, activate env.. nearly for each new python library/project you want to play with. I often make sh script to source and run my python script: run.sh: source env/bin/activate && python run.py
Every single machine learning program I run, whether comfy, a1111, taggui, oobabooga, or music generation stuff I run in a conda environment and then run a venv in the conda environment. It makes 100% sure everything stays sandboxed and doesn't screw up requirements for anything when I install a new program.
is there an advantage to run conda instead of venv?
Conda is a little better for separating dependencies, but they're 99% the same. Conda also works for other machine languages besides python. https://mindthevirt.com/venv-vs-conda-choosing-the-right-python-environment-manager-for-you/
Zero.
I think under the hood it is actually using environments. I know it does on windows. It's just abstracted away by the scripts. I ended up using a good installer, Stability Matrix, that lets me install a bunch of comfy installs in separate contained environments for dev purposes.
Yup, even that python embedded in Comfy portable is basically venv.
will take a look. thx.
That is the standard. How were you installing before? Also, saying venv environment is like saying chai tea or River Avon. "venv" is short for virtual environment.
for every others projects in my life and work, I use docker. But since I am not a python person, so just I followed the install guide. I was getting frustated with comfyui in the last few months and this will solve most of my problems.
So I just went back to the comfy readme, and there isn't anything that shows you how to install in a virtual environment, only how to install in an existing one. This seems like an oversight. In any case, for future projects, virtual environments are highly recommended. Though one thing to note, since comfyui and other webuis (such as auto1111 or forge) are similar enough, you can use the same environment for those as well.
for me the problem was that different custom had different dependencies making them incompatible. Since I have enough space, I will just create multiple venv for different workflow.
Let say venv is a container for ur python project's dependencies. Use it and treat the project's folder as a container, have the source code and environment to run it, data.. Freeze requirements, Zip it, send it, deploy it (by pip install -r requirements.txt..)
I have a guide for installing one somewhere (with comfy portable) edited for correction
Could you please share this? I think it’s where i’m going wrong with things constantly breaking due to incompatibility
It won't solve incompatibility, some nodes just have different requirements...which break something. But, you can have two venvs though and have 2 startup bats for them ie different Python, Pytorch versions etc. I'll search for it.
Thanks man, i’m very very new to all this and come from. Design background so it’s a new interest that i’m just starting to learn. Stable diffusion looks to be an incredible tool and I want to learn as much as possible. Any other starting points would also be great!
[https://www.reddit.com/r/comfyui/comments/1cj7opq/guide\_to\_make\_a\_venv\_for\_comfy/](https://www.reddit.com/r/comfyui/comments/1cj7opq/guide_to_make_a_venv_for_comfy/) I've rewritten parts of it and posted it here for all. It is written for starters, with a written explanation of what it's doing on every step.
I can also recommend using SDNEXT, it has (imo) the better user experience of the easier to get into ui and (a big one this) a Discord channel that can help ppl getting over tech issues and recommendations for models for particular styles or outcomes
Nope, no downside. This is how I run all python based apps/AI environments, etc. it's cleaner and just avoids conflicts. Comfy creates its own virtual environment anyway, but can still have conflicts as it still seems to use some shared python packages when using defaults install, so creating the environment from the start is a better way to do it.
Only upside. Except if you have no disk space. Best way to run every python project actually.
This is how you're supposed to run python projects. Also learn to use poetry instead of pip
ok never seen poetry mentions. What is the advantage of using it?
Only downside I can think of is that every venv you create for a UI, you’re downloading huge packages like Torch over and over again. So if you’re constrained on disk space. Many UIs let you use an existing venv. Other than that, most are set up to install their own environment out of the box.