Google Cloud FakeApp Tutorial

How to Create DeepFakes with Google Cloud GPU Services

If you want to use the FakeApp program for Windows but lack the necessary hardware, Google Cloud offers GPU services. This tutorial will show you how to get started making deepfakes in the cloud.

IMPORTANT WARNING

Google Clouds will charge you for every hour of time that you use their services. If you do not properly terminate a cloud instance when you are done, you may end up with a very large bill at the end of the month. Proceed at your own risk and make sure you know what you are doing!

Should you use Google Cloud GPU Services?

The price of cloud computing

Google Cloud GPU services are not particularly cheap. A fairly modest setup will cost at least $200-300 per month if you use it 24/7. You can take several steps to reduce the cost. When you are not actively using your cloud instance, you can stop it. You will still pay a small fee to maintain your instance’s configuration and data, but if your virtual machine is only used half the time, you could stretch it out to $100-$200 a month, for example.

Google is also currently offering $300 of free credit to new users. While you must upgrade your account to a paid one to access GPU services, you will still receive the $300 credit. This is enough to play around with Google’s services for a month and test making videos. Please do not abuse Google’s generosity. Google Cloud Services supports commercial clients, but there are also many researchers and students who rely on it for important purposes like biomedical research. Please keep this in mind and pay appropriately for Google Cloud Services if you use it regularly.

Buying a new computer or using the cloud

You should also consider the financial cost in comparison to building a new computer or upgrading your current one. If you are building a computer from scratch in order to run the FakeApp program, you might spend at least $1000 for a mid-tier system. There is also the electricity cost if you are running your computer continuously. If you plan to make deepfake videos for longer than several months, you might be better off building or buying a new computer.

If you only plan to make deepfakes occasionally, or as a one-time thing, Google Cloud Services might be a good choice.

Preparing your Google Cloud account for GPU services

Sign-up for a free trial

The first thing you need to do is sign up. Use Google’s link HERE to get $300 of free credit in the process.

cloud 0

Click the button and fill out your details to sign up. You must have a Google account or create one.

Once you enter your details, you will be brought to a generic welcome page.

cloud 1

Click on “Create an empty project”.

cloud 2

If you are using a pre-existing account you may already have some “projects” from other Google activities. You should pick “Create” and name your new project.

Upgrade to paid services to access GPUs

After you are done creating your project, you will next need to upgrade your account. You currently should have $300 of free credit to use on Google Cloud. However, this free trial does not include access to GPU services. To do this, you will need to click the “Upgrade” button. It can be somewhat hidden. If you see the banner across the top of your screen asking you to upgrade, click it.

cloud 3

Otherwise, click on the menu bars in the upper left corner, and then select “Billing”. You should see the request to upgrade in the upper right hand corner.

cloud 4

Click on “Upgrade” to proceed. Confirm and check your billing information to proceed.

Request a GPU quota

UDPATE: Some users are reporting that Google is requesting a $35 prepayment to get the GPU quota approved. Whether this depends on the country of origin or other account properties is unknown.

Even though you have an upgraded account, you still need to manually request an increase in your GPU quota, which is currently set at zero for all zones. The quota is determined separately for each zone, so you will need to pick the one you want, and then request a quota increase.

Only a limited number of zones offer GPUs. See this page to find the zone that is geographically closest to you. Different zones have slightly different GPU pricing, but you probably want to reduce your latency when accessing your instances, so pick one close to you.

You have a choice of the Tesla K80 or P100 GPUs. While the P100 is more powerful, the K80 is about one-third the price. You may want to select the cheaper K80 for your first instances while you test things out. You can always go back and create a P100 instance later.

Now that you have selected a zone offering your GPU of choice, the K80, For example, perhaps I decide that I want the asia-east1-a zone.

cloud 7

Click on the Menu bar in the upper left again. Select “Compute Engine” and from the sub-menu, select “Quotas”.

You will see a very long list of all possible quotas.

cloud 8

 

To narrow down the list, restrict the quotas to your zone of interest using the pulldown menu “Region” in the upper right part of the screen. In this example, I am selecting asia-east1, which corresponds to my earlier choice. You can ignore the “a, b, c, etc.” portions of the zone names on this page.

cloud 9

Scroll down through the list, or hit Ctrl+F in Chrome to find the NVIDIA K80 GPUs quota. Check that line. Then go to the top of the page and click the button “EDIT QUOTAS”.

You should request just one GPU, since the FakeApp cannot take advantage of more than one GPU, and you should start with only one instance. You will need to enter some justification. After you submit your request, you will need to wait until your quota is approved. This took me less than one minute, and others have generally reported five minutes or less to hear a response.

After you are approved, you are now ready to deploy your GPU instance.

Installing FakeApp on Google Cloud

Creating you first GPU instance

We now need to create our first virtual machine in order to install FakeApp on it.

cloud 5

Go back to your Google Cloud console and click on the menu again. Select “Compute Engine”, and in the sub-menu select “VM instances”.

cloud 6

If this is your first instance, you may see a message like the above. Click “Create” to continue.

cloud 10

You now need to fill in the details of your VM instance. You can leave the name as the default. Under “Zone”, be sure to pick the same zone as your GPU quota request. Under “Machine type” you can select different configurations. I would suggest something like 2 vCPUs and 7.5 GB memory as a good starting point. (UPDATE: If you want to train 2000 images or more for each face at once,  you should use around 16 GB RAM or more.) Adding more resources will increase the cost of your VM instance.

Under “Boot disk” select Windows Server 2016. You have the choice of SSD or regular persistent disk, with a minimum size of 50 GB. You can choose either for your first instance. I ended up going with the SSD, which is only slightly more expensive.

We still need to add the GPU. Under the “Machine type” heading, click “Customize”.

cloud 11

Now click on “GPUs” to expand the menu.

cloud 12

Set the number of GPUs to “1” and select your GPU (in this case, the NVIDIA Tesla K80).

cloud 13

Check allow HTTP and HTTPS traffic. Then, change any other settings you like and click “Create”. The upper right corner will give you a monthly cost. If you use the setting here, the cost should be around $350-$375 per month. You can reduce the cost by about $100 per month by making your instance “Preemptible”. Preemptible instances can be terminated at any time by Google if someone else needs the resource. They also cannot run for more than 24 hours at a time. You can read about them here. I would just start with a non-preemptible instance to begin, but the choice is yours. If you want a preemptible instance, click on the “Management, disks, networking, SSH keys” menu above to expand options, then select the Preemptible option you desire.

cloud 14

After you create you instance, it may take several minutes for it to be ready to use. You will then see a summary of your instances. Your VM instance is now ready to use.

Connecting to your VM instance

You will need to connect to your instance using a Remote Desktop Protocol (RDP). If you are using Windows, you have a great RDP client already on your home computer. Otherwise, you will need to use another client. The rest of the tutorial will assume you are using Windows on your home computer.

cloud 15

Click on the button next to “RDP” and select “Set Windows password”.

cloud 16

You need to pick a username. Your Google username will appear here as your default. You now need to click the “SET” button to generate a new password to access your Windows VM instance.

Write down or copy the password that you are given.

If the SET button shows moving dots but nothing happens, try these steps:

  • Make sure you disable any adblockers.
  • Clear cookies, close your browser, reopen your browser, and try again.
  • Try a different browser. Some users of Chrome or Firefox report occasional issues with this step.

Go back to the RDP button above and click “Download the RDP file”.

cloud 17

Press the Windows button or click the search icon, then type “remote desktop connection”. Click on Remote Desktop Connection to run it.

cloud 18

Under “Connection settings”, click “Open”. Load your previously saved RDP file. This will auto-fill your settings.

Note that your IP address may change if you you stop your instance unless you have applied for a static IP for your instance. If you cannot connect, re-download a fresh RDP file.

The simplest way to transfer files between your home computer and your Windows VM instance is to link your home computer’s hard drive.

cloud 18

Click on the Local Resources tab. Under the “Local devices and resources” section, click “More”.

cloud 20

Open up the “Drives” menu and select which drive you would like to share with your VM instance. Click Okay.

Finally, click the “Connect” button. Enter you password and you should be connected to your Windows VM instance.

DeepFakes software installation

Most of the software installation instructions are identical to a normal Windows installation, so take a look at the original tutorial for detailed steps.

Here are a few tips specific for your Windows VM instance.

cloud 21

You can transfer files back and forth between your computer and VM instance using the shared hard drive that you selected above. Simply open up Explorer and select your file. In the figure above, the directory is “D on Name of computer“.

Note that your RDP connection is limited by the network upload and download speeds. When you are uploading files, you may experience severe lag on the order of 10 seconds or more. Also, when you click on a directory from your hard drive, if there are many files, it will take a long time to open that directory and list all files, during which RDP will lag.

I suggest that you create a directory on your home computer’s local drive that contains nothing but the few files that you need to transfer. You may want to zip any large directories that you need to transfer. The Windows VM instance comes with unzipping software. While transferring files, just wait until it is over.

While you can access the internet from within your Windows VM, the security settings can be a bit cumbersome for beginners. I would suggest that you simply prepare all your files on your local system and transfer them to your VM instance.

You will want to perform the following steps:

  • Install the appropriate graphics driver (in this case the Tesla K80), which you can find here. Again, I suggest you download the relevant Tesla driver on your local machine and transfer it to the cloud instance.
  • Install CUDA 8.0, available with its patch here. Skip the Visual Studio step. Select the “Custom” setup and un-select the drivers.
  • Install the CUDA 8.0 patch fix.
  • Install the Visual C++ Redistributable for Visual Studio 2015 available here. Choose the 64-bit version. This step is required for your Windows VM instance or you will get an error.
  • Unzip FakeApp (available here) and setup the directory structure.
  • Check that all appropriate paths are set in your PATH variable.
  • Prepare all of your training data sets. This can be done on your local machine, and then you just need to copy them to the correct folders.
  • Run FakeApp!

cloud 22

You should now be able to use Google Cloud to train your data FakeApp model. The K80 shows up as having just over 11 GB of free video RAM. I did not perform extensive testing, but the default parameters of batch=64, layers=4, and nodes=512 worked just fine. When you are done, you can transfer files back to your local computer.

Quitting your session

To quit, simply close your RDP session.

Then, you need to go back to the VM instance menu to stop your instance.

cloud 14

Click on the instance and select “STOP” from the button above to turn off your instance. You will still be charged some fees for maintaining your instance, but not the full charge for running it. If you are done with your instance, you can also choose to “DELETE” it. However, you will need to transfer files and install the software again the next time you wish to use it.

Don’t neglect this step. It is very important, or you may be charged high fees for your instances. Good luck making deepfakes!

24 thoughts on “Google Cloud FakeApp Tutorial

  1. Hey THANKS alot for you tutorial without it I would have never could have done it, I was posrting a lot on reddit but it got deleted I am training for some hours

  2. Hi, nice tutorial. I have one dude. Following this tutorial (same settings) … How much time needs the vm to train a new model (approx)? Take this example. I turn on the machine, start learn, end learn… close the instance… How much cost this???. I thing that is important have a reference of the cost… And maybe a good point to start is know the time to learn and the cost (approx). I don´t know, maybe 24 hours?. And what is the cost for have 24 hours the vm working?. There is a way to calculate? I think that this option is good, but for example for me… it´s a little dangerous …
    Another dude. It´s possible to test with the free 300$ and then cancel everything without extra charges?
    Thanks in advance.

    • When you setup an instance, Google gives you the cost per month as you are picking the different options (memory, CPU, ssd, etc.). You can figure out the cost per hour from that. I would estimate the final price would be around $0.50 per hour, maybe a bit less if you use preemptible instances. I would guess it takes around 24 hours for one project, since it also takes a long time to transfer your files over and back, fiddling around. Maybe if you get used to it, it goes a little faster. So $10-15 per project?

      Yes, you could use the free credit and cancel early. Except Google seems to have changed their policy. They are now asking for a $35 credit card payment if you ask for GPU activation. They will still give you the free credit for $335 total, but you have to pay the $35. At least, that is the latest that I have heard.

  3. It’s *SO STRANGE* how they email you asking for a payment of $35 be made…. it comes across like a scam.

    “Thank you for requesting additional quota.

    To help us ensure that this is a legitimate request and that the resources you
    requested are available to you, please do one of the following:

    Make a payment of $35 US Dollars or the same amount in your currency
    following the instructions linked below [1] and reply to this message when
    the charge clears. Your payment will be applied to any charges you incur in the
    future and will be visible as a credit in your account”

    ….make a payment then reply to an email? Surely Google can do better than this……

    • They initially didn’t do this when I signed up. When I tried to request more GPUs, recently, they did this to me as well.

      I think they had too many free requests fro GPUs, so they are trying to stem abuse of their free credit.

      Also, Google is notorious for having poor quality products. Read the comments and article here to get a feeling why… https://news.ycombinator.com/item?id=16483241

  4. Hi,
    First of all, this is a really great tutorial, thanks to everyone involved.
    But I am stuck.
    After making the payment of 35$, I went to create my VM instance but it didn’t work. I received this error: “Quota ‘NVIDIA_K80_GPUS’ exceeded. Limit: 0.0 in region europe-west1” .
    I think that my request for the GPU is not accepted but I don’t know how to verify this.
    I ended up trying the process again but received another email asking for the payment.
    Any idea how to verify that ? And also that I won’t be charged for a second GPU ?Thanks for your help.

    • You need to ask for the quota in the exact region that you will create an instance.

      After making a payment, it can take an hour to a day to process. Usually just an hour or less for me.

      If you are still having issues, you should contact Google support directly. You have to pay each time you increase your quota by 1 GPU, I think. I have paid multiple times now, and it always worked. I would imagine Google should tell you if the request is processed. There is usually an accounts manager that contacts you.

  5. Great guide, thanks for posting.

    I’ve run through it step by step, but i’m getting an error when I try to extract a dataset, after splitting.

    Here’s the trace back, any help appreciated:
    undefined[2316] Failed to execute script pyi_rth_win32comgenpy

    Traceback (most recent call last):
    File “site-packages\PyInstaller\loader\rthooks\pyi_rth_win32comgenpy.py”, line 47, in
    File “d:\anaconda\envs\fakeapp\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”, line 631, in exec_module
    File “site-packages\win32com\__init__.py”, line 5, in
    ModuleNotFoundError: No module named ‘win32api’

        • Not sure if it matters, but I always use Windows Server 2016 Desktop Experience.

          You shouldn’t need to install anything other than CUDA/cudNN, the VC redist, and the latest drivers.

          Seriously, don’t use 2.2. The software can be updated an anytime without your permission, so I have no idea if there was an invisible update that broke it. I’ve only run 2.2 once a while ago.

          The error you are getting is a weird fundamental error. With an open python install, you would fix that with “pip install pypiwin32”, but you can’t do anything to alter 2.2.

          I’ve used 1.1 over and over on multiple Google instances and never had a problem.

          It’s also possible your original 2.2 installation was corrupted somehow, or you downloaded an altered version.

          • Thanks, I think you were right on the corruption somehow.

            A fresh download and re-install has fixed the issue.

    • It should be fine with a Mac. However, you will need to change the way you connect to the server. I’m not sure if Macs support Remote Desktop Protocol, or what options you have.

  6. Great tutorial! I go thru setting up my VM up until the part where I need to install drivers, fakeapp or anything on the VM. All the installation files are shared thru my local drive but for some reason the VM seems to freeze anytime i try to make an installation. Am I doing something wrong?

  7. I am stuck trying to install the NVIDIA driver. I launch the utility and it gives a message: “Unable to install the Nvidia driver. The graphics driver could not find compatible graphics hardware.”

    Has anybody had this issue?

  8. This is lovely. Man have you saved any images of these VM that we should easily start to use without wasting money and time on configuring the environment.

    • I think Google’s GPU instances don’t let you save images. I have to reinstall the drivers, etc. for each instance I create.

Leave a Comment