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.

  1. OpenMicrosoftVisualStudio2010fromStart|AllPrograms|MicrosoftVisualStudio2010|MicrosoftVisualStudio2010.
  2. OpentheImageRendering.slnsolutionfilelocatedintheImageRendering\Sourcefolder.
  3. IntheSolutionExplorerwindow,expandtheAzureUtilitiesprojectnode,asshowninFigure 1:

Figure1

TheAzureUtilitiesproject

  1. OpentheBlobUtilities.csfileandinspecttheBlobUtilitiesclass.TheclasscontainsseveralmethodsforworkingwithWindowsAzureblobstorage:
  2. InitializeStorage.Themethodvalidatestheexistenceofarequiredblobcontainer,and,ifnecessary,createssuchacontainerandsetsitspermissions.
  3. DownloadFile.Themethoddownloadsafilefromablockblobandsavesittoaspecifiedpath.
  4. 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));

}

}

  1. DeleteFile.Themethoddeletesafilefromablockblob.
  1. IntheSolutionExplorerwindow,locatetheAzureBlobCopyproject,andinspectthecontentsoftheProgram.csfile.
    AzureBlobCopyisaconsoleapplicationthatsupportscopyingfilestoandfromWindowsAzureblobstorage.Forexample,thefollowingcommandlinedownloadsafilenamedframe-1.zipfromtheinputblobstoragetoalocalfolder:

CMD

AzureBlobCopy.exe-ActionDownload-BlobContainerinput-LocalDirc:\frames\-FileNameframe-1.zip

  1. OpentheAzureBlobCopyproject’ssettingsandinspectthefollowingtabs:
  2. Build.Theaqsisfoldercontainstheaqsisrenderingapplicationthatrunsoneachcomputenode;thisistheonlyfolderthatis copiedtothecomputenodes(on-premisesandWindowsAzure).Beforerunningtheaqsisapplication,theAzureBlobCopyutilityiscalledinordertodownloadtherenderinginstructionfilefromtheblob.Theoutputpathoftheprojectisthereforesettotheaqsis\binfolder.
  3. BuildEvents.ThePost-buildeventrunsthehpcpackcommandtopacktheaqsisapplicationandtheAzureBlobCopyutilitytoacompressedzipfilefordeploymenttoWindowsAzurecomputenodes.
  4. OpentheApp.configfilefromtheAzureBlobCopyproject.TheappSettingssectioncontainstwokeys,StorageAccountNameandStorageKey.
  5. ChangethestorageaccountnameandthestorageprimarykeytomatchyourWindowsAzurestorageaccountsettings.
  6. 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.

  1. In the Solution Explorer window, right-click the solution and select Open Folder in Windows Explorer.
  1. 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

  1. The run.cmd file executes the following commands:
  2. Runs the AzureBlobCopy utility to download the current rendering instruction file from the input blob and decompress it.
  3. 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.

  1. Runs the AzureBlobCopy utility to upload the generated .tiff image to the output blob.

Task3-InspectingtheRenderCmdClientApplication

Inthistask,youwillexploretheRenderCmdclientapplicationthatuploadstheinstructionfilestotheWindowsAzureblobstorage,submitstheparametricsweepjob,anddownloadstherenderedimagesfromtheoutputblob.

  1. IntheSolutionExplorerwindow,expandtheRenderCmdprojectnode.

Figure2

TheRenderCmdproject

  1. IntheRenderCmdproject,opentheRenderCommand.csfile,andinspectthecontentsoftheRenderCommandclass.
  2. UploadFiles.Thismethoditeratesthefilesintheinputfolderanduploadsalltherenderinstructionfilestoablob.
  3. DownloadFiles.Thismethoddownloadsthecontentsoftherenderedimages’outputblobtoalocalfolder.
  4. Run.ThismethodcallstheUploadFilesmethod,submitstheparametricsweepjob,andthencallstheDownloadFilesmethodtodownloadtherendered imagescreatedbytheparametricsweepapplication.
  5. IntheRenderCmdproject,opentheHPC.csfileandinspecttheCreateJobmethod.
  6. 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);

  1. 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.

  1. Aftersubmittingthejob,theclientapplicationwaitsuntilthejobcompletes,periodicallycheckingthejob’sstatus.
  1. IntheRenderCmdproject,opentheapp.configfileandinspecttheappSettingssection.Thissectioncontainsfoursettingsthatyouneedtochangein accordancewithyourHPCclusterdefinitionsandWindowsAzurestorageaccountsettings:
  2. HeadNodeName.Thenameofyourheadnodemachine.
  3. NodeGroup.Thegroupofcomputenodesthatwillruntheparametricsweepapplication.
  4. StorageAccountName.Thenameoftheblob storageinwhichtheinputandoutputfileswillbestored.
  5. StorageKey.TheprimarystoragekeyofthestoragespecifiedinStorageAccountName.
  6. 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.

  1. Inyourheadnodemachine,createasharenamedapps.Verifythatalltheon-premisesnodescanaccessthisshare.
  1. In the SolutionExplorer window, right-click the solution and select OpenFolderinWindowsExplorer.
  1. Copy the aqsis folder and its sub-folders to the shared folder you created in the head node.
  2. OpenthecommandpromptwindowfromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
  3. 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.

  1. 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.

  1. OpenthecommandpromptwindowfromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
  2. 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.

  1. 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:

  1. 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.
  2. 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.

  1. OpentheHPC2008R2ClusterManagerapplicationfromStart|AllPrograms|MicrosoftHPCPack2008R2|HPCClusterManager.
  1. 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.

  1. Download and install CloudBerry Explorer for Azure Blob Storage.
  2. Open CloudBerry Explorer for Azure Blob Storage from Start | All Programs | CloudBerryLab | CloudBerry Explorer for Azure Blob Storage | CloudBerry Explorer for Azure Blob Storage.
  3. 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

  1. 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.
  2. 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.
  3. You should now see your blob storage in the left pane of the application, and your machine (“My Computer”) in the right pane.
  4. 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

  1. 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.

  1. 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).
  2. In the right pane, navigate to the labs folder, and locate the RenderMan\SampleInput folder.
  3. 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.

  1. 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.

  1. 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

  1. 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

  1. 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

  1. In the Parametric Sweep Task dialog, enter the following information and then click OK:
  2. Task name: ImageRendering
  3. Start value: 0
  4. End value: 39
  5. Command line: %CCP_PACKAGE_ROOT%\Aqsis\bin\run.cmd frame-*
  6. Working Directory: %CCP_PACKAGE_ROOT%

Figure 10

Setting the parametric sweep task details

  1. 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

  1. Click the Submit button to start the parametric sweep job.
  2. 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

  1. The View Job dialog displays the current state of the job, as shown inFigure 13:

Figure 13

Running job’s state

  1. Click the Refresh button every couple of seconds to see the change in the number of finished tasks.
  2. 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.
  3. 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

  1. 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

  1. Open the command prompt window fromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
  1. 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

  1. 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

  1. 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.