How to Create DeepFakes with Google Cloud GPU Services
- 1 Should you use Google Cloud GPU Services?
- 2 Preparing your Google Cloud account for GPU services
- 3 Installing FakeApp on Google Cloud
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.
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.
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.
Click on “Create an empty project”.
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.
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.
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.
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.
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.
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.
Go back to your Google Cloud console and click on the menu again. Select “Compute Engine”, and in the sub-menu select “VM instances”.
If this is your first instance, you may see a message like the above. Click “Create” to continue.
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”.
Now click on “GPUs” to expand the menu.
Set the number of GPUs to “1” and select your GPU (in this case, the NVIDIA Tesla K80).
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.
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.
Click on the button next to “RDP” and select “Set Windows password”.
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”.
Press the Windows button or click the search icon, then type “remote desktop connection”. Click on Remote Desktop Connection to run it.
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.
Click on the Local Resources tab. Under the “Local devices and resources” section, click “More”.
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.
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!
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.
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!