Home
%3CLINGO-SUB%20id%3D%22lingo-sub-844391%22%20slang%3D%22en-US%22%3EResolving%20complex%20software%20and%20hardware%20dependencies%20in%20Azure%20DevOps%20pipelines%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-844391%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20a%20previous%20blog%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fblog%2Fbreaking-the-wall-between-data-scientists-and-app-developers-with-azure-devops%2F%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epost%3C%2FA%3E%2C%20I%20provided%20an%20overview%20of%20how%20Azure%20%3CA%20href%3D%22https%3A%2F%2Fdev.azure.com%2F%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDevOps%3C%2FA%3Ecan%20be%20used%20to%20reduce%20the%20friction%20between%20app%20developers%20and%20data%20scientists.%20In%20this%20blog%20post%2C%20I%E2%80%99m%20going%20to%20address%20how%20to%20deal%20with%20an%20advanced%20scenario%2C%20where%20we%20ditch%20the%20standard%20build%20environment%20of%20Azure%20DevOps%20to%20instead%20create%20a%20custom%20environment%20to%20satisfy%20a%20complex%20set%20of%20hardware%20and%20software%20dependencies.%20Figure%201%20provides%20a%20diagram%20of%20a%20decision%20process%20followed%20by%20a%20description%20of%20the%20components%20and%20rationale%20for%20selecting%20one%20path%20over%20another.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F130754iEC9E0D4FD1097BDE%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFigure%201%3A%20How%20to%20decide%20when%20to%20go%20with%20a%20self-hosted%20agent%20and%20when%20to%20use%20a%20container%20job.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1820172468%22%20id%3D%22toc-hId-1820172468%22%20id%3D%22toc-hId-1820172468%22%3EMicrosoft-hosted%20build%20agents%3C%2FH2%3E%0A%3CP%3EFor%20a%20lot%20of%20scenarios%2C%20Azure%20DevOps%20users%20may%20be%20able%20to%20rely%20on%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Fagents%2Fhosted%3Fview%3Dazure-devops%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMicrosoft-hosted%20build%20agents%3C%2FA%3E.%20Let%E2%80%99s%20refer%20to%20this%20as%20the%20standard%20build%20environment.%20In%20these%20cases%2C%20you%20could%20simply%20create%20a%20%3CA%20href%3D%22https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FYAML%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EYAML%3C%2FA%3Edefinition%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Fcustomize-pipeline%3Fview%3Dazure-devops%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ecreate%20an%20Azure%20build%20pipeline%3C%2FA%3E.%20This%20may%20look%20something%20like%20this%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Etrigger%3A%0A-%20master%0A%0Apool%3A%0A%20%20%20vmImage%3A%20'Ubuntu-16.04'%0A%0Asteps%3A%0A-%20script%3A%20python%20setup.py%20bdist_wheel%0A%20%20displayName%3A%20Create%20Python%20wheel%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20pipeline%20will%20be%20triggered%20and%20executed%20on%20an%20Ubuntu-16.04%20virtual%20machine%2C%20to%20build%20a%20%3CA%20href%3D%22https%3A%2F%2Fpackaging.python.org%2Fglossary%2F%23term-wheel%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epython%20wheel%3C%2FA%3Eof%20your%20source%20code%20every%20time%20a%20code%20commit%20is%20pushed%20to%20the%20master%20branch%20of%20your%20repository.%3C%2FP%3E%0A%3CP%3EIf%20your%20build%20pipeline%20requires%20software%20dependencies%2C%20it%20will%20often%20be%20sufficient%20to%20create%20and%20activate%20a%20%3CA%20href%3D%22https%3A%2F%2Fconda.io%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Econda%3C%2FA%3Eenvironment%20at%20the%20beginning%20of%20your%20pipeline%2C%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Ftasks%2Fpackage%2Fconda-environment%3Fview%3Dazure-devops%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECondaEnvironment%3C%2FA%3Etask%20of%20Azure%20DevOps.%3C%2FP%3E%0A%3CP%3EHowever%2C%20in%20some%20scenarios%20you%20will%20hit%20a%20wall%20with%20this%20approach.%20Let%E2%80%99s%20use%20a%20concrete%20scenario%2C%20say%20you%20created%20a%20custom%20neural%20network%20architecture%20in%20%3CA%20href%3D%22https%3A%2F%2Fpytorch.org%2Ftutorials%2Fadvanced%2Fcpp_extension.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPyTorch%3C%2FA%3E%2C%20including%20%3CA%20href%3D%22https%3A%2F%2Fpytorch.org%2Ftutorials%2Fadvanced%2Fcpp_extension.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EC%2B%2B%20extensions%3C%2FA%3Eto%20the%20PyTorch%20backend.%20You%20decided%20to%20implement%20these%20extensions%20in%20C%2B%2B%2C%20instead%20of%20extending%20the%20PyTorch%20%3CA%20href%3D%22https%3A%2F%2Fpytorch.org%2Fdocs%2Fmaster%2Fnotes%2Fextending.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EFunction%20or%20Module%20in%20python%3C%2FA%3E%2C%20because%20you%20want%20these%20operations%20to%20execute%20very%20quickly%20or%20because%20your%20extensions%20interact%20with%20other%20C%2B%2B%20libraries.%20In%20this%20case%2C%20you%20need%20to%20have%20complete%20control%20over%20the%20hardware%20and%20software%20-%20and%20having%20control%20over%20the%20operating%20system%20of%20your%20build%20environment%20would%20certainly%20make%20things%20easier.%20That%20is%2C%20it%20might%20be%20time%20to%20switch%20to%20using%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Fprocess%2Fcontainer-phases%3Fview%3Dazure-devops%26amp%3Btabs%3Dyamlv%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Econtainer%20jobs%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Fagents%2Fv2-linux%3Fview%3Dazure-devops%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eself-hosted%20agents%3C%2FA%3E%2C%20or%20both.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--731984493%22%20id%3D%22toc-hId--731984493%22%20id%3D%22toc-hId--731984493%22%3EContainer%20Jobs%3C%2FH2%3E%0A%3CP%3EContainer%20jobs%20give%20you%20more%20control%20over%20the%20build%20environment%20than%20what%20you%20get%20from%20creating%20a%20Conda%20environment%20on%20a%20build%20agent%20because%20containers%20offer%20isolation%20from%20the%20host%20operating%20system.%20This%20allows%20you%20to%20pin%20versions%20of%20software%20that%20are%20not%20available%20as%20Conda%20packages%20or%20software%20that%20is%20better%20to%20install%20system-wide%20(e.g.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.nvidia.com%2Fcuda%2Fcuda-installation-guide-linux%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ecuda%20toolkit%3C%2FA%3E).%20You%20can%20even%20run%20a%20different%20operating%20system%20inside%20your%20container%20than%20the%20operating%20system%20that%20is%20running%20on%20the%20host%20(e.g.%20run%20an%20Ubuntu%20Linux%20container%20on%20a%20Windows%2010%20VM).%20This%20can%20be%20immensely%20useful%2C%20not%20only%20if%20your%20build%20environment%20has%20a%20complex%20set%20of%20dependencies%2C%20but%20also%20if%20you%20want%20to%20preserve%20the%20reproducibility%20of%20your%20pipeline%20for%20a%20long%20time%20into%20the%20future.%3C%2FP%3E%0A%3CP%3EExecuting%20your%20build%20pipeline%20inside%20your%20custom-made%20container%20is%20straightforward.%20You%20simply%20include%20a%20section%20towards%20the%20top%20of%20your%20pipeline%20YAML%20file%20that%20specifies%20which%20container%20to%20use.%20For%20example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Econtainer%3A%0A%20%20%20%20image%3A%20wopauli01234567.azurecr.io%2Fubuntu-16.04_cuda9%3Alatest%0A%20%20%20%20endpoint%3A%20azureContainerRegistryConnection%0A%20%20%20%20options%3A%20%22--runtime%3Dnvidia%20-e%20NVIDIA_VISIBLE_DEVICES%3Dall%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20provide%20the%20registry%20(my%20private%20Azure%20Container%20Registry%20in%20this%20example)%2C%20name%2C%20and%20tag%20of%20the%20container%20image%2C%20an%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Fprocess%2Fcontainer-phases%3Fview%3Dazure-devops%26amp%3Btabs%3Dyaml%23endpoints%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eendpoint%3C%2FA%3Efor%20a%20secure%20connection%20for%20pulling%20the%20image%2C%20and%20optional%20arguments%20for%20how%20to%20start%20the%20container.%20In%20this%20case%2C%20we%20want%20the%20container%20to%20have%20access%20to%20all%20NVIDIA%20%3CA%20href%3D%22https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FCUDA%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECUDA%3C%2FA%3Ecards%20on%20the%20build%20agent.%20Now%20each%20step%20of%20our%20pipeline%20will%20be%20run%20inside%20the%20container.%3C%2FP%3E%0A%3CP%3EYou%20may%20ask%3A%20How%20would%20one%20build%20a%20custom%20Docker%20image%20suitable%20for%20Azure%20DevOps%3F%20In%20my%20opinion%2C%20you%20have%20at%20least%20three%20great%20options%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EStart%20with%20one%20of%20the%20docker%20files%20offered%20by%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmachine-learning%2Fservice%2Fconcept-ml-pipelines%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Machine%20Learning%20service%3C%2FA%3Ein%20its%20repository%20for%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzureML-Containers%2F%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzureML-Containers%3C%2FA%3E.%20Simply%20add%20your%20dependencies%20to%20one%20of%20those%20%3CA%20href%3D%22https%3A%2F%2Fdocs.docker.com%2Fengine%2Freference%2Fbuilder%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDockerfiles%3C%2FA%3E.%3C%2FLI%3E%0A%3CLI%3EAlternatively%2C%20you%20could%20use%20either%20a%20container%20image%20that%20you%20previously%20used%20for%20deployment%2C%20or%20one%20that%20you%20used%20for%20training%20your%20model%20on%20AML%20compute.%20You%20would%20then%20create%20your%20own%20Dockerfile%20but%20specify%20that%20image%20as%20the%20base%20image%20to%20start%20from%20(see%20Figure%202).%3C%2FLI%3E%0A%3CLI%3EOf%20course%2C%20the%20cleanest%20solution%20would%20be%20to%20create%20your%20own%20Dockerfile%20from%20scratch.%20This%20allows%20you%20complete%20control%20over%20what%20is%20installed%20in%20the%20image%2C%20potentially%20reducing%20a%20lot%20of%20overhead.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F130755i8C957648AC261666%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_1.png%22%20title%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFigure%202.%20A%20simple%20Dockerfile%20that%20pulls%20an%20existing%20base%20image%20from%20the%20azure%20container%20registry%20and%20adds%20the%20dependencies%20needed%20for%20our%20project%20(cuda-toolkit%20and%20Azure%20CLI).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1010825842%22%20id%3D%22toc-hId-1010825842%22%20id%3D%22toc-hId-1010825842%22%3ESelf-hosted%20agents%3C%2FH2%3E%0A%3CP%3EVery%20often%20Microsoft-hosted%20agents%20will%20be%20the%20most%20convenient%20option%20because%20you%20don%E2%80%99t%20have%20to%20worry%20about%20upgrades%20and%20maintenance.%20Every%20time%20you%20run%20your%20build%20pipeline%20you%20get%20a%20fresh%20virtual%20machine%20with%20all%20upgrades%20taken%20care%20of.%3C%2FP%3E%0A%3CP%3EHowever%2C%20in%20our%20use-case%2C%20we%20need%20to%20have%20a%20VM%20with%20a%20NVIDIA%20CUDA%20card%20on%20it%2C%20so%20that%20we%20can%20compile%20our%20C%2B%2B%20extensions%20for%20PyTorch%20with%20CUDA%20support.%20This%20means%20we%20will%20have%20to%20use%20a%20self-hosted%20agent.%20One%20good%20option%20is%20to%20configure%20a%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fservices%2Fvirtual-machines%2Fdata-science-virtual-machines%2F%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EData%20Science%20VM%3C%2FA%3Eto%20be%20your%20self-hosted%20agent.%20The%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Fagents%2Fv2-linux%3Fview%3Dazure-devops%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Einstructions%3C%2FA%3Efor%20creating%20a%20self-hosted%20agent%20are%20straightforward%20and%20should%20only%20take%20a%20couple%20of%20minutes%20to%20complete.%20After%20you%20are%20done%20setting%20up%20your%20agent%20and%20adding%20it%20to%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Fagents%2Fpools-queues%3Fview%3Dazure-devops%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eagent%20pool%3C%2FA%3E%2C%20you%20can%20simply%20change%20the%20corresponding%20line%20in%20your%20pipeline%20definition%20shared%20above.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Epool%3A%0A%20%20name%3A%20wopauliM60%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1541331119%22%20id%3D%22toc-hId--1541331119%22%20id%3D%22toc-hId--1541331119%22%3ESummary%3C%2FH2%3E%0A%3CP%3EWhile%20Microsoft-hosted%20agents%20in%20combination%20with%20a%20conda%20environment%20will%20often%20be%20the%20most%20convenient%20option%2C%20Azure%20gives%20you%20a%20lot%20of%20options%20to%20configure%20the%20build%20environment%20to%20meet%20your%20runtime%20needs.%20In%20this%20blog%20post%2C%20I%20tried%20to%20outline%20a%20scenario%20that%20demonstrates%20the%20limitations%20of%20the%20standard%20Azure%20DevOps%20environment%20in%20which%20the%20build%20pipeline%20is%20executed%20directly%20on%20a%20Microsoft-hosted%20build%20agent%2C%20and%20how%20to%20get%20around%20these%20limitations.%20To%20get%20more%20control%20over%20software%20dependencies%20and%20operating%20system%2C%20you%20can%20use%20Container%20jobs.%20For%20additional%20control%20over%20hardware%2C%20you%20can%20use%20a%20self-hosted%20build%20agent.%20Note%20that%20the%20decisions%20whether%20to%20run%20your%20pipeline%20inside%20a%20container%20and%20whether%20to%20use%20a%20self-hosted%20agent%20are%20independent.%20You%20can%20directly%20run%20your%20pipeline%20on%20a%20self-hosted%20agent%2C%20or%20inside%20a%20container.%20You%20can%20also%20execute%20your%20pipeline%20in%20a%20container%20on%20a%20Microsoft-hosted%20agent%20or%20on%20a%20self-hosted%20agent.%3C%2FP%3E%0A%3CP%3EAs%20always%2C%20please%20leave%20comments%20and%20questions%20below%2C%20or%20email%20me.%20I%E2%80%99d%20be%20especially%20interested%20whether%20you%20experienced%20other%20situations%20in%20which%20you%20had%20to%20go%20with%20a%20container%20job%20or%20a%20self-hosted%20agent!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-844391%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20a%20previous%20blog%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fblog%2Fbreaking-the-wall-between-data-scientists-and-app-developers-with-azure-devops%2F%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epost%3C%2FA%3E%2C%20I%20provided%20an%20overview%20of%20how%20Azure%20%3CA%20href%3D%22https%3A%2F%2Fdev.azure.com%2F%3FWT.mc_id%3Daiptechcomm-blog-azureai%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDevOps%3C%2FA%3Ecan%20be%20used%20to%20reduce%20the%20friction%20between%20app%20developers%20and%20data%20scientists.%20In%20this%20blog%20post%2C%20I%E2%80%99m%20going%20to%20address%20how%20to%20deal%20with%20an%20advanced%20scenario%2C%20where%20we%20ditch%20the%20standard%20build%20environment%20of%20Azure%20DevOps%20to%20instead%20create%20a%20custom%20environment%20to%20satisfy%20a%20complex%20set%20of%20hardware%20and%20software%20dependencies.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-SUB%20id%3D%22lingo-sub-854996%22%20slang%3D%22en-US%22%3ERE%3A%20Resolving%20complex%20software%20and%20hardware%20dependencies%20in%20Azure%20DevOps%20pipelines%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-854996%22%20slang%3D%22en-US%22%3EI%20cant%20not%20wait%20to%20get%20to%20help%20in%20any%20way%20that%20I%20can%20if%20you%20want%20a%20bunch%20of%20data%20that%20is%20something%20I'm%20that%20some%20I%20could%20really%20need%20to%20be%20mapped%20configured%20thanks%20for%20letting%20me%20join%20you.%3C%2FLINGO-BODY%3E
Microsoft

In a previous blog post, I provided an overview of how Azure DevOps can be used to reduce the friction between app developers and data scientists. In this blog post, I’m going to address how to deal with an advanced scenario, where we ditch the standard build environment of Azure DevOps to instead create a custom environment to satisfy a complex set of hardware and software dependencies. Figure 1 provides a diagram of a decision process followed by a description of the components and rationale for selecting one path over another.

 

clipboard_image_0.png

Figure 1: How to decide when to go with a self-hosted agent and when to use a container job.

 

Microsoft-hosted build agents

For a lot of scenarios, Azure DevOps users may be able to rely on Microsoft-hosted build agents. Let’s refer to this as the standard build environment. In these cases, you could simply create a YAML definition to create an Azure build pipeline. This may look something like this:

 

 

trigger:
- master

pool:
   vmImage: 'Ubuntu-16.04'

steps:
- script: python setup.py bdist_wheel
  displayName: Create Python wheel

 

 

This pipeline will be triggered and executed on an Ubuntu-16.04 virtual machine, to build a python wheel of your source code every time a code commit is pushed to the master branch of your repository.

If your build pipeline requires software dependencies, it will often be sufficient to create and activate a conda environment at the beginning of your pipeline, using the CondaEnvironment task of Azure DevOps.

However, in some scenarios you will hit a wall with this approach. Let’s use a concrete scenario, say you created a custom neural network architecture in PyTorch, including C++ extensions to the PyTorch backend. You decided to implement these extensions in C++, instead of extending the PyTorch Function or Module in python, because you want these operations to execute very quickly or because your extensions interact with other C++ libraries. In this case, you need to have complete control over the hardware and software - and having control over the operating system of your build environment would certainly make things easier. That is, it might be time to switch to using container jobs, self-hosted agents, or both.

 

Container Jobs

Container jobs give you more control over the build environment than what you get from creating a Conda environment on a build agent because containers offer isolation from the host operating system. This allows you to pin versions of software that are not available as Conda packages or software that is better to install system-wide (e.g. cuda toolkit). You can even run a different operating system inside your container than the operating system that is running on the host (e.g. run an Ubuntu Linux container on a Windows 10 VM). This can be immensely useful, not only if your build environment has a complex set of dependencies, but also if you want to preserve the reproducibility of your pipeline for a long time into the future.

Executing your build pipeline inside your custom-made container is straightforward. You simply include a section towards the top of your pipeline YAML file that specifies which container to use. For example:

 

 

container:
    image: wopauli01234567.azurecr.io/ubuntu-16.04_cuda9:latest
    endpoint: azureContainerRegistryConnection
    options: "--runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all"

 

 

We provide the registry (my private Azure Container Registry in this example), name, and tag of the container image, an endpoint for a secure connection for pulling the image, and optional arguments for how to start the container. In this case, we want the container to have access to all NVIDIA CUDA cards on the build agent. Now each step of our pipeline will be run inside the container.

You may ask: How would one build a custom Docker image suitable for Azure DevOps? In my opinion, you have at least three great options:

  • Start with one of the docker files offered by Azure Machine Learning service in its repository for AzureML-Containers. Simply add your dependencies to one of those Dockerfiles.
  • Alternatively, you could use either a container image that you previously used for deployment, or one that you used for training your model on AML compute. You would then create your own Dockerfile but specify that image as the base image to start from (see Figure 2).
  • Of course, the cleanest solution would be to create your own Dockerfile from scratch. This allows you complete control over what is installed in the image, potentially reducing a lot of overhead.

clipboard_image_1.png

Figure 2. A simple Dockerfile that pulls an existing base image from the azure container registry and adds the dependencies needed for our project (cuda-toolkit and Azure CLI).

 

Self-hosted agents

Very often Microsoft-hosted agents will be the most convenient option because you don’t have to worry about upgrades and maintenance. Every time you run your build pipeline you get a fresh virtual machine with all upgrades taken care of.

However, in our use-case, we need to have a VM with a NVIDIA CUDA card on it, so that we can compile our C++ extensions for PyTorch with CUDA support. This means we will have to use a self-hosted agent. One good option is to configure a Data Science VM to be your self-hosted agent. The instructions for creating a self-hosted agent are straightforward and should only take a couple of minutes to complete. After you are done setting up your agent and adding it to the agent pool, you can simply change the corresponding line in your pipeline definition shared above.

 

 

pool:
  name: wopauliM60

 

 

 

Summary

While Microsoft-hosted agents in combination with a conda environment will often be the most convenient option, Azure gives you a lot of options to configure the build environment to meet your runtime needs. In this blog post, I tried to outline a scenario that demonstrates the limitations of the standard Azure DevOps environment in which the build pipeline is executed directly on a Microsoft-hosted build agent, and how to get around these limitations. To get more control over software dependencies and operating system, you can use Container jobs. For additional control over hardware, you can use a self-hosted build agent. Note that the decisions whether to run your pipeline inside a container and whether to use a self-hosted agent are independent. You can directly run your pipeline on a self-hosted agent, or inside a container. You can also execute your pipeline in a container on a Microsoft-hosted agent or on a self-hosted agent.

As always, please leave comments and questions below, or email me. I’d be especially interested whether you experienced other situations in which you had to go with a container job or a self-hosted agent!

1 Comment
New Contributor
I cant not wait to get to help in any way that I can if you want a bunch of data that is something I'm that some I could really need to be mapped configured thanks for letting me join you.