Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoiding error while --device is "cpu" #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

queuecameras
Copy link

Title of PR:

Make code device-agnostic by replacing cuda() with to(device)


Description:

This PR refactors the code to make it device-agnostic. Specifically, it replaces the hardcoded .cuda() call with the more flexible .to(device) method. This change ensures that the code can run seamlessly on either a CPU or a GPU, depending on the environment.

Changes made:

  • Introduced a device variable that checks if a GPU is available and sets the device accordingly.
  • Replaced the .cuda() call with .to(device) to move the tensor to the appropriate device.

Benefits:

  • Flexibility: The code can now run on either CPU or GPU without modification.
  • Compatibility: Ensures compatibility across different environments, making it easier to run the code on various machines without requiring manual changes.

@queuecameras queuecameras changed the title fix: avoiding error while device is CPU fix: avoiding error while --device is "cpu" Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant