Skip to content

Commit a3ab8d8

Browse files
cantonalexchychkan
andauthored
Add support for Apple M1 laptops (#71)
* Add support for Apple M1 laptops * Pre-install numpy * Use forked DeepFaceLab with minor fixes * Use --no-single-branch when cloning DFL * Minor improvements * Minor fixes to 0_setup.sh * Update versions * Update README Co-authored-by: Oleksandr Chychkan <chychkan@gmail.com>
1 parent cff388e commit a3ab8d8

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ This project provides scripts inspired by [DeepFaceLab_Linux](https://github.com
44

55
You'll need `git`, `ffmpeg`, `python3` and python module `virtualenv` available to be able to execute these scripts. The scripts will create a virtual env sandbox and will install all necessary dependencies there, so your main installation of `python3` will be left intact.
66

7+
## NOTE: Apple M1 chip
8+
9+
Currently there's limited support for Apple M1 laptops. You can do model training, but the XSeg editor currently does not work (the DeepFaceLab codebase is not compatible with PyQt6).
10+
711
## Setup
812

913
**Tools**
@@ -14,6 +18,9 @@ Make sure you have installed:
1418
- [Python 3](https://www.python.org/) (check with `python3 --version`)
1519
- [Virtualenv](https://github.com/pypa/virtualenv) (check with `virtualenv --version`)
1620

21+
For **Apple M1** laptops you also need [hdf5](https://formulae.brew.sh/formula/hdf5) lib installed.
22+
Check if you have it with `brew ls --versions hdf5`. Install it with `brew install hdf5`.
23+
1724
**Clone and setup**
1825

1926
1. Clone this repository (`git clone https://github.com/chychkan/DeepFaceLab_MacOS.git`)

requirements_3.9_arm64.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
numpy==1.21.4
2+
opencv-python==4.5.5.62
3+
numexpr==2.8.1
4+
h5py==3.1.0
5+
tqdm==4.62.3
6+
colorama==0.4.4
7+
cython==0.29.26
8+
ffmpeg-python==0.2.0
9+
Pillow==8.4.0
10+
scikit-image==0.19.1
11+
scipy==1.8.0
12+
tensorflow-macos==2.7.0
13+
PyQt6==6.2.3

scripts/0_setup.sh

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@ set -e
66
mkdir -p .dfl
77
mkdir -p workspace
88

9+
is_arm64() {
10+
[ "$(uname -m)" == "arm64" ]
11+
}
12+
13+
is_arm64 && echo "Running on Apple M1 chip"
14+
915
if [ ! -d .dfl/DeepFaceLab ]; then
1016
echo "Cloning DeepFaceLab"
11-
git clone --depth 1 "https://github.com/iperov/DeepFaceLab.git" .dfl/DeepFaceLab
17+
git clone --no-single-branch --depth 1 "https://github.com/chychkan/DeepFaceLab.git" .dfl/DeepFaceLab
18+
19+
if is_arm64; then
20+
(cd .dfl/DeepFaceLab; git checkout support-arm64)
21+
fi
1222
fi
1323

1424
if [ ! -d .dfl/env ]; then
@@ -17,14 +27,43 @@ fi
1727

1828
source .dfl/env/bin/activate
1929

30+
python -m pip install --upgrade pip
31+
2032
version=$(python -V | cut -f 2 -d ' ' | cut -f 1,2 -d .)
2133
reqs_file='requirements.txt'
2234

35+
version_suffix=''
2336
if [[ ! -z "$version" && -f "requirements_$version.txt" ]]; then
24-
reqs_file="requirements_$version.txt"
37+
version_suffix="_$version"
2538
fi
2639

40+
architecture_suffix=''
41+
if is_arm64 && [ -f "requirements${version_suffix}_arm64.txt" ]; then
42+
architecture_suffix="_arm64"
43+
fi
44+
45+
reqs_file="requirements${version_suffix}${architecture_suffix}.txt"
46+
2747
echo "Using $reqs_file for $(python -V)"
28-
pip install -r $reqs_file
48+
49+
if is_arm64; then
50+
if [[ -z "$(brew ls --versions hdf5)" ]]; then
51+
echo "ERROR: HDF5 needs to be installed to run DeepFaceLab on M1 chip."
52+
echo "You can install it with 'brew install hdf5'. For more details, see https://formulae.brew.sh/formula/hdf5"
53+
echo "Once it is installed, run ./scripts/0_setup.sh again"
54+
exit 1
55+
fi
56+
57+
cython_pkg="$(cat $reqs_file | grep -E 'cython==.+')"
58+
pip --no-cache-dir install "$cython_pkg"
59+
60+
numpy_pkg="$(cat $reqs_file | grep -E 'numpy==.+')"
61+
pip install "$numpy_pkg"
62+
63+
h5py_pkg="$(cat $reqs_file | grep -E 'h5py==.+')"
64+
HDF5_DIR="$(brew --prefix hdf5)" pip --no-cache-dir install --no-build-isolation "$h5py_pkg"
65+
fi
66+
67+
pip --no-cache-dir install -r $reqs_file
2968

3069
echo "Done."

0 commit comments

Comments
 (0)