Readme
HPCImageRendering
Labversion:1.5.0
Lastupdated:10/19/2018
Contents
Overview
Getting Started
Task 1 - Inspecting the AzureBlobCopy Project
Task 2 – Inspecting the Run.cmd File
Task 3 - Inspecting the RenderCmd Client Application
Deployment
Task 1 – Deploying the Parametric Sweep Application to On-Premises Nodes
Task 2 – Deploying the Parametric Sweep Application to Windows Azure Nodes
Running the Client
Task 1 – Verifying Cluster State
Task 2 - Manually Uploading Instruction Files to the Blob Storage
Task 3 – Submitting the Job Manually Through the HPC Job Scheduler
Task 4 – Running the Client Application
Summary
Overview
TheHPCImageRenderingsampledemonstrateshowtorunaparametricsweepapplicationthatrendersimagesaccordingtoinstructionfiles.TheapplicationdemonstrateshowtodownloadanduploadfilesfromWindowsAzureblobstorage,andhowtocreateaparametricsweepjobfrom.NETcode.
Note: Though this sample was originally developed for Windows HPC Server 2008 R2 SP1, it has been verified to run under Windows HPC Server 2008 R2 SP2.The sample should preferably be run under Windows HPC Server 2008 R2 SP2.
ThissampleusestheAqsisapplicationthatrenders3DimagesaccordingtotheRenderMan®standard.
Note: To use this sample application, download the sample RenderMan data files and extract them to the labs folder.
KeyFeatures
Thissampledemonstratesthefollowing:
- UploadingaparametricsweepapplicationpackagetoWindowsAzurenodes.
- UploadinganddownloadingfilestoWindowsAzureblobstorage.
- CreatingandrunningaparametricsweepjobinaWindowsHPC2008R2SP1cluster.
GettingStarted
Torunthissample,youmustinstalltheHPCPack2008R2ClientUtilitiesRedistributablePackagewithServicePack1(or higher), theHPCPack2008R2SDKwithServicePack1(or higher), and the Windows Azure SDK and Windows Azure Tools for Microsoft Visual Studio (March 2011).Inaddition,youneedtohaveadministrativeaccesstoyourHPCcluster’sheadnode.
ToruntheimagerenderingapplicationinWindowsAzurenodes,youmusthaveavalidWindowsAzureaccount,aWindowsAzureworkernodetemplatedefinedinyourheadnode,andseveralWindowsAzureworkernodesintheHPCclusterthatarestartedandonline.FollowtheDeployingAzureWorkerNodesinWindowsHPCServer2008R2SP1Step-by-StepGuideonTechNetforfurtherinformation.
Task1-InspectingtheAzureBlobCopyProject
Inthistask,youwillinspecttheAzureBlobCopyutilityprojecttoseehowtodownloadanduploadfilesfromWindowsAzureblobstorage.TheparametricsweepjobusestheAzureBlobCopyutilitytocopyarenderinginstructionfilefromablobcontainer,andcopytherenderedimagetoadifferentblobcontainer.
- OpenMicrosoftVisualStudio2010fromStart|AllPrograms|MicrosoftVisualStudio2010|MicrosoftVisualStudio2010.
- OpentheImageRendering.slnsolutionfilelocatedintheImageRendering\Sourcefolder.
- IntheSolutionExplorerwindow,expandtheAzureUtilitiesprojectnode,asshowninFigure 1:
Figure1
TheAzureUtilitiesproject
- OpentheBlobUtilities.csfileandinspecttheBlobUtilitiesclass.TheclasscontainsseveralmethodsforworkingwithWindowsAzureblobstorage:
- InitializeStorage.Themethodvalidatestheexistenceofarequiredblobcontainer,and,ifnecessary,createssuchacontainerandsetsitspermissions.
- DownloadFile.Themethoddownloadsafilefromablockblobandsavesittoaspecifiedpath.
- UploadFile.Themethoduploadsafiletoablockblob.TheCloudBlob.UploadFilemethoddivideslargecontentintoseveralblocks,andtheblocksareuploadedinparallel,accordingtotheminimumnumberofI/Othreadsinthethreadpool.Ifyouwanttochangethenumberofparalleluploads,youcansettheCloudBlobContainer.ParallelOperationThreadCountproperty,asshowninthefollowingexample:
C#
publicvoidUploadFile(
stringcontainerName,stringpath,stringfileName)
{
varblobStorage=InitializeStorage(containerName);
if(blobStorage!=null)
{
CloudBlobContainercontainer=
blobStorage.GetContainerReference(containerName);
blobStorage.ParallelOperationThreadCount=8;
CloudBlobblob=container.GetBlockBlobReference(fileName);
blob.UploadFile(Path.Combine(path,fileName));
}
}
- DeleteFile.Themethoddeletesafilefromablockblob.
- IntheSolutionExplorerwindow,locatetheAzureBlobCopyproject,andinspectthecontentsoftheProgram.csfile.
AzureBlobCopyisaconsoleapplicationthatsupportscopyingfilestoandfromWindowsAzureblobstorage.Forexample,thefollowingcommandlinedownloadsafilenamedframe-1.zipfromtheinputblobstoragetoalocalfolder:
CMD
AzureBlobCopy.exe-ActionDownload-BlobContainerinput-LocalDirc:\frames\-FileNameframe-1.zip
- OpentheAzureBlobCopyproject’ssettingsandinspectthefollowingtabs:
- Build.Theaqsisfoldercontainstheaqsisrenderingapplicationthatrunsoneachcomputenode;thisistheonlyfolderthatis copiedtothecomputenodes(on-premisesandWindowsAzure).Beforerunningtheaqsisapplication,theAzureBlobCopyutilityiscalledinordertodownloadtherenderinginstructionfilefromtheblob.Theoutputpathoftheprojectisthereforesettotheaqsis\binfolder.
- BuildEvents.ThePost-buildeventrunsthehpcpackcommandtopacktheaqsisapplicationandtheAzureBlobCopyutilitytoacompressedzipfilefordeploymenttoWindowsAzurecomputenodes.
- OpentheApp.configfilefromtheAzureBlobCopyproject.TheappSettingssectioncontainstwokeys,StorageAccountNameandStorageKey.
- ChangethestorageaccountnameandthestorageprimarykeytomatchyourWindowsAzurestorageaccountsettings.
- BuildtheAzureBlobCopyproject.
Task 2 – Inspecting the Run.cmd File
In this task, you will inspect the contents of the run.cmd file to see which commands run when the parametric sweep job executes in each compute node.
- In the Solution Explorer window, right-click the solution and select Open Folder in Windows Explorer.
- In the WindowsExplorer window navigate to the aqsis\bin folder, locate the run.cmd file, and view the file’s contents:
RUN.CMD
REM Use the input parameter as a frame index.
set frame=%1
REM Setup the executable, input, and output folders.
set root=%CCP_PACKAGE_ROOT%\Aqsis
set inputdir=%CCP_WORKDIR%\%CCP_JOBID%\%CCP_TASKID%\input
set outputdir=%CCP_WORKDIR%\%CCP_JOBID%\%CCP_TASKID%\output
if not exist %inputdir% mkdir %inputdir%
if not exist %outputdir% mkdir %outputdir%
REM Pull input data from blob storage.
%root%\bin\AzureBlobCopy.exe -Action Download -BlobContainer input -LocalDir %inputdir% -FileName %frame%.zip
REM Unzip the input file, run the executable, and create output data.
%root%\bin\rar.exe e -y %inputdir%\%frame%.zip %outputdir%
cd %outputdir%
%root%\bin\aqsis.exe -shaders:"%root%\displacement:%root%\shaders\imager:%root%\shaders\light:%root%\shaders\surface:%root%\shaders\volume" -displays="%root%\bin" %outputdir%\%frame%.rib
REM Upload the output files to blob storage.
%root%\bin\AzureBlobCopy.exe -Action Upload -BlobContainer output -LocalDir %outputdir% -FileName %frame%.tif
REM remove local files
del /Q %inputdir%\%frame%.zip
del /Q %outputdir%\%frame%.rib
del /Q %outputdir%\%frame%.tif
- The run.cmd file executes the following commands:
- Runs the AzureBlobCopy utility to download the current rendering instruction file from the input blob and decompress it.
- Runs the aqsis 3D rendering application.
Note:This application uses the root environment variable, which is set according to the CCP_PACKAGE_ROOT environment variable mentioned in Task 2 in this section.
- Runs the AzureBlobCopy utility to upload the generated .tiff image to the output blob.
Task3-InspectingtheRenderCmdClientApplication
Inthistask,youwillexploretheRenderCmdclientapplicationthatuploadstheinstructionfilestotheWindowsAzureblobstorage,submitstheparametricsweepjob,anddownloadstherenderedimagesfromtheoutputblob.
- IntheSolutionExplorerwindow,expandtheRenderCmdprojectnode.
Figure2
TheRenderCmdproject
- IntheRenderCmdproject,opentheRenderCommand.csfile,andinspectthecontentsoftheRenderCommandclass.
- UploadFiles.Thismethoditeratesthefilesintheinputfolderanduploadsalltherenderinstructionfilestoablob.
- DownloadFiles.Thismethoddownloadsthecontentsoftherenderedimages’outputblobtoalocalfolder.
- Run.ThismethodcallstheUploadFilesmethod,submitstheparametricsweepjob,andthencallstheDownloadFilesmethodtodownloadtherendered imagescreatedbytheparametricsweepapplication.
- IntheRenderCmdproject,opentheHPC.csfileandinspecttheCreateJobmethod.
- Themethodfirstconnectstothejobschedulerandcreatesanewjob,asshowninthefollowingcode snippet:
C#
Schedulerscheduler=newScheduler();
scheduler.Connect(headnode);
//Definejobsettings
ISchedulerJobjob=scheduler.CreateJob();
job.Name="AqsisonAzure";
job.MinimumNumberOfCores=1;
job.MaximumNumberOfCores=1;
job.UnitType=JobUnitType.Core;
//Lettheschedulercalculatetherequiredresourcesforthejob
job.AutoCalculateMax=true;
job.NodeGroups.Add(targetNodes);
- Aftercreatingthejobsettings,themethodaddsaparametricsweeptasktothenewjobandsubmitsittothescheduler as follows:
C#
//Createaparametricsweeptask
ISchedulerTasktask=job.CreateTask();
task.Type=TaskType.ParametricSweep;
task.StartValue=0;
task.EndValue=endValue;
task.IncrementValue=1;
//Runtheaqsiscommandtorendertheimages
//The(*)wildcardisusedasaplaceholderforthecurrentindexvalue
task.CommandLine=@"%CCP_PACKAGE_ROOT%\Aqsis\bin\run.cmdframe-*";
task.WorkDirectory="%CCP_PACKAGE_ROOT%";
Console.WriteLine("Runningjob");
job.AddTask(task);
scheduler.SubmitJob(job,username:null,password:null);
Note:TheCCP_PACKAGE_ROOTenvironmentvariableisdefinedinWindowsAzurenodesandpointstothefolderinwhich packagedHPCapplicationsaredeployed.
- Aftersubmittingthejob,theclientapplicationwaitsuntilthejobcompletes,periodicallycheckingthejob’sstatus.
- IntheRenderCmdproject,opentheapp.configfileandinspecttheappSettingssection.Thissectioncontainsfoursettingsthatyouneedtochangein accordancewithyourHPCclusterdefinitionsandWindowsAzurestorageaccountsettings:
- HeadNodeName.Thenameofyourheadnodemachine.
- NodeGroup.Thegroupofcomputenodesthatwillruntheparametricsweepapplication.
- StorageAccountName.Thenameoftheblob storageinwhichtheinputandoutputfileswillbestored.
- StorageKey.TheprimarystoragekeyofthestoragespecifiedinStorageAccountName.
- BuildtheRenderCmdproject.
Deployment
Inordertorunthissample,youwillneedtodeploytheparametricsweepapplicationtoyourcomputenodes(bothon-premisesandinWindowsAzure).
Task1–DeployingtheParametricSweepApplicationtoOn-PremisesNodes
Inthistask,youwilldeploytheaqsisparametricsweepapplicationtoyourHPCcluster’son-premisesnodes.Instead of manually copying the application to each on-premises node, you can use the clusrun command to run the xcopy command in all the nodes.
Note:IfyouaregoingtotestthissampleonWindowsAzurenodesonly,youcanskipthistask.
- Inyourheadnodemachine,createasharenamedapps.Verifythatalltheon-premisesnodescanaccessthisshare.
- In the SolutionExplorer window, right-click the solution and select OpenFolderinWindowsExplorer.
- Copy the aqsis folder and its sub-folders to the shared folder you created in the head node.
- OpenthecommandpromptwindowfromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
- Runthefollowingcommandlinetoallowtheparametricsweepapplication to use the same command line paths whether it runs in on-premises nodes or Windows Azure nodes:
CMD
cluscfgsetenvs"CCP_PACKAGE_ROOT=c:\apps"
Note:SincetheCCP_PACKAGE_ROOTenvironmentvariableusedintheparametricsweepjobisdefinedonlyinWindowsAzurecomputenodes,andwewantthecommandlinetoalsorunonon-premisesnodes,weneedtosetitmanuallyforeachoftheon-premisesnodes.
- Run the following command line to instruct all the nodes to copy the application from the shared folder:
CMD
clusrun /nodegroup:ComputeNodes xcopy \\MyHeadNode\apps\aqsis\*.* %CCP_PACKAGE_ROOT%\aqsis\ /EY
Task2–DeployingtheParametricSweepApplicationtoWindowsAzureNodes
Inthistask,youwilldeploytheaqsisparametricsweepapplicationtoyourWindowsAzurenodes.
- OpenthecommandpromptwindowfromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
- NavigatetotheImageRenderinglabsfolder,andrunthefollowingcommandtouploadthedeploymentpackagetotheWindowsAzurepackagestorage:
CMD
hpcpackuploadSource\aqsis.zip/nodetemplate:"Azure nodetemplate"/relativePath:aqsis
Note:Change the value of the nodetemplate parameter to the name of your Windows Azure node template.
- IfyoualreadyhaveWindowsAzurenodesstartedintheHPCcluster,youneedtocopythenewpackagetothem.TosynctheWindowsAzurenodeswiththenewpackagesstoredintheapplicationpackagesblob,runthefollowingcommand:
CMD
clusrun/nodegroup:AzureNodeshpcsync
Running the Client
There are two options you can choose from in order to run the Image Rendering sample:
- Run the client application. The RenderCmd client application uploads the input files to Windows Azure storage, submits the parametric sweep job, and downloads the outputted files from the storage. To use this technique refer to Tasks 1 and 4.
- Submit the parametric sweep job manually. This option requires manually uploading the input files to the storage, submitting the parametric sweep job in the HPC Job Scheduler, and then viewing the outputted images from the storage. To use this technique refer to Tasks 1, 2, and 3.
Task1–VerifyingClusterState
Inthistask,youwillverifythatthenodesinyourclusterareonline.
- OpentheHPC2008R2ClusterManagerapplicationfromStart|AllPrograms|MicrosoftHPCPack2008R2|HPCClusterManager.
- IntheClusterManagerapplication,entertheNodeManagementsectionandverifythattheWindowsAzurenodesintheclusterareonline,asshowninFigure 3:
Figure3
VerifyingtheStateoftheWindowsAzureNodes
Task 2 - Manually Uploading Instruction Files to the Blob Storage
In this task, you will upload the instruction files required by the parametric sweep application to a blob in your Windows Azure storage account.
Uploading, downloading, and browsing files in blobs is an easy task if you install one of the blob storage browsing applications, such as CloudBerry Explorer for Azure Blob Storage, or the Azure Storage Explorer. The following steps are for the CloudBerry Explorer application; you can use the same techniques with Azure Storage Explorer, but the steps may differ.
- Download and install CloudBerry Explorer for Azure Blob Storage.
- Open CloudBerry Explorer for Azure Blob Storage from Start | All Programs | CloudBerryLab | CloudBerry Explorer for Azure Blob Storage | CloudBerry Explorer for Azure Blob Storage.
- Open the File menu and select Azure Blob Storage Accounts. The Account Registration dialog will appear, as shown in Figure 4:
Figure 4
The Account Registration dialog
- Click the Add button and input the display name of the storage account, the storage account name, and the account’s shared key (primary access key). Use the same storage account settings you used in Task 1 for the AzureBlobCopy project.
- Click the Test Connection button and wait for the approval message. Close the approval message, click OK to add the storage account, and then close the Azure Blob Storage Accounts dialog.
- You should now see your blob storage in the left pane of the application, and your machine (“My Computer”) in the right pane.
- Create a new container in the blob by clicking on the New Container button in the left pane, as shown in Figure 5:
Figure 5
Creating a new blob container
- In the Create New Container dialog, set the container name to input, select the Full public read access option from the Access control options as shown in Figure 6, and click OK.
Figure 6
The Create New Container dialog
Note: If the container already exists, it is preferable that you delete it and create it again using the above settings.
- Locate the newly created container in the list of containers and double-click its name to see its contents (it should be empty for now).
- In the right pane, navigate to the labs folder, and locate the RenderMan\SampleInput folder.
- Select all the files (40 .zip files) from the SampleInput folder and click the Copy button. Click Yes in the confirmation message that appears, and then wait for the copy procedure to complete.
Note: The content of the folder is about 76MB, so this may take a couple of minutes, depending on your network bandwidth.
- After the upload completes, close the CloudBerry Explorer application.
Task 3– Submitting the Job Manually Through the HPC Job Scheduler
In this task, you will create a parametric sweep job for the image rendering application.
- In the Cluster Manager application, enter the Job Management section and click New Job… in the Actions pane as shown in Figure7:
Figure 7
Create a New Job
- In the New Job dialog, set the Job name to Image Rendering, as shown in Figure 8:
Figure 8
Setting the name of the job
- Still in the New Job dialog, click the Edit Tasks option, click the arrow next to the Add button, and then click Parametric Sweep Task…, as shown inFigure 9:
Figure 9
New Parametric Sweep Task
- In the Parametric Sweep Task dialog, enter the following information and then click OK:
- Task name: ImageRendering
- Start value: 0
- End value: 39
- Command line: %CCP_PACKAGE_ROOT%\Aqsis\bin\run.cmd frame-*
- Working Directory: %CCP_PACKAGE_ROOT%
Figure 10
Setting the parametric sweep task details
- Click the ResourceSelection option, check the Run this job only on nodes that are members of all the following groups checkbox, and then add the AzureNodes group, as shown inFigure 11:
Figure 11
Selecting a node group for the job
- Click the Submit button to start the parametric sweep job.
- While the job is running, enter the Job Management section, select the Image Rendering job from the active jobs, and click on View Job… in the Actions pane, as shown inFigure 12:
Figure 12
View running job information
- The View Job dialog displays the current state of the job, as shown inFigure 13:
Figure 13
Running job’s state
- Click the Refresh button every couple of seconds to see the change in the number of finished tasks.
- After the job completes, open CloudBerry Explorer for Azure Blob Storage from Start | All Programs | CloudBerryLab | CloudBerry Explorer for Azure Blob Storage | CloudBerry Explorer for Azure Blob Storage.
- Use the CloudBerry Explorer to view the contents of the output blob container, as shown in Figure 14:
Figure 14
Viewing the contents of the output blob container
- Double-click any of the .tif files to view the rendered image.
Task 4 – Running the Client Application
In this task, you will run the client application that creates the parametric sweep job.
Note: If you prefer to submit the job manually, you can skip this task
- Open the command prompt window fromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
- Navigate to the ImageRendering labs folder, and from there to Source\RenderCmd\bin\debug, and then run the following command to start the parametric sweep job:
CMD
RenderCmd ..\..\..\..\..\RenderMan\SampleInput
- While you wait for the application to finish rendering, you can inspect the status of the parametric sweep job using the HPC 2008 R2 Cluster Manager utility, as shown in Figure 15:
Figure 15
Status of the Parametric Sweep Rendering Job
- Wait a couple of minutes for the application to complete and then navigate to the RenderMan\SampleInput\output folder to inspect the rendered .tiff images.
Summary
AfterrunningtheImageRenderingsample,youshouldhavelearnedthefollowing:
- HowtoworkwithWindowsAzureblobstorage.
- HowtopackageanapplicationforWindowsAzure.
- HowtodeployanapplicationtoWindowsAzurenodesandtoon-premisesnodes.
- Howtosubmitaparametricsweepjobfroma.NETclientapplication.
- Howtocheckarunningjob’sstatus.