Faster Solidworks Renders and Citizen Science
I’ll continue to update this with clarifications and resources as I think of ways to make the process even easier.
Have you ever tried to render something on a uni computer, only to find that the render time is forever and a day and the remote connection isn’t dependable? Especially now that we are all at away from uni due to COVID-19, the campus VPN is oversubscribed and most of us don’t have computers that can efficiently render all of our Visualize animations.
This is why using a GPU virtual machine can be really helpful. From even a crappy old laptop, you can remotely connect to a virtual machine hosted somewhere else that can run Solidworks and render animations and images in Visualize super freaking fast. Being able to do a GPU render can cut down the render time so much in comparison to a CPU render; I’ll talk more about this later with my example of a 7 hr uni computer CPU render that was cut down to 17 minutes with the GPU setup. But, how much does this cost? There has to be a catch!
The GPU Virtual Machines I have been using are hosted using Microsoft Azure, which is a cloud computing service created by Microsoft. Luckily for me and all of you, a lot of what we can do with it is for free thanks to a student sponsorship programme that Microsoft offers.
As a student, you are given $100 worth of Azure credit for free, without having to connect a credit card or anything (which is a relief, because otherwise it would feel sorta sketch). The Virtual Machine (VM) we are using will cost approximately $1 of this credit per hour that you use it.
However, outside of just being able to reliably and quickly render our inhaler project animations for uni, there are other real-world citizen science (protein folding!) applications for these GPU virtual machines that could potentially even help with the current COVID-19 crisis.
This is a guide to set up an Azure GPU Virtual Machine to use with Solidworks Visualize and a citizen science project called Folding@Home. It is split into three parts, the first being to set up the GPU virtual machine, the second part is to use Solidworks in it, and the final part is using the VM for citizen science after all of our CAD assignments are done.
Some important warnings: This guide looks really long but it’s just because I would always rather over-explain than under-explain. It’s actually quite simple and you could get through it quite fast if it wasn’t for the waiting times between steps. If you scroll through this guide, you may see that there is a small amount of code that you must input into a terminal. If you feel that you dislike code, please do not fear. Literally all you have to do is copy-paste it. If you follow this guide exactly, the number of problems you’ll run into should be quite minimal — I’ve made a lot of the mistakes for you, haha.
Part 1: Set up the Azure GPU Virtual Machine
This may look like a lot of steps, but in reality, it shouldn’t take much longer than 30 minutes to an hour, depending on how much time it takes for things to deploy and load. Most of your time will be spent waiting for stuff.
1. Make a student account on Azure using your Glasgow Uni credentials:
Press “Activate Now” on the page linked above.
For reference, you can check your Microsoft Azure sponsorship credit balance here: https://www.microsoftazuresponsorships.com/Balance
2. Create a virtual machine. In the dashboard, navigate to Virtual Machines and press “Add”.
Use the following settings.
Under “Basics”
Subscription: Azure For Students
Resource Group: Create a new resource group and name it whatever you’d like.
Virtual Machine Name: Name your VM whatever you’d like.
Region: Anywhere that has the NV6 VM available. Sometimes a lot of the VMs are greyed out. West Europe worked last time I checked, and East US is what I used when I set up my VM. However, there may be trial and error with selecting regions then going through the VM list under “Size” to see if that region has the NV6 available.
Availability Options: No infrastructure Redundancy Required
Image: Windows 10 Pro, Version 1809
Azure Spot Instance: No
Size: Standard NV6_Promo (6 vcpus, 56GiB memory)
{ Standard NV6 should be alright too. Also, don’t worry about the cost saying “$799.35/month”, that is assuming a lot of continuous usage of the VM. We will be turning ours off every time we are done using it.}
Administrator Account Username & Password: Whatever you’d like them to be. Write them down so that you input them into your remote connection client.
Inbound Port Rules: Allow selected ports, Select inbound ports: RDP (3389)
Already have Windows 10 Enterprise License? I’m guessing this is also a “No” for y’all, but if you do then go for it, lol.
Under “Disks”
Make sure the OS disk is set to Standard SSD, and leave all other settings at defaults. Unless you want to mess around with stuff.
Under “Networking”
Change your Public IP so that it is Static, which will make your life a little easier when remotely connecting to it because you won’t have to type in a new IP address every time. Click on “Create New” underneath the Public IP option and change the Assignment to “Static”. Keep the SKU at “Basic”.
Leave everything else the same, if you’d like.
Under “Management”
The only thing here I would change is enabling Auto-Shutdown just in case. It would suck to accidentally drain all of your precious Azure credit by accidentally forgetting to stop the VM in the Azure dashboard.
I didn’t really change anything under “Advanced” or “Tags”.
Now confirm everything is correct under “Review +Create” and press Create. Wait a while for the deployment to be done.
3. While you’re waiting, make sure you have a remote desktop client on your laptop.
If you have Windows on your computer, you can just use the built-in client called Remote Desktop Connection. If you are like me and have a Mac, then get Microsoft Remote Desktop from the app store: https://apps.apple.com/us/app/microsoft-remote-desktop-10/id1295203466?mt=12
If you have Linux, then use something like Remmina. It is actually the default client in Ubuntu and apparently works quite well.
4. Once your VM has been deployed, click “Go to Resource”. Let’s see if we can connect to it.
Your VM should already be running. Click on “Connect” on the sidebar and then, assuming you are on the RDP tab, click “Download RDP File”.
On a Mac, open the Microsoft Remote Desktop application and drag this RDP file from your Downloads folder into it. A new PC with your virtual machine name should show up in the window.
On Windows and Linux, whatever client you are using should have an option somewhere to import an RDP file. So do that, maybe Google it if unsure.
In Microsoft Remote Desktop on Mac, if you right-click on the new PC and select “Edit”, then under “User Account” select “Add User Account”, you can input the Admin username and password you set when you created the virtual machine. That way, it will automatically sign you in when you connect to the virtual machine. There should be options for logon settings in the Windows and Linux clients as well.
Specifically for Mac (idk about Linux and Windows, but y’all can check), I like to change some of the other settings under Edit PC as well. Under “Devices & Audio”, I usually redirect the Clipboard, Microphone, and Cameras. And under “Folders”, I select “Redirect folders” and I have one folder added to the list. This folder exists on the Desktop of my Mac and it is how I share files back and forth between the VM and my Mac. If you want to create your own such sharable folder, you can easily link to it by pressing the plus (+) icon and selecting that folder’s location on your Mac. [See update at end of this section with more specific instructions].
Now, save your edits and connect to the Virtual Machine! On Mac, just double-click the on it, for anything else there should be a button to connect.
There might be some things to set up for your Windows system, and it might take a while to start. But eventually, it will start and you should be connected to your brand new Windows environment!
If you were to stop by the Task Manager right now, it would probably look something like this:
Something is missing, where is the NVIDIA Tesla GPU?
5. We have to install the NVIDIA GPU drivers onto our virtual machine.
You can “shutdown” your virtual machine from the Windows start menu in the remote desktop client first, if you’d like. Might be a good idea. However, do not press Stop and deallocate the virtual machine in the Azure dashboard, make sure to keep it running as it must be running to install the extensions.
To get our GPU to work, we have to use the Azure Cloud Shell in the Azure dashboard to deploy an extension that will automatically install these drivers for us on our virtual machine.
Confirm your subscription and wait for the terminal to start. We will be using the Azure CLI, just my personal preference. If you prefer to use Powershell or something else, here’s a link with information about the extension: https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/hpccompute-gpu-windows
First, type this into the terminal, replacing RESOURCEGROUP with the whatever the hell you named your resource group for the virtual machine and VMNAME with whatever the hell you named your virtual machine. It is all one line.
az vm extension list --resource-group RESOURCEGROUP --vm-name VMNAME -o table
Since this is a new virtual machine, nothing should happen.
If the NVIDIA extension doesn’t appear, that means it isn’t there and we should go ahead with installing it.
So type this into the terminal, again replacing the necessary placeholders RESOURCEGROUP and VMNAME. Type everything else exactly as it is, and note that this should all be on one line.
az vm extension set --resource-group RESOURCEGROUP --vm-name VMNAME --name NvidiaGpuDriverWindows --publisher Microsoft.HpcCompute --version 1.2 --settings '{}'
It will start Running and doing stuff, just wait for it. At the end, it should return some information. Just to make sure everything is good, run this again:
az vm extension list --resource-group RESOURCEGROUP --vm-name VMNAME -o table
Now it should return something that looks like this:
Awesome, now if we connect to our virtual machine again through the remote desktop client, wait for it to start up, and then open up the Task Manager…
There should be an option for the GPU and when you click on it, you should be able to see something like this! Our NVIDIA drivers have been installed and our NVIDIA Tesla GPU is working its magic. :)
6. Just so you know
How to stop the virtual machine when you’re not using it and save your precious credits:
Do not just press shutdown on the start menu.
It’s a good thing to do, but there’s still something else you must do afterwards…Make sure to press stop in the Azure portal.
In my experience, it can take about 15 min to fully stop and deallocate. After it is properly stopped, it will no longer eat up more of your $100 student credit.
How to start it back up again:
As you can see here, the virtual machine is completely stopped and deallocated.
Press Start, wait for the VM Status to say “Running” again, then connect to it using your Remote Desktop client. :)
Update: How to add a shared folder between the VM and your Mac:
So on a Mac, after you right-click on the VM and press edit, a menu will come up with four different tabs. Under the tab that says “Folder”, there is a checkbox that says “Redirect Folders”. If you check the box, you are then able to add folders below that you can share between your laptop and the VM. All you have to do then is press the plus sign, find the folder that you want to share, add it, and press save.
Finally, if you go into the file explorer in the Windows VM, you should be able to see the folder you shared with yourself in the sidebar and access it, like this:
Part 2: Install Solidworks and make your first GPU rendering
Skip this step if you are only interested in using Folding@Home.
Now you can install Solidworks on your virtual machine. When you’re in the VM, here’s the form you can fill out to request the download: https://www.solidworks.com/sw/education/SDL_form.html
Go to the Undergraduate CAD Moodle for the installation instructions, SEK ID, serial number, suggested settings, and all that jazz.
You may be prompted to restart the machine after Solidworks is downloaded/installed. I would recommend shutting down within the remote desktop, waiting a little while, then reconnecting. You could probably also press restart, wait for a while, then try to reconnect later. It may not want to connect if it is still restarting, I ran into some issues with that personally, just give it some time before trying to reconnect. If you encounter problems here, feel free to reach out to me via Messenger and I’ll see if there’s any more specific advice I can offer from my extensive experience of messing things up.
Once Solidworks is installed on the VM and everything, you can open up Solidworks Visualize. Import in some model you have already created (send it to yourself and download it to the VM) then make a quick animation of it, say a 10 second animation or something.
Now, click on the Output Tools icon.
Click on the Render icon and scroll down to Render Device. Select GPU.
Now go to the animation icon then set the file name, path, and everything to what you want them to be. Press Start Animation Render, then sit back and watch your amazing GPU work its magic.
For reference, the 10 second animation below took 7 hours to render on a uni machine. The GPU render on the virtual machine took 17 minutes.
Part 3: Folding@Home
Here’s another cool thing you can do with your GPU VM when you are finished with your Solidworks renderings. Folding@Home is a really neat open source “distributed computing” project that uses resources from volunteers’ personal computers to simulate protein dynamics and find potential cures for diseases. If you ever wanted to be involved in citizen science, this is a neat opportunity.
So, let’s fold some proteins and donate some computing resources to scientists who are trying to identify potential therapies for COVID-19, as well as other diseases! Here is a post from FAH explaining how they are trying to use these simulations to fight COVID-19: https://foldingathome.org/2020/03/15/coronavirus-what-were-doing-and-how-you-can-help-in-simple-terms/
If you would like to help, use this link to install the software when you’re in your virtual machine: https://foldingathome.org/start-folding/
Follow the instructions, get it all set up, and you’ll eventually have a little dashboard that looks like this:
If you’re interested in learning more about the projects you’re contributing to, here’s a directory with all active projects at the moment:
You may have noticed that there’s an option to get points and join teams. If you want to look at team and donor statistics, take a look at this link:
I’ll make a team sometime and update this post with the team name and number if anyone wants to join. :)
If you have any questions, suggestions, or problems, reach out to me on Facebook Messenger and I’ll see if I can help.
I wish you all the best for the rest of the semester, please stay safe, and I’ll see ya’ll when uni is back in session. ❤