-
-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run using docker-compose with GPU and CPU support #404
Conversation
docker/docker-compose.yml
Outdated
devices: | ||
- driver: nvidia | ||
count: 1 | ||
capabilities: [gpu] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried if the GPU usage works in Docker with this PR and everything seems fine, except ffmpeg using hwaccel for en-/decoding.
To solve this, you need to change this line to:
capabilities: [gpu,video]
which I can confirm fixes the problem and was found here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I've added video
capability and that removed the warning in ffmpeg
execution.
@@ -0,0 +1,4 @@ | |||
.cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this file - please undo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this file to prevent unnecessary file transfer between the Docker CLI and Docker Daemon when building the Docker Image. Here is documentation on how it works: https://docs.docker.com/engine/reference/builder/#dockerignore-file
This is the best practice when building Docker Images.
*.onnx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please undo the changes in .gitignore
RUN apt-get update && apt-get install -y \ | ||
ffmpeg | ||
|
||
WORKDIR /app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WORKDIR is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is needed for the following ADD commands to copy the files to the correct directory
|
||
WORKDIR /app | ||
|
||
ADD requirements.txt . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all the ADD and RUN git clone instead and checkout roop with the next branch
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I set the requirements for a reason... not asking for a development container but for a production container. It seems you continue to ignore this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the best practice on building Docker Images in CI Pipelines. In the CI Pipeline you only need to run:
docker-compose build
docker-compose push
And the images will be published to Docker Hub for public use. The published images are in no way dependent on the Git Repository.
If you want to clone the Git Repository in your CI Pipeline, you will somehow have to tell which commit to checkout or which branch. By building the Docker Images the way it's done in this pull request it happens automatically. The CI Pipeline will build exactly the commit that's been tested and built.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
ADD requirements.txt . | ||
RUN pip install -r requirements.txt | ||
|
||
ADD inswapper_128.onnx . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this ADD have to be removed - in next branch loading the models also happens automatically now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be placed into cache then, so that it won't be downloaded on each run.
|
||
RUN mkdir /cache | ||
|
||
ENTRYPOINT ["python", "/app/run.py"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENTRYPOINT ["python", "run.py"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First you say WORKDIR /app
is not needed, then you say ENTRYPOINT ["python", "run.py"]
. How should Python find run.py
without the WORKDIR or without the absolute path.
As far as I remember, Python says "explicit is better than implicit".
ADD run.py . | ||
ADD roop roop | ||
|
||
ENV HOME=/cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all that cache stuff... not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cache is needed unless you want roop
to download those files each time after you build a new Docker Image when you change a single line of code. Docker Containers are ephemeral. Unless the cache is persisted in a volume, it will be downloaded on each new start.
@@ -0,0 +1,25 @@ | |||
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply all the changes from the main Dockerfile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment. Which changes? The Dockerfiles for cuda and cpu are different, because there is no common base. cuda image is based on nvidia/cuda and the cpu image is based on python.
@@ -0,0 +1,25 @@ | |||
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename file to Dockerfile.cuda
@@ -0,0 +1,19 @@ | |||
FROM python:3.11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename file to Dockerfile
@@ -0,0 +1,65 @@ | |||
# Running roop in Docker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need a README, the final version just needs a docker-compose up :-)
build: | ||
context: .. | ||
dockerfile: docker/Dockerfile.cpu | ||
volumes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expose the temp and output folder
volumes:
- roop/output:/home/node/roop/output
- roop/temp:/home/node/roop/temp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really want to have them as Docker Volumes or do you want to bind-mount a directory from the host?
Bind-mounting a directory would be (the prepending ./
makes it a bind-mount):
services:
roop:
volumes:
- ./roop/output:/home/node/roop/output
- ./roop/temp:/home/node/roop/temp
Mounting a volume would be (can't have slashes in volume name):
services:
roop:
volumes:
- output:/home/node/roop/output
- temp:/home/node/roop/temp
volumes:
output:
temp:
@@ -0,0 +1,21 @@ | |||
services: | |||
roop-cpu: &base |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roop without cpu
- ../.github/examples:/data | ||
- ../.cache:/cache | ||
user: 1000:1000 | ||
roop-nvidia: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roop-cuda
@@ -12,7 +11,7 @@ onnxruntime==1.15.0; sys_platform == 'darwin' and platform_machine != 'arm64' | |||
onnxruntime-silicon==1.13.1; sys_platform == 'darwin' and platform_machine == 'arm64' | |||
onnxruntime-gpu==1.15.0; sys_platform != 'darwin' | |||
tensorflow==2.13.0rc1; sys_platform == 'darwin' | |||
tensorflow==2.12.0; sys_platform != 'darwin' | |||
tensorflow==2.13.0rc1; sys_platform != 'darwin' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please undo this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't be able to install all the dependencies, because requirements.txt
is broken at the moment. There is a conflict on the required version of transient numpy
.
Feel free to close this pull request. You may use it as a good starting point to build the thing you want to achieve, whatever it may be. |
* Rename landmark 5 variables * Mark as NEXT * Render tabs for multiple ui layout usage * Allow many face detectors at once, Add face detector tweaks * Remove face detector tweaks for now (kinda placebo) * Fix lint issues * Allow rendering the landmark-5 and landmark-5/68 via debugger * Fix naming * Convert face landmark based on confidence score * Convert face landmark based on confidence score * Add scrfd face detector model (#397) * Add scrfd face detector model * Switch to scrfd_2.5g.onnx model * Just some renaming * Downgrade OpenCV, Add SYSTEM_VERSION_COMPAT=0 for MacOS * Improve naming * prepare detect frame outside of semaphore * Feat/process manager (#399) * Minor naming * Introduce process manager to start and stop * Introduce process manager to start and stop * Introduce process manager to start and stop * Introduce process manager to start and stop * Introduce process manager to start and stop * Remove useless test for now * Avoid useless variables * Show stop once is_processing is True * Allow to stop ffmpeg processing too * Implement output image resolution (#403) * Implement output image resolution * Reorder code * Simplify output logic and therefore fix bug * Frame-enhancer-onnx (s0md3v#404) * changes * changes * changes * changes * add models * update workflow * Some cleanup * Some cleanup * Feat/frame enhancer polishing (#410) * Some cleanup * Polish the frame enhancer * Frame Enhancer: Add more models, optimize processing * Minor changes * Improve readability of create_tile_frames and merge_tile_frames * We don't have enough models yet * Feat/face landmarker score (#413) * Introduce face landmarker score * Fix testing * Fix testing * Use release for score related sliders * Reduce face landmark fallbacks * Scores and landmarks in Face dict, Change color-theme in face debugger * Scores and landmarks in Face dict, Change color-theme in face debugger * Fix some naming * Add 8K support (for whatever reasons) * Fix testing * Using get() for face.landmarks * Introduce statistics * More statistics * Limit the histogram equalization * Enable queue() for default layout * Improve copy_image() * Fix error when switching detector model * Always set UI values with globals if possible * Use different logic for output image and output video resolutions * Enforce re-download if file size is off * Remove unused method * Remove unused method * Remove unused warning filter * Improved output path normalization (s0md3v#419) * Handle some exceptions * Handle some exceptions * Cleanup * Prevent countless thread locks * Listen to user feedback * Fix webp edge case * Feat/cuda device detection (s0md3v#424) * Introduce cuda device detection * Introduce cuda device detection * it's gtx * Move logic to run_nvidia_smi() * Finalize execution device naming * Finalize execution device naming * Merge execution_helper.py to execution.py * Undo lowercase of values * Undo lowercase of values * Finalize naming * Add missing entry to ini * fix lip_syncer preview (#426) * fix lip_syncer preview * change * Refresh preview on trim changes * Cleanup frame enhancers and remove useless scale in merge_video() (s0md3v#428) * Keep lips over the whole video once lip syncer is enabled (s0md3v#430) * Keep lips over the whole video once lip syncer is enabled * changes * changes * Fix spacing * Use empty audio frame on silence * Use empty audio frame on silence * Fix ConfigParser encoding (#431) facefusion.ini is UTF8 encoded but config.py doesn't specify encoding which results in corrupted entries when non english characters are used. Affected entries: source_paths target_path output_path * Adjust spacing * Improve the GTX 16 series detection * Use general exception to catch ParseError * Use general exception to catch ParseError * Host frame enhancer models4 * Use latest onnxruntime * Minor changes in benchmark UI * Different approach to cancel ffmpeg process * Add support for amd amf encoders (#433) * Add amd_amf encoders * remove -rc cqp from amf encoder parameters * Improve terminal output, move success messages to debug mode * Improve terminal output, move success messages to debug mode * Minor update * Minor update * onnxruntime 1.17.1 matches cuda 12.2 * Feat/improved scaling (#435) * Prevent useless temp upscaling, Show resolution and fps in terminal output * Remove temp frame quality * Remove temp frame quality * Tiny cleanup * Default back to png for temp frames, Remove pix_fmt from frame extraction due mjpeg error * Fix inswapper fallback by onnxruntime * Fix inswapper fallback by major onnxruntime * Fix inswapper fallback by major onnxruntime * Add testing for vision restrict methods * Fix left / right face mask regions, add left-ear and right-ear * Flip right and left again * Undo ears - does not work with box mask * Prepare next release * Fix spacing * 100% quality when using jpg for temp frames * Use span_kendata_x4 as default as of speed * benchmark optimal tile and pad * Undo commented out code * Add real_esrgan_x4_fp16 model * Be strict when using many face detectors --------- Co-authored-by: Harisreedhar <46858047+harisreedhar@users.noreply.github.com> Co-authored-by: aldemoth <159712934+aldemoth@users.noreply.github.com>
I think I've got all the requirements from https://github.com/s0md3v/roop/issues/171#issuecomment-1584142177 except for the REST service:
I don't know how to implement those two in Python.