Using AWS G and P Series EC2 Instances for High-Quality Rendering, Cloud Gaming and Machine Learning.
Using AWS g4dn.xlarge EC2 Instance with Nvidia Tesla T4 GPU for High-Quality Rendering, Cloud Gaming and Machine Learning.
Introduction:
As a 3D artist, game designer, or environment artist, you’re likely familiar with the frustration of rendering complex designs on a local machine. High-quality rendering is resource-intensive, and relying solely on your computer can be time-consuming and inefficient. Large design studios typically solve this by using render farms — clusters of powerful hardware dedicated to rendering multiple scenes simultaneously. However, these setups are often costly and out of reach for most individual artists or small studios.
Thankfully, there’s an affordable alternative: AWS. With AWS, you can access a variety of EC2 instances designed specifically for high-performance tasks, including rendering. The G series instances, in particular, are optimized for graphics and video processing with different types of Nvidia GPUs. You can even create your own mini render farm without the heavy upfront costs of dedicated hardware.
In this blog, I’ll focus on one of the most budget-friendly options, the g4dn.xlarge EC2 instance. This instance is equipped with 4 vCPUs, 16 GB of RAM, and a powerful Nvidia Tesla T4 GPU with 16 GB of memory and 40 RT Cores, perfect for rendering tasks. I’ll guide you through the entire process — from launching the instance to setting up drivers and optimizing your GPU usage for maximum performance.
Pricing:
AWS offers a range of G series instances, each with varying configurations and pricing. It’s important to note that Windows Server instances typically have a higher cost compared to Linux instances due to licensing fees.
To check the latest pricing for all G series instances, you can refer to the AWS GPU instance pricing guide here.
For this blog, I’m using the most cost-effective option: the g4dn.xlarge instance, running Windows Server 2022 (included in the AWS Free Tier). This configuration costs $0.763 per hour, making it a budget-friendly option for high-quality rendering tasks.
Who is the Target Audience?
Are you a freelancer or a startup that frequently needs to render high-quality 3D designs, animations, or game environments? If so, this AWS solution could be the most cost-effective and scalable way to access powerful hardware without the upfront cost of purchasing dedicated machines. With AWS, you pay only for the resources you use, meaning you can leverage high-end GPUs for your render jobs on-demand, without the hassle of maintaining expensive hardware.
This setup is ideal for freelancers who don’t have access to high-performance machines but need to handle heavy rendering workloads. Even if you have limited hardware, AWS allows you to scale up instantly and work efficiently without making a large financial investment.
If you’re working in Machine Learning or AI, this setup could be a great solution for training and testing heavy models. The availability of high-end GPU resources allows you to handle intensive computations without worrying about hardware limitations, enabling faster iterations and development cycles. With AWS GPU instances, you can scale up when needed, making it a cost-effective and scalable option for both AI research and deep learning tasks.
The first step is to increase the vCPU service quota for G series instances. By default, AWS accounts have a vCPU limit of 0 for G series instances, meaning you won’t be able to launch them until you request a quota increase.
Warning: Basic AWS knowledge is required to perform further steps.
Increase vCPU Service Quota for G Series Instances
- Go to the Service Quotas → Manage Quotas: ‘Amazon Elastic Compute Cloud’ → Search for ‘Running On-Demand G and VT instances’ → Request increase at account level.
2. Increase quota value to: 8.
For smaller requests, the quota increase might be automatically approved. However, if it’s not, you’ll be prompted to open an AWS Support case. In that case, you’ll need to provide the following details:
Service: EC2 Instances
Region: Your Region. (Service Quota is Regional)
Primary Instance Type: All G instances
Limit name: Instance Limit
New limit value: 8
You’ll also be required to draft a professional email explaining why you need the quota increase and what specific goals you’re trying to achieve. AWS provides a text box where you can type your message. Typically, within 1–2 days, the AWS Support team will review your request and approve the quota increase.
Launch Instance with Proper Configurations:
You know the drill go the AWS → EC2 → Instances.
- Launch instances → Provide proper name.
- Operating System: Here I am going to use Windows Server 2022 Base, because it is simple and easy to use.
- Select instance: g4dn.xlarge
You can choose instances according to your needs, For more information you can visit here: https://docs.aws.amazon.com/dlami/latest/devguide/gpu.html
4. Important: Create new key-pair or Select exsiting. This key is required to get windows server password.
5. Create new security group with RDS Traffic allowed.
6. Storage: I prefer you choose size between: 50GB — 60GB or else you will be run out of the storage in no time. g4dn.xlarge instnace by default comes with 125GB temporary storage, when you stop your instnace you will lose all your stored data in that storage.
7. Launch Instance.
8. We still need some changes in Security Group, that we created with instance.
Inbound rules:
Protocol: All TCP, All UDP
Source: 0.0.0.0/0
9. We need to create IAM Role for EC2 with “AmazonS3RealOnlyAccess”.
Go to IAM → Role → Create Role → AWS Service: EC2 → Select “AmazonS3RealOnlyAccess” IAM Policy → Create.
10. Attach this IAM role to our EC2: EC2 → Actions → Security → Modify IAM Role → Select the IAM Role → Update IAM Role.
Connecting to the EC2:
- Go to your instance → Connect to instnace → RDS Client → Get password.
2. Upload Private key file that we have created for server and Decrypt Password.
3. After Decrypting password, you will get the page like below where you can find DNS, Username and Password for EC2.
4. If you are on windows then search for Remote Desktop Connection → Copy and Paste Public DNS to Computer → Enter Username and Password.
5. Click “Yes” if you see any certifcate Dialog-Box. You are now connected to the Windows Server.
Installing NVIDIA Drivers:
Go to the following AWS document on NVIDIA Drivers for EC2 instnaces.
- NVIDIA GRID Drivers:
- Open PowerShell as Administrator.
- Copy and Paste Following Commands one by one to the PowerShell.
$Bucket = "ec2-windows-nvidia-drivers"
$KeyPrefix = "latest"
$LocalPath = "$home\Desktop\NVIDIA"
$Objects = Get-S3Object -BucketName $Bucket -KeyPrefix $KeyPrefix -Region us-east-1
foreach ($Object in $Objects) {
$LocalFileName = $Object.Key
if ($LocalFileName -ne '' -and $Object.Size -ne 0) {
$LocalFilePath = Join-Path $LocalPath $LocalFileName
Copy-S3Object -BucketName $Bucket -Key $Object.Key -LocalFile $LocalFilePath -Region us-east-1
}
}
3. Go to the folder create on your Desktop: Desktop → NVIDIA → latest → install the graphics driver.
4. Choose Express install.
5. To confim go to Task Manager → Preformance → GPU 0. It will your GPU.
- NVIDIA Gaming Driver:
- Open PowerShell as Administartor.
- Run Following Commands one by one:
$Bucket = "nvidia-gaming"
$KeyPrefix = "windows/latest"
$LocalPath = "$home\Desktop\NVIDIA"
$Objects = Get-S3Object -BucketName $Bucket -KeyPrefix $KeyPrefix -Region us-east-1
foreach ($Object in $Objects) {
$LocalFileName = $Object.Key
if ($LocalFileName -ne '' -and $Object.Size -ne 0) {
$LocalFilePath = Join-Path $LocalPath $LocalFileName
Copy-S3Object -BucketName $Bucket -Key $Object.Key -LocalFile $LocalFilePath -Region us-east-1
}
}
3. Rest of the Process is same as GRID DRIVER.
4. We need to Register Gaming Driver, for that run following command:
PowerShell:
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\nvlddmkm\Global" -Name "vGamingMarketplace" -PropertyType "DWord" -Value "2"
CMD:
reg add "HKLM\SYSTEM\CurrentControlSet\Services\nvlddmkm\Global" /v vGamingMarketplace /t REG_DWORD /d 2
5. Apply Driver Certificates, Run following command in the powershell:
Invoke-WebRequest -Uri "https://nvidia-gaming.s3.amazonaws.com/GridSwCert-Archive/GridSwCertWindows_2024_02_22.cert" -OutFile "$Env:PUBLIC\Documents\GridSwCert.txt"
6. Reboot instance.
7. To verify Go to the following Path: C:\Windows\System32\DriverStore\FileRepository\nvgridsw_aws.inf_* and run following command:
nvidia-smi.exe -q
Here, our instance is set up with proper driver set up.
NICE DVC:
The regular Remote Desktop Connection is designed for basic tasks, and by default, it uses its own display driver. This makes it impossible to fully utilize the GPU, meaning you won’t get the performance needed for tasks like cloud gaming or high-resolution rendering. Achieving good FPS and high resolution is particularly challenging with the standard RDP setup.
To overcome this, AWS recommends using NICE DCV, an advanced RDP connection tool. With NICE DCV, you can achieve video output up to 4K and benefit from an indirect connection to the GPU-rendered display, which maximizes the GPU’s potential. Additionally, NICE DCV supports USB redirection and even allows for XBOX controller integration, making it a versatile solution for high-performance cloud gaming and rendering tasks.
- Go the https://download.nice-dcv.com/ and download NICE DCV Server.
2. Run Set up → Keep everything default and next → Install.
3. After this Go to the Settings → System → Display → Graphics Settings → Change Default graphics settings → Turn On Hardware-accelerated GPU Scheduling.
4. Restart your Instance.
5. Download NICE DVC Client on your local device. From, https://download.nice-dcv.com/
6. Open Client and You will prompt with server connection details. You can provide server details in this formate:
my-dcv-server.com:8443#console
you can replace my-dcv-server.com with Public DNS.
7. Enter Username and Password which are generated at AWS EC2 Console.
8. Now you are connected to the Server with virtual Display driver of NICE DVC.
Enable Temporary Storage Drive:
g4dn.xlarge comes with 125GB NVME storage, which is temporary but it is not enabled by default.
- Right click on Windows icon and go to Disk Management, on the launch of Disk Management you will prompt with Initialize Disk option, where you can select GPT and ok.
2. Right click on the Unallocated Disk → New Sample Volume → Just keep clicking Next and Create Disk. You will be able to see your disk in My Computer.
Testing GPU with Blender:
- Download your prefered Blender version from https://www.blender.org/download/
- After Installing Blender open it, we need to made some changes in blender to use GPU.
- Go to the Edit → Preferences → System → Cycles Render Devices → Optix → Select Tesla T4 → save Preferences.
4. Let’s try to Render this design: https://cloud.blender.org/p/gallery/629f23f908e12d4ff15241d3
5. This configuration I am using to render this scene:
Resolution: 4K (16:9)
Output: .png (100% Lossless, 16 bit color depth, RGBA)
6. Hit the render image button to render current frame.
For this render, the Tesla T4 GPU took approximately 17 minutes to complete. While the Tesla T4 comes with 16 GB of vRAM, its overall processing power is not on par with higher-end GPUs. However, it excels at Ray Tracing due to its RT cores, making it faster than GTX GPUs for such tasks. If your rendering workload requires higher vRAM, you may want to consider other GPU instances with more power. In this case, I used one of the most cost-effective options, but AWS offers several other GPU instances that might better suit your needs for faster or more memory-intensive rendering.
What About Gaming on Tesla T4?
If you’re planning to use this setup for gaming, the Tesla T4 is a solid choice. You’ll benefit from Ray Tracing support along with DLSS frame generation, which enhances frame rates. However, when using NICE DCV, you’ll need a super-fast internet connection to fully enjoy the experience.
I tested The Witcher 3 on this instance, and while the game performed quite well, my internet didn’t. I experienced multiple instances of input lag and low video quality due to bandwidth limitations. So, while the Tesla T4 is capable, a stable and high-speed internet connection is crucial for smooth gameplay.
What About Unreal Engine 5 on Tesla T4?
Unfortunately, I’ve tried running Unreal Engine 5 on the g4dn.xlarge instance, but its configuration doesn’t seem ideal for this task. The instance struggled, and UE5 crashed when I attempted to open a pre-existing level. This could be due to the instance’s 4 vCPUs, which likely created a CPU bottleneck.
While it’s possible that higher-end instances would perform better, I haven’t had the chance to test them due to budget constraints. If you’re working with Unreal Engine 5, you may want to consider a more powerful instance with higher CPU capacity to avoid these issues.
Machine Learning
Although Machine Learning isn’t my area of expertise, I tested the Stable Diffusion model using stable-diffusion-webui for image generation and upscaling, and the results were impressive. Compared to my local device (i7 10th Gen, GTX 1660ti 6GB), the AWS GPU instance delivered significantly faster image generation. For image upscaling, I was able to scale images up to 8x or 16x, which would normally cause my device to run out of GPU vRAM. On AWS, however, this wasn’t an issue, making it a great choice for similar workloads. Even for Machine Learning tasks, AWS GPU instances prove to be a good option.
Conclusion
In conclusion, AWS GPU instances provide a versatile and cost-effective solution for freelancers and startup design companies looking to shift their rendering workloads to the cloud. By leveraging these instances, you can significantly reduce the upfront costs of purchasing expensive high-end hardware, while still accessing the power needed to handle demanding rendering tasks. AWS offers flexibility, allowing you to scale resources based on your needs, making it an ideal choice for budget-conscious professionals in the creative industry.
Reference:
https://www.vantage.sh/blog/aws-ec2-gpu-instances-g-family-vs-p-family-g4dn