nagadomi / nunif

Misc; latest version of waifu2x; 2D video to stereo 3D video conversion
MIT License
1.58k stars 142 forks source link

Setting the GPU via command line #170

Closed sundriftproductions closed 4 months ago

sundriftproductions commented 4 months ago

Hello --

I recently discovered IW3 and think it's great. I've been using the GUI version and have been very pleased with the speed with rendering off of my video card.

Now I'm trying to come up with a command line to do the exact same thing that I usually do in the GUI. Here is an example of what I'll use in the GUI:

image

And here's what I think is the equivalent CLI version:

python -m iw3 --input "M:\junk\actually convert these\test 1.avi" --output "M:\junk\actually convert these\test 1_SBS.mp4" --divergence 2.0 --convergence 0.5 --method row_flow_v3 --depth-model Any_V2_N_B --foreground-scale 0 --max-fps 30 --crf 20 --preset ultrafast --video-format mp4 --pix-fmt yuv420p --zoed-batch-size 2 --max-workers 16 --tta --ipd-offset 0 --edge-dilation 0 --gpu 0

The problem, though, is the --gpu 0 part. If I leave it off, it appears that it's relying on the CPU to render. (Please correct me if I'm wrong about this.) If I leave it on, my understanding is that this is supposed to pick up the first GPU it can find. Instead, I get this:

image

Any idea how I can fix this? I'd really like to render off of the GPU, not CPU via the command line.

nagadomi commented 4 months ago

The use of --gpu option is not a problem.

I am guessing the problem is that Python environment used for CLI is different from GUI. (installed PyTorch version does not support CUDA) If you have installed the GUI with nunif-windows-package, try the CLI on a prompt launched from nunif-prompt.bat.

If you want to create a python (venv) environment manually, the following command should install the same modules as nunif-windows-package.

pip install --no-cache-dir --upgrade -r requirements-torch.txt
pip install --no-cache-dir --upgrade -r requirements.txt
# pip install --no-cache-dir --upgrade -r requirements-gui.txt

This seems to be the same problem as #74 and CLI/GUI just reversed.

sundriftproductions commented 4 months ago

Thank you, nagadomi! Launching nunif-prompt.bat first works.

If I were to run the pip install commands that you mentioned, would the GUI version still work?

nagadomi commented 4 months ago

Is using CLI from nunif-prompt.bat not suitable for your purposes?

nunif-windows-package has a built-in python environment that is not affected by system python or other python projects. nunif-prompt.bat sets environment variables for its built-in python environment before launching the command prompt.

Running the above pip install command from global/system python will not affect nunif-windows-package environment, but if you are using other python projects, it can break their dependencies. In practice, venv is used to avoid such problems.

sundriftproductions commented 4 months ago

Ah, that makes sense. I can work with the CLI from nunif-prompt.bat. Thank you for clarifying, nagadomi!