squito commented on a change in pull request #24374: [SPARK-27366][CORE] 
Support GPU Resources in Spark job scheduling
URL: https://github.com/apache/spark/pull/24374#discussion_r275605116
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/SparkConf.scala
 ##########
 @@ -575,6 +575,27 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable 
with Logging with Seria
       }
     }
 
+    if (contains(GPUS_PER_TASK)) {
+      val executorGpus = get(EXECUTOR_GPUS)
+      val taskGpus = get(GPUS_PER_TASK)
+
+      if (executorGpus < taskGpus) {
+        throw new SparkException(
+          s"${EXECUTOR_GPUS.key} must not be less than ${GPUS_PER_TASK.key}.")
+      }
+
+      if (contains(EXECUTOR_CORES) && contains(CPUS_PER_TASK)) {
+        val executorCores = get(EXECUTOR_CORES)
+        val taskCpus = get(CPUS_PER_TASK)
+
+        if (executorCores > 0 && taskCpus > 0
+          && executorGpus * taskCpus != executorCores * taskGpus) {
 
 Review comment:
   I think it would help if the exception was more detailed about how resources 
would get wasted, though its a bit of a pain to do that. (eg. 4 cores and 3 
gpus means 1 core will always be idle, etc.)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to