Page 1 of 1

Setting environment variables for Tensorflow (on Linux)

Posted: Thu Mar 25, 2021 11:45 pm
by rmaurice

Hi,

I seem to have trouble getting my small Nvidia GT710 card getting to do even menial work on Faceswap on Linux. My setup has been made today on Debian buster using the Linux install script as described on the Download page. The card is successfully detected as the drivers are properly installed. But when I start extraction, Tensorflow automatically switches to CPU because:

Code: Select all

2021-03-26 00:35:00.726016: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561]
Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GT 710 computeCapability: 3.5
coreClock: 0.954GHz coreCount: 1 deviceMemorySize: 1.96GiB deviceMemoryBandwidth: 13.41GiB/s

...

2021-03-26 00:35:02.323817: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1688] Ignoring visible gpu device
 (device: 0, name: GeForce GT 710, pci bus id: 0000:01:00.0, compute capability: 3.5)
 with core count: 1. The minimum required count is 4.
 You can adjust this requirement with the env var TF_MIN_GPU_MULTIPROCESSOR_COUNT.

The card has 192 Cuda cores, so I think there may be a bug in detection here. Anyway, as a workaround, I have been trying to set up TF_MIN_GPU_MULTIPROCESSOR_COUNT in my .bashrc file to 1, but it is not taken into account. I have tried modifying faceswap.py and add os.environ["TF_MIN_GPU_MULTIPROCESSOR_COUNT"] = "1" at startup, but it is not taken into account either. Of course I also did the usual close/restart terminal etc.

I wonder how can I set environment variables so that Tensorflow takes them into account in the context of an execution from Faceswap's GUI. Any help welcome!


Re: Setting environment variables for Tensorflow (on Linux)

Posted: Fri Mar 26, 2021 9:27 am
by abigflea

I'm pretty sure that GPU is not going to be supported.
Even if it was, a GT 710 is going to be excruciatingly slow.


Re: Setting environment variables for Tensorflow (on Linux)

Posted: Fri Mar 26, 2021 9:33 am
by torzdf

In the first instance, run Faceswap in VERBOSE mode and you should get a message from Tensorflow telling you why the GPU is not being used.

You can set an env variable by doing:

VARIABLE=variable ; python faceswap.py ...


Re: Setting environment variables for Tensorflow (on Linux)

Posted: Sat Mar 27, 2021 7:05 pm
by algeron

I had a similar problem on Windows. I was able to get it working by editing the hardcoded value in \lib\cli\launcher.py


Re: Setting environment variables for Tensorflow (on Linux)

Posted: Sun Mar 28, 2021 11:50 am
by torzdf

I would say that editing the code directly is rarely the best idea, as it can prevent Faceswap from updating.


Re: Setting environment variables for Tensorflow (on Linux)

Posted: Sun Mar 28, 2021 7:27 pm
by rmaurice
algeron wrote: Sat Mar 27, 2021 7:05 pm

I had a similar problem on Windows. I was able to get it working by editing the hardcoded value in \lib\cli\launcher.py

Thanks [mention]algeron[/mention]!

Those are lines 61-62 of launcher.py:

Code: Select all

    # Ensure tensorflow doesn't pin all threads to one core when using Math Kernel Library
    os.environ["TF_MIN_GPU_MULTIPROCESSOR_COUNT"] = "4"

Setting this to "1" does the trick and the computations are sent to the GPU.

[mention]torzdf[/mention]: is it possible to move this hardcoded setting into a user-configurable one, maybe in an "experimental" section?


Re: Setting environment variables for Tensorflow (on Linux)

Posted: Mon Mar 29, 2021 11:48 am
by torzdf

Honestly? I'd need to investigate why that hard coded value was put in in the first place. My preference would just be to remove it altogether, as I am not particularly a fan of setting environment variables inside applications.