Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
IntroductionQuickstartClient APIWorker APIFile I/OBackends
getGPUBackendloadGPUProvidergetGPUBackendInfoGPUBackendsaveloadload_safetensorsSerializationFormatSaveOptionsLoadOptions
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. torch-node
  3. torch-node
  4. getGPUBackend

torch-node.getGPUBackend

function getGPUBackend(): GPUBackend

Get the configured GPU backend from environment.

Reads the TORCH_GPU_BACKEND environment variable and returns the corresponding backend type. If not set or invalid, defaults to 'dawn'.

Returns

GPUBackend– The selected GPU backend type

Examples

// Returns 'wgpu-native' if TORCH_GPU_BACKEND=wgpu-native
const backend = getGPUBackend();
console.log(`Using GPU backend: ${backend}`);
Previous
Testing
Next
getGPUBackendInfo