diff --git a/api/src/main/java/ai/djl/training/listener/MemoryTrainingListener.java b/api/src/main/java/ai/djl/training/listener/MemoryTrainingListener.java index 5cb6303840c..0029bb6312a 100644 --- a/api/src/main/java/ai/djl/training/listener/MemoryTrainingListener.java +++ b/api/src/main/java/ai/djl/training/listener/MemoryTrainingListener.java @@ -103,7 +103,7 @@ public static void collectMemoryInfo(Metrics metrics) { metrics.addMetric("Heap", heapUsed, "bytes"); metrics.addMetric("NonHeap", nonHeapUsed, "bytes"); - int gpuCount = Device.getGpuCount(); + int gpuCount = CudaUtils.getGpuCount(); // CudaUtils.getGpuMemory() will allocates memory on GPUs if CUDA runtime is not // initialized. @@ -138,7 +138,7 @@ public static void dumpMemoryInfo(Metrics metrics, String logDir) { list.addAll(metrics.getMetric("NonHeap")); list.addAll(metrics.getMetric("cpu")); list.addAll(metrics.getMetric("rss")); - int gpuCount = Device.getGpuCount(); + int gpuCount = CudaUtils.getGpuCount(); for (int i = 0; i < gpuCount; ++i) { list.addAll(metrics.getMetric("GPU-" + i)); } diff --git a/serving/serving/build.gradle b/serving/serving/build.gradle index 432a05bcea2..4b08420ee39 100644 --- a/serving/serving/build.gradle +++ b/serving/serving/build.gradle @@ -46,6 +46,7 @@ run { systemProperties System.getProperties() systemProperties.remove("user.dir") systemProperty("file.encoding", "UTF-8") + systemProperty("ai.djl.pytorch.num_interop_threads", "1") applicationDefaultJvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=4000"] } @@ -56,7 +57,7 @@ startScripts { text = text.replace('DEFAULT_JVM_OPTS=""', 'if [[ "${MODEL_SERVER_HOME}" = "" ]] ; then\n' + ' export MODEL_SERVER_HOME=${APP_HOME}\n' + 'fi\n' + - 'DEFAULT_JVM_OPTS="-Dlog4j.configurationFile=${APP_HOME}/conf/log4j2.xml"\n') + 'DEFAULT_JVM_OPTS="-Dai.djl.pytorch.num_interop_threads=1 -Dlog4j.configurationFile=${APP_HOME}/conf/log4j2.xml"\n') text = text.replaceAll('CLASSPATH=\\$APP_HOME/lib/.*', 'CLASSPATH=\\$APP_HOME/lib/*') unixScript.text = text }