installing on apple silicon (m1 pro)

Installing and setting up FaceSwap


Forum rules

Read the FAQs and search the forum before posting a new topic.

Please mark any answers that fixed your problems so others can find the solutions.

Locked
User avatar
alexbloch8
Posts: 12
Joined: Tue Nov 09, 2021 2:06 pm

installing on apple silicon (m1 pro)

Post by alexbloch8 »

Hi
I've just finished installing faceswap on my macbook with M1 chip following the instruction in the git repo and here are a few notes (what I saw until now).

  • After finishing all the installation I tried running the GUI and got an error for running tensorflow 2.9 while faceswap support up to tensorflow 2.8
    I've checked the apple yaml file and saw that while the dependencies are set to tensorflow-deps==2.8.0 in reality it install tensorflow-macos 2.9.0
    I've removed the faceswap env and changed the yaml to trnsorflow-macos==2.8.0 and reinstalled the faceswap conda env
    this fixed the problem
  • I tried extracting and got an error that ffmpeg could not be found - maybe add brew install ffmpeg to the installation flow?

so far I'm in the middle of extraction - if I'll come across other issue I'll be happy to share if anyone is interested :)

by torzdf » Thu Jun 16, 2022 3:43 pm

Ok, merged.

Going to lock this thread as information is outdated. Any future M1 issues should start a new thread.

Go to full post
User avatar
torzdf
Posts: 2650
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 129 times
Been thanked: 622 times

Re: installing on apple silicon (m1 pro)

Post by torzdf »

Thanks for this. I do not own an M1 mac so am unable to test/give support. However, I do plan to roll the install process into the standard setup.py procedure at some point, which will hopefully alleviate the tensorflow version errors.

I always welcome PRs from users to fix these kinds of issues though :)

My word is final

User avatar
knowgood
Posts: 2
Joined: Mon May 23, 2022 5:30 am

Re: installing on apple silicon (m1 pro)

Post by knowgood »

I am having these same errors with the macbook m1. I am not quite sure how you were able to fix these issues. Could you walk me through it? I am fairly new to this.

User avatar
cascaschatz
Posts: 2
Joined: Tue May 31, 2022 10:01 pm

Re: installing on apple silicon (m1 pro)

Post by cascaschatz »

Hello, same issue here. Somebody to help?

User avatar
alexbloch8
Posts: 12
Joined: Tue Nov 09, 2021 2:06 pm

Re: installing on apple silicon (m1 pro)

Post by alexbloch8 »

My deepest apologies! I was vacationing and only saw the post now!
[mention]cascaschatz[/mention] [mention]knowgood[/mention] after you clone the repo and have the faceswap folder on your mac go to faceswap/requirements folder.
there you will see the "conda-environment-apple-sillicon.yaml" file. in there you will see a line "tensorflow-macos" - I've edited this and set it to 2.8.0 (i.e tensorflow-mscos==2.8.0) and saved (I've also set tensorflow-deps==2.8.0 just to be on the safe side).
from there just follow the install.md file (don't forget to install ffmpeg as well)

User avatar
cascaschatz
Posts: 2
Joined: Tue May 31, 2022 10:01 pm

Re: installing on apple silicon (m1 pro)

Post by cascaschatz »

Don't mention it, Alex.
Tks for your support.
I did like you ask, including ffmpeg. It has solved the problem, partially.
Now, the error message is like below:
Image

Image

Do you know if it is easy to fix?

User avatar
alexbloch8
Posts: 12
Joined: Tue Nov 09, 2021 2:06 pm

Re: installing on apple silicon (m1 pro)

Post by alexbloch8 »

mmmm that is strange - I've never came across this - perhaps a clean install of everything would help?

User avatar
knowgood
Posts: 2
Joined: Mon May 23, 2022 5:30 am

Re: installing on apple silicon (m1 pro)

Post by knowgood »

[mention]alexbloch8[/mention] I really appreciate your reponse. Although I am having this issue now after following your steps. I am not sure how to downgrade the protobuf.

Image

User avatar
torzdf
Posts: 2650
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 129 times
Been thanked: 622 times

Re: installing on apple silicon (m1 pro)

Post by torzdf »

I have added a new branch to try and roll Apple Silicon into the standard setup path. I do not have an M1 to test though, so would welcome testers to try and standardise the install.

Please follow the steps here:

https://github.com/deepfakes/faceswap/b ... tall-guide

After running the command to download the faceswap repo (git clone) please enter the command:

Code: Select all

git checkout apple_setup

before continuing.

I'm sure there will be errors, but hopefully I can get on top of them.

My word is final

User avatar
geewiz94
Posts: 8
Joined: Wed Nov 24, 2021 8:17 pm
Been thanked: 3 times

Re: installing on apple silicon (m1 pro)

Post by geewiz94 »

[mention]torzdf[/mention] I tried out your branch and fixed some issues:
https://github.com/deepfakes/faceswap/pull/1238

Note that setup.py doesn't ask for Apple Silicon, so the backend gets set to CPU. This:

Code: Select all

python setup.py --apple-silicon

worked though.

Setup runs successfully using my PR, but when trying to run FS, I get this:

Code: Select all

Setting Faceswap backend to APPLE_SILICON
Traceback (most recent call last):
  File "/Users/server/Documents/faceswap_test/faceswap.py", line 6, in <module>
    from lib.cli import args as cli_args
  File "/Users/server/Documents/faceswap_test/lib/cli/args.py", line 13, in <module>
    from lib.gpu_stats import GPUStats
  File "/Users/server/Documents/faceswap_test/lib/gpu_stats/__init__.py", line 20, in <module>
    from .apple_silicon import AppleSiliconStats as GPUStats  # noqa
  File "/Users/server/Documents/faceswap_test/lib/gpu_stats/apple_silicon.py", line 7, in <module>
    import tensorflow as tf
  File "/Users/server/miniforge3/envs/test3/lib/python3.9/site-packages/tensorflow/__init__.py", line 37, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/Users/server/miniforge3/envs/test3/lib/python3.9/site-packages/tensorflow/python/__init__.py", line 37, in <module>
    from tensorflow.python.eager import context
  File "/Users/server/miniforge3/envs/test3/lib/python3.9/site-packages/tensorflow/python/eager/context.py", line 29, in <module>
    from tensorflow.core.framework import function_pb2
  File "/Users/server/miniforge3/envs/test3/lib/python3.9/site-packages/tensorflow/core/framework/function_pb2.py", line 16, in <module>
    from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
  File "/Users/server/miniforge3/envs/test3/lib/python3.9/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
    from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
  File "/Users/server/miniforge3/envs/test3/lib/python3.9/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
    from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
  File "/Users/server/miniforge3/envs/test3/lib/python3.9/site-packages/tensorflow/core/framework/resource_handle_pb2.py", line 16, in <module>
    from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
  File "/Users/server/miniforge3/envs/test3/lib/python3.9/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 36, in <module>
    _descriptor.FieldDescriptor(
  File "/Users/server/miniforge3/envs/test3/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 560, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

Might be due to a new Python version?

User avatar
torzdf
Posts: 2650
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 129 times
Been thanked: 622 times

Re: installing on apple silicon (m1 pro)

Post by torzdf »

I have this issue on AMD too, so I have pinned protobuf. Will push the same for Apple-silicon now.

Edit: Now pushed

My word is final

User avatar
torzdf
Posts: 2650
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 129 times
Been thanked: 622 times

Re: installing on apple silicon (m1 pro)

Post by torzdf »

geewiz94 wrote: Thu Jun 16, 2022 10:14 am

@torzdf I tried out your branch and fixed some issues:
https://github.com/deepfakes/faceswap/pull/1238

Note that setup.py doesn't ask for Apple Silicon, so the backend gets set to CPU. This:

Code: Select all

python setup.py --apple-silicon

worked though.

Might be due to a new Python version?

Ok, that was an oversight (it's not meant to ask, but it should set the backend). Will look to fix that now.

My word is final

User avatar
geewiz94
Posts: 8
Joined: Wed Nov 24, 2021 8:17 pm
Been thanked: 3 times

Re: installing on apple silicon (m1 pro)

Post by geewiz94 »

Nice, I'm getting no more errors! I also checked that GPU training works, seems to be fine!

User avatar
torzdf
Posts: 2650
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 129 times
Been thanked: 622 times

Re: installing on apple silicon (m1 pro)

Post by torzdf »

Ok, I have pushed an update now where if the --apple-silicon is not passed in, it should now set the backend correctly.

If you could confirm, it would be appreciated. I'll then get this merged to master

My word is final

User avatar
geewiz94
Posts: 8
Joined: Wed Nov 24, 2021 8:17 pm
Been thanked: 3 times

Re: installing on apple silicon (m1 pro)

Post by geewiz94 »

Backend gets set correctly now :)

User avatar
torzdf
Posts: 2650
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 129 times
Been thanked: 622 times

Re: installing on apple silicon (m1 pro)

Post by torzdf »

Ok, merged.

Going to lock this thread as information is outdated. Any future M1 issues should start a new thread.

My word is final

Locked