DeepFaceLab_MacOS icon indicating copy to clipboard operation
DeepFaceLab_MacOS copied to clipboard

XSeg editor does not run on Apple M1

Open chychkan opened this issue 3 years ago • 13 comments

The ./scripts/xseg.sh script fails with the following error:

Traceback (most recent call last):
  File "/Users/alex/Code/chychkan/DeepFaceLab_MacOS/.dfl/DeepFaceLab/main.py", line 343, in <module>
    arguments.func(arguments)
  File "/Users/alex/Code/chychkan/DeepFaceLab_MacOS/.dfl/DeepFaceLab/main.py", line 291, in process_xsegeditor
    from XSegEditor import XSegEditor
  File "/Users/alex/Code/chychkan/DeepFaceLab_MacOS/.dfl/DeepFaceLab/XSegEditor/XSegEditor.py", line 15, in <module>
    from PyQt5.QtCore import *
ModuleNotFoundError: No module named 'PyQt5'

The root cause is that DeepFaceLap codebase is not compatible with PyQt6 which we install on M1 laptops.

chychkan avatar Feb 23 '22 05:02 chychkan

Is there GPU support?

cantonalex avatar Feb 25 '22 14:02 cantonalex

The issue is tagged as "stale issue" due to no activity in 30 days. If there is no activity for 15 more days, the issue will be closed.

github-actions[bot] avatar Mar 27 '22 14:03 github-actions[bot]

Bumping this because this isn't working for me too.

@chychkan were you able to find a workaround? I've tried installing python -m pip install PyQt5, but that doesn't seem to work.

rolandinthedeep avatar May 18 '22 04:05 rolandinthedeep

@rolandinthedeep yeah, PyQt5 is not compatible with M1 and DeepFaceLab itself is not compatible with PyQt6. One possible path forward could be to upgrade DeepFaceLab to PyQt6, but I didn't have time to look into that.

chychkan avatar May 18 '22 14:05 chychkan

I found PR #5523 that uses PySide6 instead of PyQt. I switched to this and now I'm able to train and use the XSeg editor on my M1 Mac mini!

Steps I followed

  1. Follow all instructions in this repo's README, but stop before you run ./scripts/0_setup.sh
  2. Edit ./scripts/0_setup.sh
    1. Change https://github.com/chychkan/DeepFaceLab.git to https://github.com/jkennedyvz/DeepFaceLab.git (the source repo of the PR mentioned above)
    2. Change python3 to python3.9 (you may not need to do this, but for some reason I had to do this or else virtualenv would use Python 3.10)
  3. Edit requirements_3.9_arm64.txt
    1. Add tensorflow-metal
    2. Add PySide6
  4. Run ./scripts/0_setup.sh

Temporary bug and workaround

At this point, you may run into different problems. It appears there is a bug in the latest update to protobuf. To get around this, force a downgrade in your Python environment:

  1. Run source .dfl/env/bin/activate
  2. Run pip install 'protobuf~=3.19.0'
  3. Run deactivate

Notes

I'm completely new to the XSeg editor, so I don't know if it is working 100%. But it does launch, loads my frames, and seems to let me save changes.

andrewortwein avatar May 29 '22 01:05 andrewortwein

I found PR #5523 that uses PySide6 instead of PyQt. I switched to this and now I'm able to train and use the XSeg editor on my M1 Mac mini!

Steps I followed

  1. Follow all instructions in this repo's README, but stop before you run ./scripts/0_setup.sh

  2. Edit ./scripts/0_setup.sh

    1. Change https://github.com/chychkan/DeepFaceLab.git to https://github.com/jkennedyvz/DeepFaceLab.git (the source repo of the PR mentioned above)
    2. Change python3 to python3.9 (you may not need to do this, but for some reason I had to do this or else virtualenv would use Python 3.10)
  3. Edit requirements_3.9_arm64.txt

    1. Add tensorflow-metal
    2. Add PySide6
  4. Run ./scripts/0_setup.sh

Temporary bug and workaround

At this point, you may run into different problems. It appears there is a bug in the latest update to protobuf. To get around this, force a downgrade in your Python environment:

  1. Run source .dfl/env/bin/activate
  2. Run pip install 'protobuf~=3.19.0'
  3. Run deactivate

Notes

I'm completely new to the XSeg editor, so I don't know if it is working 100%. But it does launch, loads my frames, and seems to let me save changes.

Run on Apple air M1 successfully, Thanks for your effort to fix it.

ipatpat avatar Jun 10 '22 06:06 ipatpat

Hi,

When I tried with the PR I get this error : (env) jbarbaud@MacBook-Air-de-Jeremy DeepFaceLab_MacOS % bash scripts/2_extract_images_from_video_data_src.sh RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe ImportError: numpy.core._multiarray_umath failed to import ImportError: numpy.core.umath failed to import Process Process-1: Traceback (most recent call last): File "/opt/homebrew/Cellar/[email protected]/3.9.13_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap self.run() File "/opt/homebrew/Cellar/[email protected]/3.9.13_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/DeepFaceLab/core/leras/device.py", line 102, in _get_tf_devices_proc import tensorflow File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/init.py", line 37, in from tensorflow.python.tools import module_util as _module_util File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/init.py", line 42, in from tensorflow.python import data File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/data/init.py", line 21, in from tensorflow.python.data import experimental File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/data/experimental/init.py", line 95, in from tensorflow.python.data.experimental import service File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/data/experimental/service/init.py", line 387, in from tensorflow.python.data.experimental.ops.data_service_ops import distribute File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py", line 22, in from tensorflow.python.data.experimental.ops import compression_ops File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/data/experimental/ops/compression_ops.py", line 16, in from tensorflow.python.data.util import structure File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/data/util/structure.py", line 22, in from tensorflow.python.data.util import nest File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/data/util/nest.py", line 36, in from tensorflow.python.framework import sparse_tensor as _sparse_tensor File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/framework/sparse_tensor.py", line 24, in from tensorflow.python.framework import constant_op File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/framework/constant_op.py", line 25, in from tensorflow.python.eager import execute File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/eager/execute.py", line 23, in from tensorflow.python.framework import dtypes File "/Users/jbarbaud/DeepFaceLab_MacOS/.dfl/env/lib/python3.9/site-packages/tensorflow/python/framework/dtypes.py", line 29, in _np_bfloat16 = _pywrap_bfloat16.TF_bfloat16_type() TypeError: Unable to convert function return value to a Python type! The signature was () -> handle

Did you get that ? Thank you

jeremybarbaud avatar Aug 18 '22 21:08 jeremybarbaud

I found PR #5523 that uses PySide6 instead of PyQt. I switched to this and now I'm able to train and use the XSeg editor on my M1 Mac mini!

Steps I followed

  1. Follow all instructions in this repo's README, but stop before you run ./scripts/0_setup.sh

  2. Edit ./scripts/0_setup.sh

    1. Change https://github.com/chychkan/DeepFaceLab.git to https://github.com/jkennedyvz/DeepFaceLab.git (the source repo of the PR mentioned above)
    2. Change python3 to python3.9 (you may not need to do this, but for some reason I had to do this or else virtualenv would use Python 3.10)
  3. Edit requirements_3.9_arm64.txt

    1. Add tensorflow-metal
    2. Add PySide6
  4. Run ./scripts/0_setup.sh

Temporary bug and workaround

At this point, you may run into different problems. It appears there is a bug in the latest update to protobuf. To get around this, force a downgrade in your Python environment:

  1. Run source .dfl/env/bin/activate
  2. Run pip install 'protobuf~=3.19.0'
  3. Run deactivate

Notes

I'm completely new to the XSeg editor, so I don't know if it is working 100%. But it does launch, loads my frames, and seems to let me save changes.

Run on Apple air M1 successfully, Thanks for your effort to fix it.

Hi does it still work? I also got m1 mbp

ngardelis avatar Feb 27 '23 17:02 ngardelis

Hey @andrewortwein can you tell me which python version you use and all the versions of requirements_3.9_arm64.txt in your working solution? Because for me it works but when I train a model in the training preview, 3 from all 5 columns are grey and never update on each frame for some reason

ngardelis avatar Feb 28 '23 07:02 ngardelis

Hey @andrewortwein can you tell me which python version you use and all the versions of requirements_3.9_arm64.txt in your working solution? Because for me it works but when I train a model in the training preview, 3 from all 5 columns are grey and never update on each frame for some reason

It's been many months since I've tried that, but I do still have the env around and here are the settings it's in:

python version: 3.9

#requirements_3.9_arm64.txt
numpy==1.21.4
opencv-python==4.5.5.62
numexpr==2.8.1
h5py==3.1.0
tqdm==4.62.3
colorama==0.4.4
cython==0.29.26
ffmpeg-python==0.2.0
Pillow==8.4.0
scikit-image==0.19.1
scipy==1.8.0
tensorflow-macos==2.7.0
PyQt6==6.2.3
tensorflow-metal

andrewortwein avatar Mar 05 '23 16:03 andrewortwein

@andrewortwein Thank you very much, it works for me now!

ngardelis avatar Mar 07 '23 18:03 ngardelis

Hey @andrewortwein can you tell me which python version you use and all the versions of requirements_3.9_arm64.txt in your working solution? Because for me it works but when I train a model in the training preview, 3 from all 5 columns are grey and never update on each frame for some reason

My training previews of columns 3 , 5 and 6 are empty. And my loss is also not going down. As if model is not learning , just calculating bunch of stuff. Did you get any solution?

prashantspandey avatar Mar 15 '23 21:03 prashantspandey

Hey @andrewortwein can you tell me which python version you use and all the versions of requirements_3.9_arm64.txt in your working solution? Because for me it works but when I train a model in the training preview, 3 from all 5 columns are grey and never update on each frame for some reason

My training previews of columns 3 , 5 and 6 are empty. And my loss is also not going down. As if model is not learning , just calculating bunch of stuff.

Did you get any solution?

Did you try to run it with SAEHD? The issue for me was I was using quick96 instead of SAEHD

ngardelis avatar Mar 21 '23 21:03 ngardelis