Skip to content

Commit

Permalink
Remove plaidML support (#1325)
Browse files Browse the repository at this point in the history
* Remove PlaidML reference from readme files

* Remove AMD option from installers

* remove amd requirements and update setup.py

* remove plaidml test from CI workflow

* gpustats: remove plaidml backend

* plaid removals:
  - faceswap.py - python version check
  - setup.cfg - plaidml typing ignore
  - lib.keras_utils - All plaid code
  - lib.launcher.py - All plaidml checks and configuration

* remove tf2.2 specific code from GUI event reader

* lib.model - remove all plaidml implementations

* plugins.extract - remove plaidml code

* plugins.train remove plaidml code

* lib.convert - remove plaidml code

* tools.model: remove plaidml code

* Remove plaidML tests from unit tests

* remove plaidml_utils and docsting cleanups

* Remove plaidML refs from configs

* fix keras imports
  • Loading branch information
torzdf authored Jun 21, 2023
1 parent 82e927d commit 03f5c67
Show file tree
Hide file tree
Showing 90 changed files with 2,050 additions and 5,554 deletions.
18 changes: 5 additions & 13 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: ci/build
on:
push:
pull_request:
paths-ignore:
paths-ignore:
- docs/**
- "**/README.md"

Expand All @@ -15,18 +15,13 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9"]
backend: ["amd", "cpu"]
backend: ["cpu"]
include:
- kbackend: "plaidml.keras.backend"
backend: "amd"
- kbackend: "tensorflow"
backend: "cpu"
exclude:
- python-version: 3.9
backend: amd
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -50,14 +45,11 @@ jobs:
mypy .
- name: Simple Tests
run: |
if [ "${{ matrix.backend }}" == "amd" ] ; then echo "{\"PLAIDML_DEVICE_IDS\":[\"llvm_cpu.0\"],\"PLAIDML_EXPERIMENTAL\":true}" > ~/.plaidml; fi ;
echo "{\"PLAIDML_DEVICE_IDS\":[\"llvm_cpu.0\"],\"PLAIDML_EXPERIMENTAL\":true}" > ~/.plaidml;
FACESWAP_BACKEND="${{ matrix.backend }}" KERAS_BACKEND="${{ matrix.kbackend }}" py.test -v tests/;
- name: End to End Tests
run: |
FACESWAP_BACKEND="${{ matrix.backend }}" KERAS_BACKEND="${{ matrix.kbackend }}" python tests/simple_tests.py;
if [ "${{ matrix.backend }}" == "amd" ] ; then rm -f ~/.plaidml; fi ;
build_windows:
runs-on: windows-latest
strategy:
Expand All @@ -70,7 +62,7 @@ jobs:
- backend: "directml"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
Expand Down
12 changes: 1 addition & 11 deletions .install/linux/faceswap_setup_x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,12 @@ ask_version() {
# Ask which version of faceswap to install
while true; do
default=1
read -rp $'\e[36mSelect:\t1: NVIDIA\n\t2: AMD (ROCm)\n\t3: CPU\n\t4: AMD (PlaidML) - deprecated\n'"[default: $default]: "$'\e[97m' vers
read -rp $'\e[36mSelect:\t1: NVIDIA\n\t2: AMD (ROCm)\n\t3: CPU\n'"[default: $default]: "$'\e[97m' vers
vers="${vers:-${default}}"
case $vers in
1) VERSION="nvidia" ; break ;;
2) VERSION="rocm" ; break ;;
3) VERSION="cpu" ; break ;;
4) VERSION="amd" ; PYENV_VERSION="3.8" ; break ;;
* ) echo "Invalid selection." ;;
esac
done
Expand Down Expand Up @@ -281,11 +280,6 @@ faceswap_opts () {
latest graphics card drivers installed from the relevant vendor. Please select the version\
of Faceswap you wish to install."
ask_version
if [ $VERSION == "amd" ] ; then
warn "PlaidML support is deprecated and will be removed in a future update. If possible \
please consider using the ROCm version"
sleep 2
fi
if [ $VERSION == "rocm" ] ; then
warn "ROCm support is experimental. Please make sure that your GPU is supported by ROCm and that \
ROCm has been installed on your system before proceeding. Installation instructions: \
Expand Down Expand Up @@ -328,10 +322,6 @@ review() {
fi
echo " - Faceswap will be installed in '$DIR_FACESWAP'"
echo " - Installing for '$VERSION'"
if [ $VERSION == "amd" ] ; then
echo -e " \e[33m- Note: '$VERSION' is deprecated and will be removed in a\e[97m"
echo -e " \e[33m future update. Consider using the ROCm version.\e[97m"
fi
if [ $VERSION == "rocm" ] ; then
echo -e " \e[33m- Note: Please ensure that ROCm is supported by your GPU\e[97m"
echo -e " \e[33m and is installed prior to proceeding.\e[97m"
Expand Down
24 changes: 6 additions & 18 deletions .install/windows/install.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ InstallDir $PROFILE\faceswap
# Install cli flags
!define flagsConda "/S /RegisterPython=0 /AddToPath=0 /D=$PROFILE\MiniConda3"
!define flagsRepo "--depth 1 --no-single-branch ${wwwRepo}"
!define flagsEnv "-y python=3."
!define flagsEnv "-y python=3.9"

# Folders
Var ProgramData
Expand Down Expand Up @@ -129,32 +129,25 @@ Function pgPrereqCreate
${NSD_CreateLabel} 10% $lblPos% 80% 14u "Faceswap"
Pop $0

StrCpy $lblPos 50
StrCpy $lblPos 46
# Info Custom Options
${NSD_CreateGroupBox} 5% 40% 90% 120% "Custom Items"
${NSD_CreateGroupBox} 5% 40% 90% 60% "Custom Items"
Pop $0
${NSD_CreateRadioButton} 10% $lblPos% 27% 11u "Setup for NVIDIA GPU"
Pop $ctlRadio
${NSD_AddStyle} $ctlRadio ${WS_GROUP}
nsDialogs::SetUserData $ctlRadio "nvidia"
${NSD_OnClick} $ctlRadio RadioClick
${NSD_CreateRadioButton} 50% $lblPos% 30% 11u "Setup for DirectML"
${NSD_CreateRadioButton} 40% $lblPos% 25% 11u "Setup for DirectML"
Pop $ctlRadio
nsDialogs::SetUserData $ctlRadio "directml"
${NSD_OnClick} $ctlRadio RadioClick

intOp $lblPos $lblPos + 10

${NSD_CreateRadioButton} 10% $lblPos% 25% 11u "Setup for CPU"
${NSD_CreateRadioButton} 70% $lblPos% 20% 11u "Setup for CPU"
Pop $ctlRadio
nsDialogs::SetUserData $ctlRadio "cpu"
${NSD_OnClick} $ctlRadio RadioClick
${NSD_CreateRadioButton} 50% $lblPos% 40% 11u "Setup for AMD (deprecated)"
Pop $ctlRadio
nsDialogs::SetUserData $ctlRadio "amd"
${NSD_OnClick} $ctlRadio RadioClick

intOp $lblPos $lblPos + 12
intOp $lblPos $lblPos + 10

${NSD_CreateLabel} 10% $lblPos% 80% 10u "Environment Name (NB: Existing envs with this name will be deleted):"
pop $0
Expand Down Expand Up @@ -404,11 +397,6 @@ Function SetEnvironment

CreateEnv:
SetDetailsPrint listonly
${If} $setupType == "amd"
StrCpy $0 "${flagsEnv}8"
${else}
StrCpy $0 "${flagsEnv}9"
${EndIf}
ExecDos::exec /NOUNLOAD /ASYNC /DETAILED "$\"$dirConda\scripts\activate.bat$\" && conda create $0 -n $\"$envName$\" && conda deactivate"
pop $0
ExecDos::wait $0
Expand Down
2 changes: 0 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ The type of computations that the process does are well suited for graphics card
- DirectX 12 AMD GPUs are supported on Windows through DirectML.
- More modern AMD GPUs are supported on Linux through ROCm.
- M-series Macs are supported through Tensorflow-Metal
- OpenCL 1.2 support through PlaidML is deprecated and will be removed in a future update
- If using an Nvidia GPU, then it needs to support at least CUDA Compute Capability 3.5. (Release 1.0 will work on Compute Capability 3.0)
To see which version your GPU supports, consult this list: https://developer.nvidia.com/cuda-gpus
Desktop cards later than the 7xx series are most likely supported.
Expand Down Expand Up @@ -142,7 +141,6 @@ If you are using an Nvidia card make sure you have the correct versions of Cuda/
- Install tkinter (required for the GUI) by typing: `conda install tk`
- Install requirements:
- For Nvidia GPU users: `pip install -r ./requirements/requirements_nvidia.txt`
- For AMD GPU users: `pip install -r ./requirements/requirements_amd.txt`
- For CPU users: `pip install -r ./requirements/requirements_cpu.txt`

## Running faceswap
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ We are very troubled by the fact that FaceSwap can be used for unethical and dis
# How To setup and run the project
FaceSwap is a Python program that will run on multiple Operating Systems including Windows, Linux, and MacOS.

See [INSTALL.md](INSTALL.md) for full installation instructions. You will need a modern GPU with CUDA support for best performance. AMD GPUs are partially supported.
See [INSTALL.md](INSTALL.md) for full installation instructions. You will need a modern GPU with CUDA support for best performance. Many AMD GPUs are supported through DirectML (Windows) and ROCm (Linux).

# Overview
The project has multiple entry points. You will have to:
Expand Down
4 changes: 0 additions & 4 deletions faceswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@

from lib.cli import args as cli_args # pylint:disable=wrong-import-position
from lib.config import generate_configs # pylint:disable=wrong-import-position
from lib.utils import get_backend # pylint:disable=wrong-import-position

# LOCALES
_LANG = gettext.translation("faceswap", localedir="locales", fallback=True)
_ = _LANG.gettext

if sys.version_info < (3, 7):
raise ValueError("This program requires at least python3.7")
if get_backend() == "amd" and sys.version_info >= (3, 9):
raise ValueError("The AMD version of Faceswap cannot run on versions of Python higher "
"than 3.8")


_PARSER = cli_args.FullHelpArgumentParser()
Expand Down
46 changes: 3 additions & 43 deletions lib/cli/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from lib.gpu_stats import set_exclude_devices, GPUStats
from lib.logger import crash_log, log_setup
from lib.utils import (deprecation_warning, FaceswapError, get_backend, get_tf_version,
from lib.utils import (FaceswapError, get_backend, get_tf_version,
safe_shutdown, set_backend, set_system_verbosity)

if TYPE_CHECKING:
Expand Down Expand Up @@ -99,7 +99,6 @@ def _test_for_tf_version(self) -> None:
FaceswapError
If Tensorflow is not found, or is not between versions 2.4 and 2.9
"""
amd_ver = (2, 2)
directml_ver = rocm_ver = (2, 10)
min_ver = (2, 7)
max_ver = (2, 10)
Expand All @@ -122,18 +121,14 @@ def _test_for_tf_version(self) -> None:

tf_ver = get_tf_version()
backend = get_backend()
if backend != "amd" and tf_ver < min_ver:
if tf_ver < min_ver:
msg = (f"The minimum supported Tensorflow is version {min_ver} but you have version "
f"{tf_ver} installed. Please upgrade Tensorflow.")
self._handle_import_error(msg)
if backend != "amd" and tf_ver > max_ver:
if tf_ver > max_ver:
msg = (f"The maximum supported Tensorflow is version {max_ver} but you have version "
f"{tf_ver} installed. Please downgrade Tensorflow.")
self._handle_import_error(msg)
if backend == "amd" and tf_ver != amd_ver:
msg = (f"The supported Tensorflow version for AMD cards is {amd_ver} but you have "
f"version {tf_ver} installed. Please install the correct version.")
self._handle_import_error(msg)
if backend == "directml" and tf_ver != directml_ver:
msg = (f"The supported Tensorflow version for DirectML cards is {directml_ver} but "
f"you have version {tf_ver} installed. Please install the correct version.")
Expand Down Expand Up @@ -283,42 +278,7 @@ def _configure_backend(self, arguments: "argparse.Namespace") -> None:

if GPUStats().exclude_all_devices:
msg = "Switching backend to CPU"
if get_backend() == "amd":
msg += (". Using Tensorflow for CPU operations.")
os.environ["KERAS_BACKEND"] = "tensorflow"
set_backend("cpu")
logger.info(msg)

logger.debug("Executing: %s. PID: %s", self._command, os.getpid())

if get_backend() == "amd" and not self._setup_amd(arguments):
safe_shutdown(got_error=True)

@classmethod
def _setup_amd(cls, arguments: "argparse.Namespace") -> bool:
""" Test for plaidml and perform setup for AMD.
Parameters
----------
arguments: :class:`argparse.Namespace`
The command line arguments passed to Faceswap.
Returns
-------
bool
``True`` if AMD was set up succesfully otherwise ``False``
"""
logger.debug("Setting up for AMD")
if platform.system() == "Windows":
deprecation_warning("The AMD backend",
additional_info="Please consider re-installing using the "
"'DirectML' backend")
try:
import plaidml # noqa pylint:disable=unused-import,import-outside-toplevel
except ImportError:
logger.error("PlaidML not found. Run `pip install plaidml-keras` for AMD support")
return False
from lib.gpu_stats import setup_plaidml # pylint:disable=import-outside-toplevel
setup_plaidml(arguments.loglevel, arguments.exclude_gpus)
logger.debug("setup up for PlaidML")
return True
2 changes: 0 additions & 2 deletions lib/gpu_stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
from .nvidia_apple import NvidiaAppleStats as GPUStats # type:ignore
elif backend == "nvidia":
from .nvidia import NvidiaStats as GPUStats # type:ignore
elif backend == "amd":
from .amd import AMDStats as GPUStats, setup_plaidml # type:ignore
elif backend == "apple_silicon":
from .apple_silicon import AppleSiliconStats as GPUStats # type:ignore
elif backend == "directml":
Expand Down
Loading

0 comments on commit 03f5c67

Please sign in to comment.