Skip to content

Commit

Permalink
Remove Cuda support.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbackstein committed Apr 21, 2023
1 parent 57621bb commit 258650f
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 453 deletions.
24 changes: 1 addition & 23 deletions api/src/main/java/ai/djl/engine/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
import ai.djl.training.optimizer.Optimizer;
import ai.djl.util.RandomUtils;
import ai.djl.util.Utils;
import ai.djl.util.cuda.CudaUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.lang.management.MemoryUsage;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -207,11 +205,7 @@ public static Engine getEngine(String engineName) {
*/
public Device defaultDevice() {
if (defaultDevice == null) {
if (hasCapability(StandardCapabilities.CUDA) && CudaUtils.getGpuCount() > 0) {
defaultDevice = Device.gpu();
} else {
defaultDevice = Device.cpu();
}
defaultDevice = Device.cpu();
}
return defaultDevice;
}
Expand Down Expand Up @@ -258,9 +252,6 @@ public Device[] getDevices(int maxGpus) {
* @return the number of GPUs available in the system
*/
public int getGpuCount() {
if (hasCapability(StandardCapabilities.CUDA)) {
return CudaUtils.getGpuCount();
}
return 0;
}

Expand Down Expand Up @@ -397,19 +388,6 @@ public static void debugEnvironment() {
e.printStackTrace(System.out);
}

System.out.println();
System.out.println("------------------ CUDA -----------------");
int gpuCount = CudaUtils.getGpuCount();
System.out.println("GPU Count: " + gpuCount);
if (gpuCount > 0) {
System.out.println("CUDA: " + CudaUtils.getCudaVersionString());
System.out.println("ARCH: " + CudaUtils.getComputeCapability(0));
}
for (int i = 0; i < gpuCount; ++i) {
Device device = Device.gpu(i);
MemoryUsage mem = CudaUtils.getGpuMemory(device);
System.out.println("GPU(" + i + ") memory used: " + mem.getCommitted() + " bytes");
}

System.out.println();
System.out.println("----------------- Engines ---------------");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
*/
package ai.djl.training.listener;

import ai.djl.Device;
import ai.djl.metric.Metric;
import ai.djl.metric.Metrics;
import ai.djl.metric.Unit;
import ai.djl.training.Trainer;
import ai.djl.util.cuda.CudaUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -106,15 +104,6 @@ public static void collectMemoryInfo(Metrics metrics) {

metrics.addMetric("Heap", heapUsed, Unit.BYTES);
metrics.addMetric("NonHeap", nonHeapUsed, Unit.BYTES);
int gpuCount = CudaUtils.getGpuCount();

// CudaUtils.getGpuMemory() will allocates memory on GPUs if CUDA runtime is not
// initialized.
for (int i = 0; i < gpuCount; ++i) {
Device device = Device.gpu(i);
MemoryUsage mem = CudaUtils.getGpuMemory(device);
metrics.addMetric("GPU-" + i, mem.getCommitted(), Unit.BYTES);
}
}
}

Expand All @@ -141,10 +130,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 = CudaUtils.getGpuCount();
for (int i = 0; i < gpuCount; ++i) {
list.addAll(metrics.getMetric("GPU-" + i));
}

for (Metric metric : list) {
writer.append(metric.toString());
writer.newLine();
Expand Down
10 changes: 3 additions & 7 deletions api/src/main/java/ai/djl/util/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package ai.djl.util;

import ai.djl.util.cuda.CudaUtils;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -185,12 +184,9 @@ static Platform fromSystem() {
if ("amd64".equals(platform.osArch)) {
platform.osArch = "x86_64";
}
if (CudaUtils.getGpuCount() > 0) {
platform.flavor = "cu" + CudaUtils.getCudaVersionString();
platform.cudaArch = CudaUtils.getComputeCapability(0);
} else {
platform.flavor = "cpu";
}

platform.flavor = "cpu";

return platform;
}

Expand Down
88 changes: 0 additions & 88 deletions api/src/main/java/ai/djl/util/cuda/CudaLibrary.java

This file was deleted.

Loading

0 comments on commit 258650f

Please sign in to comment.