Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

refacer and roop parralel installation causes problems. #60

Open
NeverBeLazyG opened this issue Jun 27, 2023 · 12 comments
Open

refacer and roop parralel installation causes problems. #60

NeverBeLazyG opened this issue Jun 27, 2023 · 12 comments

Comments

@NeverBeLazyG
Copy link

NeverBeLazyG commented Jun 27, 2023

when i install refacer after roop. then roop dont work anymore. then i installed roop again. when i do this refacer dont work anymore:

i think it has something to do with cuda environment variables. here is the error i get:

`
PS C:\tools\refacer\refacer> python .\app.py
Trying FFMPEG h264_nvenc encoder
FFMPEG h264_nvenc encoder works
Video codec for FFMPEG: h264_nvenc
CUDA mode with providers ['CUDAExecutionProvider', 'CPUExecutionProvider']
EP Error D:\a_work\1\s\onnxruntime\python\onnxruntime_pybind_state.cc:636 onnxruntime::python::CreateExecutionProviderInstance CUDA_PATH is set but CUDA wasn't able to be loaded. Please install the correct version of CUDA and cuDNN as mentioned in the GPU requirements page (https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements), make sure they're in the PATH, and that your GPU is supported.
when using ['CUDAExecutionProvider', 'CPUExecutionProvider']
Falling back to ['CUDAExecutionProvider', 'CPUExecutionProvider'] and retrying.
Traceback (most recent call last):
File "C:\Users\youba\AppData\Local\Programs\Python\Python310\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 383, in init
self._create_inference_session(providers, provider_options, disabled_optimizers)
File "C:\Users\youba\AppData\Local\Programs\Python\Python310\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 435, in _create_inference_session
sess.initialize_session(providers, provider_options, disabled_optimizers)
RuntimeError: D:\a_work\1\s\onnxruntime\python\onnxruntime_pybind_state.cc:636 onnxruntime::python::CreateExecutionProviderInstance CUDA_PATH is set but CUDA wasn't able to be loaded. Please install the correct version of CUDA and cuDNN as mentioned in the GPU requirements page (https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements), make sure they're in the PATH, and that your GPU is supported.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\tools\refacer\refacer\app.py", line 17, in
refacer = Refacer(force_cpu=args.force_cpu,colab_performance=args.colab_performance)
File "C:\tools\refacer\refacer\refacer.py", line 35, in init
self.__init_apps()
File "C:\tools\refacer\refacer\refacer.py", line 84, in __init_apps
sess_face = rt.InferenceSession(model_path, self.sess_options, providers=self.providers)
File "C:\Users\youba\AppData\Local\Programs\Python\Python310\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 394, in init
raise fallback_error from e
File "C:\Users\youba\AppData\Local\Programs\Python\Python310\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 389, in init
self._create_inference_session(self._fallback_providers, None)
File "C:\Users\youba\AppData\Local\Programs\Python\Python310\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 435, in _create_inference_session
sess.initialize_session(providers, provider_options, disabled_optimizers)
RuntimeError: D:\a_work\1\s\onnxruntime\python\onnxruntime_pybind_state.cc:636 onnxruntime::python::CreateExecutionProviderInstance CUDA_PATH is set but CUDA wasn't able to be loaded. Please install the correct version of CUDA and cuDNN as mentioned in the GPU requirements page (https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements), make sure they're in the PATH, and that your GPU is supported.

PS C:\tools\refacer\refacer>
`

newest version of cuda cudnn etc. is installed. and works properly in other aplications. only roop and refacer together makes problems.

please help

@phineas-pta
Copy link
Contributor

better isolate environments with venv or conda, install many projects in same environment likely fails

@NeverBeLazyG
Copy link
Author

can you please explain me how ? i dont know how to do. i am not a python expert.

@phineas-pta
Copy link
Contributor

google venv for example

@NeverBeLazyG
Copy link
Author

ok thanks, what is better conda or venv ?

@phineas-pta
Copy link
Contributor

u can start with venv

@NeverBeLazyG
Copy link
Author

ok i got it to run with venv. but now i have the next problem. when i run it via a venv --system-site-packages, it wont use my gpu anymore.

can i force to use the gpu ?

`(refacer) C:\tools\refacer\refacer>python app.py
Trying FFMPEG h264_nvenc encoder
FFMPEG h264_nvenc encoder works
Video codec for FFMPEG: h264_nvenc
CPU mode with providers ['CPUExecutionProvider']
inswapper-shape: [1, 3, 128, 128]
Running on local URL: http://127.0.0.1:7860

To create a public link, set share=True in launch().`

@NeverBeLazyG
Copy link
Author

NeverBeLazyG commented Jun 28, 2023

sorry to bother you. maybe i found the problem, why roop and refacer dont works parralel. i think refacer developer have some backed in path to onnxruntim in his python script to his own d:\ drive, look at the output error, there is a D:\a_work\ directory backed into the code:

"(refacer_env) C:\tools\refacer_env\refacer>python app.py
Trying FFMPEG h264_nvenc encoder
FFMPEG h264_nvenc encoder works
Video codec for FFMPEG: h264_nvenc
CUDA mode with providers ['CUDAExecutionProvider', 'CPUExecutionProvider']
EP Error D:\a_work\1\s\onnxruntime\python\onnxruntime_pybind_state.cc:636 onnxruntime::python::CreateExecutionProviderInstance CUDA_PATH is set but CUDA wasn't able to be loaded. Please install the correct version of CUDA and cuDNN as mentioned in the GPU requirements page (https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements), make sure they're in the PATH, and that your GPU is supported.
when using ['CUDAExecutionProvider', 'CPUExecutionProvider']
Falling back to ['CUDAExecutionProvider', 'CPUExecutionProvider'] and retrying.
Traceback (most recent call last):
File "C:\tools\refacer_env\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 383, in init
self._create_inference_session(providers, provider_options, disabled_optimizers)
File "C:\tools\refacer_env\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 435, in _create_inference_session
sess.initialize_session(providers, provider_options, disabled_optimizers)
RuntimeError: D:\a_work\1\s\onnxruntime\python\onnxruntime_pybind_state.cc:636 onnxruntime::python::CreateExecutionProviderInstance CUDA_PATH is set but CUDA wasn't able to be loaded. Please install the correct version of CUDA and cuDNN as mentioned in the GPU requirements page (https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements), make sure they're in the PATH, and that your GPU is supported.

@phineas-pta
Copy link
Contributor

D:\a_work\1\s\onnxruntime\python\... is a mess generated by onnxruntime, the devs never hard code any path in the scripts

@ooofest
Copy link

ooofest commented Jun 28, 2023

My refacer installation is based on much the same steps as for the roop install - is it all necessary? Not sure, but it already worked for roop and I found it also supported refacer:

  1. install visual studio 2022 with desktop development C++ and python development (not sure about python development)
  2. install cuda 11.7 (https://developer.nvidia.com/cuda-11-7-0-download-archive)
  3. download cudnn 8.9.1 for cuda 11.x https://developer.nvidia.com/rdp/cudnn-archive
  4. unpack cudnn over C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7 with replacement
  5. install python 3.10.x (any 3.10)
  6. download and install the last version of refacer
  7. pip install virtualenv
  8. virtualenv venv
  9. venv\scripts\activate.bat
  10. pip install torch torchvision torchaudio --force-reinstall --index-url https://download.pytorch.org/whl/cu118
  11. pip install -r requirements-GPU.txt
  12. Add ...\refacer-main\venv\Lib\site-packages\torch\lib to PATH (e.g., SET PATH=C:\refacer-main\venv\Lib\site-packages\torch\lib;%PATH%)
  13. SET CUDA_VISIBLE_DEVICES=x

That final step is unnecessary if you have a single GPU, but if you have multiple GPUs then set it to the ordinal of your desired card (e.g., 0, 1, . . .) and it will primarily use that GPU for supported operations.

They both use their respective venv environment and there have been no clashes/collisions.

@NeverBeLazyG
Copy link
Author

ok i will try this thank you

@NeverBeLazyG
Copy link
Author

My refacer installation is based on much the same steps as for the roop install - is it all necessary? Not sure, but it already worked for roop and I found it also supported refacer:

  1. install visual studio 2022 with desktop development C++ and python development (not sure about python development)
  2. install cuda 11.7 (https://developer.nvidia.com/cuda-11-7-0-download-archive)
  3. download cudnn 8.9.1 for cuda 11.x https://developer.nvidia.com/rdp/cudnn-archive
  4. unpack cudnn over C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7 with replacement
  5. install python 3.10.x (any 3.10)
  6. download and install the last version of refacer
  7. pip install virtualenv
  8. virtualenv venv
  9. venv\scripts\activate.bat
  10. pip install torch torchvision torchaudio --force-reinstall --index-url https://download.pytorch.org/whl/cu118
  11. pip install -r requirements-GPU.txt
  12. Add ...\refacer-main\venv\Lib\site-packages\torch\lib to PATH (e.g., SET PATH=C:\refacer-main\venv\Lib\site-packages\torch\lib;%PATH%)
  13. SET CUDA_VISIBLE_DEVICES=x

That final step is unnecessary if you have a single GPU, but if you have multiple GPUs then set it to the ordinal of your desired card (e.g., 0, 1, . . .) and it will primarily use that GPU for supported operations.

They both use their respective venv environment and there have been no clashes/collisions.

thank you so much friend. now it worked. the only difference to you was the setting path. maybe that was the problem. 😀

@phineas-pta
Copy link
Contributor

consider closing the issue if u r good

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants