Skip to content

Instantly share code, notes, and snippets.

@LimHyungTae
Created February 23, 2025 03:15
Show Gist options
  • Save LimHyungTae/bff50f7e16bef023202b5caff827ec26 to your computer and use it in GitHub Desktop.
Save LimHyungTae/bff50f7e16bef023202b5caff827ec26 to your computer and use it in GitHub Desktop.
import ray
import torch
import os
import torch
print("CUDA Available:", torch.cuda.is_available())
print("CUDA Device Count:", torch.cuda.device_count())
print("Current CUDA Device:", torch.cuda.current_device())
print("CUDA Device Name:", torch.cuda.get_device_name(torch.cuda.current_device()))
print(os.environ.get("CUDA_VISIBLE_DEVICES"))
ray.init(num_gpus=1)
@ray.remote(num_gpus=1)
def check_cuda():
print(os.environ.get("CUDA_VISIBLE_DEVICES"))
return torch.cuda.is_available(), torch.cuda.device_count()
print(ray.get(check_cuda.remote()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment