@@ -181,6 +181,7 @@ var Deployment = &cli.Command{
181181 ContainerPort : deployment .ContainerPort ,
182182 RequestedMemoryMB : deployment .RequestedMemoryMB ,
183183 RequestedCPU : deployment .RequestedCPU ,
184+ ExperimentalRequestedGPU : & deployment .RequestedGPU , // TODO: add support for final API field when it exists
184185 AdditionalContainerPorts : deployment .AdditionalContainerPorts ,
185186 Env : deployment .Env ,
186187 DeploymentTag : deploymentTag ,
@@ -297,6 +298,17 @@ var (
297298 Category : "Deployment:" ,
298299 }
299300
301+ requestedGPUFlag = & workaround.FloatFlag {
302+ Name : "requested-gpu" ,
303+ Sources : cli .NewValueSourceChain (
304+ cli .EnvVar (deploymentEnvVar ("REQUESTED_GPU" )),
305+ altsrc .ConfigFile (configFlag .Name , "deployment.requested-gpu" ),
306+ ),
307+ Usage : "`<gpus>` to allocate to your process" ,
308+ Persistent : true ,
309+ Category : "Deployment:" ,
310+ }
311+
300312 fromLatestFlag = & cli.BoolFlag {
301313 Name : "from-latest" ,
302314 Sources : cli .EnvVars (deploymentEnvVar ("FROM_LATEST" )),
@@ -457,6 +469,7 @@ type CreateDeploymentConfig struct {
457469 ContainerPort int
458470 RequestedMemoryMB float64
459471 RequestedCPU float64
472+ RequestedGPU float64
460473 AdditionalContainerPorts []components.ContainerPort
461474 Env []components.DeploymentConfigV3Env
462475 DeploymentTag string
@@ -490,6 +503,7 @@ func (c *CreateDeploymentConfig) Load(cmd *cli.Command) error {
490503 c .ContainerPort = int (cmd .Int (containerPortFlag .Name ))
491504 c .RequestedMemoryMB = cmd .Float (requestedMemoryFlag .Name )
492505 c .RequestedCPU = cmd .Float (requestedCPUFlag .Name )
506+ c .RequestedGPU = cmd .Float (requestedGPUFlag .Name )
493507 c .DeploymentTag = cmd .String (deploymentTagFlag .Name )
494508
495509 addlPorts := cmd .StringSlice (additionalContainerPortsFlag .Name )
@@ -542,6 +556,11 @@ func (c *CreateDeploymentConfig) Merge(latest *components.DeploymentV3) {
542556 c .RequestedCPU = latest .RequestedCPU
543557 }
544558
559+ if c .RequestedGPU == 0 {
560+ // TODO: add support for final API field when it exists
561+ c .RequestedGPU = * latest .ExperimentalRequestedGPU
562+ }
563+
545564 if len (c .AdditionalContainerPorts ) == 0 {
546565 c .AdditionalContainerPorts = latest .AdditionalContainerPorts
547566 }
0 commit comments