Extract: ValueError: Unable to import backend : plaidml.keras.backend

The Extraction process failing on you, and you aren't getting an error back with clear instructions? Tell us about it here


Forum rules

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

This forum is for reporting errors with the Extraction process. If you want to get tips, or better understand the Extract process, then you should look in the Extract Discussion forum.

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

Locked
User avatar
mongplea
Posts: 16
Joined: Fri Apr 24, 2020 3:22 pm

Extract: ValueError: Unable to import backend : plaidml.keras.backend

Post by mongplea »

I deleted and reinstalled the face swap several times. However, due to the plaidml error below, extract and train are not possible.
I am using RTX2070 super and did not install Plaidml because I chose NVIDIA GPU when installing facewap.

I followed the steps below.
https://github.com/deepfakes/faceswap/b ... INSTALL.md

show that
I didn't not install Plaidml

Code: Select all

(base) C:\Users\M\faceswap>pip uninstall plaidml
WARNING: Skipping plaidml as it is not installed.

I wonder if it's the problem with my Cuda and CudNN version.

I attached output system information log....

Code: Select all

Loading...
Setting Faceswap backend to NVIDIA
04/26/2020 18:20:28 INFO     Log level set to: INFO
04/26/2020 18:20:31 INFO     Output Directory: C:\faceswap_test\test_3\out_extract\test

04/26/2020 18:20:31 INFO     Loading Detect from S3Fd plugin...
04/26/2020 18:20:34 ERROR    Got Exception on main handler:
Traceback (most recent call last):
File "C:\Users\M\MiniConda3\lib\site-packages\keras\backend\__init__.py", line 93, in <module>
backend_module = importlib.import_module(_BACKEND)
File "C:\Users\M\MiniConda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'plaidml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\M\faceswap\lib\cli\launcher.py", line 154, in execute_script
process = script(arguments)
File "C:\Users\M\faceswap\scripts\extract.py", line 63, in __init__
normalize_method=normalization)
File "C:\Users\M\faceswap\plugins\extract\pipeline.py", line 92, in __init__
self._detect = self._load_detect(detector, rotate_images, min_size, configfile)
File "C:\Users\M\faceswap\plugins\extract\pipeline.py", line 520, in _load_detect
detector = PluginLoader.get_detector(detector_name)(rotation=rotation,
File "C:\Users\M\faceswap\plugins\plugin_loader.py", line 40, in get_detector
return PluginLoader._import("extract.detect", name, disable_logging)
File "C:\Users\M\faceswap\plugins\plugin_loader.py", line 163, in _import
module = import_module(mod)
File "C:\Users\M\MiniConda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\M\faceswap\plugins\extract\detect\s3fd.py", line 11, in <module>
import keras
File "C:\Users\M\MiniConda3\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Users\M\MiniConda3\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:\Users\M\MiniConda3\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "C:\Users\M\MiniConda3\lib\site-packages\keras\backend\__init__.py", line 108, in <module>
raise ValueError('Unable to import backend : ' + str(_BACKEND))
ValueError: Unable to import backend : plaidml.keras.backend
04/26/2020 18:20:34 CRITICAL An unexpected crash has occurred. Crash report written to 'C:\Users\M\faceswap\crash_report.2020.04.26.182031781921.log'. You MUST provide this file if seeking assistance. Please verify you are running the latest version of faceswap before reporting

and when I run python setup.py
show that log

Code: Select all

Enable  CUDA? [Y/n] y
INFO    CUDA Enabled
INFO    Skipping Cuda/cuDNN checks for Conda install
[b]INFO    1. Install PIP requirements
        You may want to execute `chcp 65001` in cmd line
        to fix Unicode issues on Windows when installing dependencies
INFO    Faceswap config written to: C:\Users\M\faceswap\config\.faceswap[/b]
Please ensure your System Dependencies are met. Continue? [y/N] y
INFO    Installing Required Python Packages. This may take some time...
INFO    Installing git+https://github.com/deepfakes/nvidia-ml-py3.git
INFO    All python3 dependencies are met.
        You are good to go.

    Enter:  'python faceswap.py -h' to see the options
            'python faceswap.py gui' to launch the GUI

Is that the problem?

Attachments
sys_info.txt
(14.09 KiB) Downloaded 231 times
by torzdf » Tue Apr 28, 2020 1:22 am

Found it!

KERAS_BACKEND=plaidml.keras.backend

Go and delete this environment variable (KERAS_BACKEND)

https://support.foundry.com/hc/en-us/ar ... -variables

Go to full post
User avatar
torzdf
Posts: 2649
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 128 times
Been thanked: 623 times

Re: Extract error

Post by torzdf »

Ok. Somehow, in a previous install (of Faceswap or something else) it looks like you have managed to set the Keras backend to plaidML.

You should be able to change this by navigating to the file:
%USERPROFILE%/.keras/keras.json

And changing the backend value to tensorflow (i.e: "backend": "tensorflow",)

You should also uninstall your system installed Cuda as it will conflict with the version in Conda

My word is final

User avatar
mongplea
Posts: 16
Joined: Fri Apr 24, 2020 3:22 pm

Re: Extract error

Post by mongplea »

torzdf wrote: Sun Apr 26, 2020 10:35 am

Ok. Somehow, in a previous install (of Faceswap or something else) it looks like you have managed to set the Keras backend to plaidML.

You should be able to change this my navigating to the file:
%USERPROFILE%/.keras/keras.json

And changing the backend value to tensorflow (i.e: "backend": "tensorflow",)

You should also uninstall your system installed Cuda as it will conflict with the version in Conda

Thank you

when I checked keras.json
"backend": "tensorflow"

So now I uninsatll cuda 10.2 and re-install cuda 10.0

I will try again when the installation is complete

User avatar
torzdf
Posts: 2649
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 128 times
Been thanked: 623 times

Re: Extract error

Post by torzdf »

You shouldn't install Cuda at all. Completely remove if from your system.

Faceswap installs a local version inside your Conda Faceswap environment. Any system version is likely to cause conflicts.

My word is final

User avatar
mongplea
Posts: 16
Joined: Fri Apr 24, 2020 3:22 pm

Re: Extract error

Post by mongplea »

torzdf wrote: Sun Apr 26, 2020 11:35 am

You shouldn't install Cuda at all. Completely remove if from your system.

Faceswap installs a local version inside your Conda Faceswap environment. Any system version is likely to cause conflicts.

Oh! No!
maybe I will re-install faceswap...

User avatar
torzdf
Posts: 2649
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 128 times
Been thanked: 623 times

Re: Extract error

Post by torzdf »

This isn't your issue, but it is likely to cause you problems in the future.

Your issue is that Keras thinks it should be using plaidML as the backend, when it should in fact be using tensorflow

My word is final

User avatar
mongplea
Posts: 16
Joined: Fri Apr 24, 2020 3:22 pm

Re: Extract error

Post by mongplea »

torzdf wrote: Sun Apr 26, 2020 1:42 pm

This isn't your issue, but it is likely to cause you problems in the future.

Your issue is that Keras thinks it should be using plaidML as the backend, when it should in fact be using tensorflow

Unfortunately, the same error is repeated over and over and over again.
When checking the Keras.json file Tensorflow is working

Code: Select all

{
    "floatx": "float32",
    "epsilon": 1e-07,
    "backend": "tensorflow",
    "image_data_format": "channels_last"
}

Code: Select all

Setting Faceswap backend to NVIDIA
04/27/2020 01:23:09 INFO     Log level set to: INFO
04/27/2020 01:23:12 INFO     Output Directory: C:\faceswap_test\test_3\out_extract\test

04/27/2020 01:23:13 INFO     Loading Detect from S3Fd plugin...
04/27/2020 01:23:16 ERROR    Got Exception on main handler:
Traceback (most recent call last):
File "C:\Users\M\anaconda3\envs\faceswap\lib\site-packages\keras\backend\__init__.py", line 93, in <module>
backend_module = importlib.import_module(_BACKEND)
File "C:\Users\M\anaconda3\envs\faceswap\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'plaidml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\M\faceswap\lib\cli\launcher.py", line 154, in execute_script
process = script(arguments)
File "C:\Users\M\faceswap\scripts\extract.py", line 63, in __init__
normalize_method=normalization)
File "C:\Users\M\faceswap\plugins\extract\pipeline.py", line 92, in __init__
self._detect = self._load_detect(detector, rotate_images, min_size, configfile)
File "C:\Users\M\faceswap\plugins\extract\pipeline.py", line 520, in _load_detect
detector = PluginLoader.get_detector(detector_name)(rotation=rotation,
File "C:\Users\M\faceswap\plugins\plugin_loader.py", line 40, in get_detector
return PluginLoader._import("extract.detect", name, disable_logging)
File "C:\Users\M\faceswap\plugins\plugin_loader.py", line 163, in _import
module = import_module(mod)
File "C:\Users\M\anaconda3\envs\faceswap\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\M\faceswap\plugins\extract\detect\s3fd.py", line 11, in <module>
import keras
File "C:\Users\M\anaconda3\envs\faceswap\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Users\M\anaconda3\envs\faceswap\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:\Users\M\anaconda3\envs\faceswap\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "C:\Users\M\anaconda3\envs\faceswap\lib\site-packages\keras\backend\__init__.py", line 108, in <module>
raise ValueError('Unable to import backend : ' + str(_BACKEND))
ValueError: Unable to import backend : plaidml.keras.backend
04/27/2020 01:23:16 CRITICAL An unexpected crash has occurred. Crash report written to 'C:\Users\M\faceswap\crash_report.2020.04.27.012313358263.log'. You MUST provide this file if seeking assistance. Please verify you are running the latest version of faceswap before reporting

and is this correctly setting?
I did not install other cuda and cudnn.

============ System Information ============
encoding:            cp949
git_branch:          master
git_commits:         d5f42b6 Bugfix: lib.gui.project - Reset invalid choices to default if an invalid choice is discovered when loading a .fsw file
gpu_cuda:            No global version found. Check Conda packages for Conda Cuda
gpu_cudnn:           No global version found. Check Conda packages for Conda cuDNN
gpu_devices:         GPU_0: GeForce RTX 2070 SUPER
gpu_devices_active:  GPU_0
gpu_driver:          445.87
gpu_vram:            GPU_0: 8192MB
os_machine:          AMD64
os_platform:         Windows-10-10.0.18362-SP0
os_release:          10
py_command:          faceswap.py gui
py_conda_version:    conda 4.8.2
py_implementation:   CPython
py_version:          3.7.7
py_virtual_env:      True
sys_cores:           16
sys_processor:       AMD64 Family 23 Model 1 Stepping 1, AuthenticAMD
sys_ram:             Total: 16333MB, Available: 10190MB, Used: 6142MB, Free: 10190MB
User avatar
torzdf
Posts: 2649
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 128 times
Been thanked: 623 times

Re: Extract error

Post by torzdf »

In the past, you have installed something somewhere that has set a Keras backend to plaidml.... Where this is, I do not know, as the file I got you to edit SHOULD be the Keras config file.

When I'm back at my PC I will check for a python command to change the keras backend, which will hopefully fix the issue.

My word is final

User avatar
mongplea
Posts: 16
Joined: Fri Apr 24, 2020 3:22 pm

Re: Extract error

Post by mongplea »

torzdf wrote: Sun Apr 26, 2020 9:57 pm

In the past, you have installed something somewhere that has set a Keras backend to plaidml.... Where this is, I do not know, as the file I got you to edit SHOULD be the Keras config file.

When I'm back at my PC I will check for a python command to change the keras backend, which will hopefully fix the issue.

I checked the Keras.json file of C:\Users\M\.Keras.
{
"floatx": "float32",
"epsilon": 1e-07,
"backend": "tensorflow",
"image_data_format": "channels_last"
}

when you will find check for a python command to change the keras backend
tell me

User avatar
torzdf
Posts: 2649
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 128 times
Been thanked: 623 times

Re: Extract error

Post by torzdf »

Can you open up an Anaconda Prompt:

Start > Anaconda Prompt

then issue the following commands and paste the output:

Code: Select all

conda activate faceswap
set

My word is final

User avatar
mongplea
Posts: 16
Joined: Fri Apr 24, 2020 3:22 pm

Re: Extract error

Post by mongplea »

torzdf wrote: Mon Apr 27, 2020 9:06 am

Can you open up an Anaconda Prompt:

Start > Anaconda Prompt

then issue the following commands and paste the output:

Code: Select all

conda activate faceswap
set

Thank you.
My reply was late.

I pasted the output

Please check the Issue

Code: Select all

(base) C:\Users\M>conda activate faceswap

(faceswap) C:\Users\M>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\M\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=DESKTOP-OOKE9K6
ComSpec=C:\WINDOWS\system32\cmd.exe
CONDA_DEFAULT_ENV=faceswap
CONDA_EXE=C:\Users\M\anaconda3\Scripts\conda.exe
CONDA_PREFIX=C:\Users\M\anaconda3\envs\faceswap
CONDA_PREFIX_1=C:\Users\M\anaconda3
CONDA_PROMPT_MODIFIER=(faceswap)
CONDA_PYTHON_EXE=C:\Users\M\anaconda3\python.exe
CONDA_SHLVL=2
DriverData=C:\Windows\System32\Drivers\DriverData
FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
FPS_BROWSER_USER_PROFILE_STRING=Default
HOMEDRIVE=C:
HOMEPATH=\Users\M
KERAS_BACKEND=plaidml.keras.backend
LOCALAPPDATA=C:\Users\M\AppData\Local
LOGONSERVER=\\DESKTOP-OOKE9K6
NUMBER_OF_PROCESSORS=16
NVTOOLSEXT_PATH=C:\Program Files\NVIDIA Corporation\NvToolsExt\
OneDrive=C:\Users\M\OneDrive
OneDriveConsumer=C:\Users\M\OneDrive
OS=Windows_NT
Path=C:\Users\M\anaconda3\envs\faceswap;C:\Users\M\anaconda3\envs\faceswap\Library\mingw-w64\bin;C:\Users\M\anaconda3\envs\faceswap\Library\usr\bin;C:\Users\M\anaconda3\envs\faceswap\Library\bin;C:\Users\M\anaconda3\envs\faceswap\Scripts;C:\Users\M\anaconda3\envs\faceswap\bin;C:\Users\M\anaconda3\condabin;c:\program files (x86)\common files\oracle\java\javapath;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0;c:\windows\system32\openssh;c:\program files\putty;c:\program files (x86)\streamlink\bin;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0;c:\windows\system32\openssh;c:\program files\nvidia corporation\nvidia nvdlisr;c:\program files\nvidia corporation\nsight compute 2019.5.0;c:\ffmpeg-4.2.2-win64-static\bin;c:\program files\cmake\bin;c:\program files (x86)\windows kits\10\windows performance toolkit;c:\program files\git\cmd;c:\faceswap_test\ffmpeg-20200422-2e38c63-win64-static\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Users\M\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Bandizip;C:\Program Files (x86)\SoftForum\XecureHSM;.
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=AMD64 Family 23 Model 1 Stepping 1, AuthenticAMD
PROCESSOR_LEVEL=23
PROCESSOR_REVISION=0101
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=(faceswap) $P$G
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\Users\M\AppData\Local\Temp
TMP=C:\Users\M\AppData\Local\Temp
USERDOMAIN=DESKTOP-OOKE9K6
USERDOMAIN_ROAMINGPROFILE=DESKTOP-OOKE9K6
USERNAME=M
USERPROFILE=C:\Users\M
VBOX_HWVIRTEX_IGNORE_SVM_IN_USE=1
VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
windir=C:\WINDOWS
User avatar
torzdf
Posts: 2649
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 128 times
Been thanked: 623 times

Re: Extract error

Post by torzdf »

Found it!

KERAS_BACKEND=plaidml.keras.backend

Go and delete this environment variable (KERAS_BACKEND)

https://support.foundry.com/hc/en-us/ar ... -variables

My word is final

User avatar
mongplea
Posts: 16
Joined: Fri Apr 24, 2020 3:22 pm

Re: Extract error

Post by mongplea »

torzdf wrote: Tue Apr 28, 2020 1:22 am

Found it!

KERAS_BACKEND=plaidml.keras.backend

Go and delete this environment variable (KERAS_BACKEND)

https://support.foundry.com/hc/en-us/ar ... -variables

Thanks
The problem seems to have been solved.
Thank you so much for your help

Locked