Readme
HPCImageRendering
Labversion:1.0.0
Lastupdated:12/21/2018
Contents
Overview
Getting Started
Task 1 - Inspecting the AzureBlobCopy Project
Task 2 – Inspecting the RenderCmd Client Applications
Task 3 – Inspecting the Run.cmd File
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 – Running the Client Application
Summary
Overview
TheHPCImageRenderingsampledemonstrateshowtorunaparametricsweepapplicationthatrendersimagesaccordingtoinstructionfiles.TheapplicationdemonstrateshowtodownloadanduploadfilesfromWindowsAzureblobstorage,andhowtocreateaparametricsweepjobfrom.NETcode.
ThissampleusestheAqsisapplicationthatrenders3DimagesaccordingtotheRenderMan®standard.
Note: To use this sample application, download the sample RenderMan data files and extract them to the samples folder.
KeyFeatures
Thissampledemonstratesthefollowing:
- UploadingaparametricsweepapplicationpackagetoWindowsAzurenodes.
- UploadinganddownloadingfilestoWindowsAzureblobstorage.
- CreatingandrunningaparametricsweepjobinaWindowsHPC2008R2SP1cluster.
GettingStarted
Torunthissample,youmustinstalltheHPCPack2008R2ClientUtilitiesRedistributablePackagewithServicePack1andtheHPCPack2008R2SDKwithServicePack1.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.
Task2–InspectingtheRenderCmdClientApplications
Inthistask,youwillexploretheRenderCmdclientapplicationthatuploadstheinstructionfilestotheWindowsAzureblobstorage,submitstheparametricsweepjob,anddownloadstherenderedimagesfromtheoutputblob.
- IntheSolutionExplorerwindow,expandtheRenderCmdprojectnode.
Figure2
TheRenderCmdproject
- IntheRenderCmdproject,opentheRenderCommand.csfile,andinspectthecontentsoftheRenderCommandclass.
- UploadFiles.Thismethoditeratesthefilesintheinputfolderanduploadsalltherenderinstructionfiles(.ribfiles)toablobaftercompressingeachfilewiththerar.exeutility.
- 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:
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_ROOTenvironmentvariableisdefinedinWindowsAzurenodesandpointstothefolderinwhichHPCpackagedapplicationsaredeployed.
- Aftersubmittingthejob,theclientapplicationwaitsuntilthejobcompletes,periodicallycheckingthejob’sstatus.
- IntheRenderCmdproject,opentheapp.configfileandinspecttheappSettingssection.ThissectioncontainsfoursettingsthatyouneedtochangetoaccordwithyourHPCclusterdefinitionsandWindowsAzurestorageaccountsettings:
- HeadNodeName.Thenameofyourheadnodemachine.
- NodeGroup.Thegroupofcomputenodesthatwillruntheparametricsweepapplication.
- StorageAccountName.Thenameoftheblob storageinwhichtheinputandoutputfileswillbestored.
- StorageKey.TheprimarystoragekeyofthestoragespecifiedinStorageAccountName.
- BuildtheRenderCmdproject.
Task3–InspectingtheRun.cmdFile
Inthistask,youwillinspectthecontentsoftherun.cmdfiletoseewhichcommandsrunwhentheparametricsweepjobexecutesineachcomputenode.
- IntheSolutionExplorerwindow,right-clickthesolutionandselectOpenFolderinWindowsExplorer.
- IntheWindowsExplorerwindownavigatetotheaqsis\binfolder,locatetherun.cmdfile,andviewthefile’scontents:
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
- Therun.cmdfileexecutesthefollowingcommands:
- RunstheAzureBlobCopyutilitytodownloadthecurrentrenderinginstructionfilefromtheinputblobanddecompressit.
- Runstheaqsis3Drenderingapplication.
Note:Thisapplicationusestherootenvironmentvariable,whichissetaccordingtotheCCP_PACKAGE_ROOTenvironmentvariablementionedinTask2inthissection.
- RunstheAzureBlobCopyutilitytouploadthegenerated.tiffimagetotheoutputblob.
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:ComputeNodesxcopy \\MyHeadNode\apps\aqsis\*.* %CCP_PACKAGE_ROOT%\aqsis\ /EY
Task2–DeployingtheParametricSweepApplicationtoWindowsAzureNodes
Inthistask,youwilldeploytheaqsisparametricsweepapplicationtoyourWindowsAzurenodes.
- OpenthecommandpromptwindowfromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
- NavigatetotheImageRenderingsamplefolder,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:WindowsAzureNodeshpcsync
Running the Client
Task1–VerifyingClusterState
Inthistask,youwillverifythatthenodesinyourclusterareonline.
- OpentheHPC2008R2ClusterManagerapplicationfromStart|AllPrograms|MicrosoftHPCPack2008R2|HPCClusterManager.
- IntheClusterManagerapplication,entertheNodeManagementsectionandverifythattheWindowsAzurenodesintheclusterareonline,asshowninFigure 3
Figure3
VerifyingtheStateoftheWindowsAzureNodes
Task2–RunningtheClientApplication
Inthistask,youwillruntheclientapplicationthatcreatestheparametricsweepjob.
- OpenthecommandpromptwindowfromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
- NavigatetotheImageRenderingsamplefolder,andfromtheretoSource\RenderCmd\bin\debug,andthenrunthefollowingcommandtostarttheparametricsweepjob:
CMD
RenderCmd..\..\..\..\SampleInput
- Whileyouwaitfortheapplicationtofinishrendering,youcaninspectthestatusoftheparametricsweepjobusingtheHPC2008R2ClusterManagerutility,asshowninFigure 4
Figure4
StatusoftheParametricSweepRenderingJob
- WaitacoupleofminutesfortheapplicationtocompleteandthennavigatetotheImageRendering\SampleInput\outputfoldertoinspecttherendered.tiffimages.
Summary
AfterrunningtheImageRenderingsample,youshouldhavelearnedthefollowing:
- HowtoworkwithWindowsAzureblobstorage.
- HowtopackageanapplicationforWindowsAzure.
- HowtodeployanapplicationtoWindowsAzurenodesandtoon-premisesnodes.
- Howtosubmitaparametricsweepjobfroma.NETclientapplication.
- Howtocheckarunningjob’sstatus.