NextGen-GameDev / LibTorch-UE

Integrate LibTorch Unreal to create and use neural networks without leveraging Python.
MIT License
19 stars 4 forks source link

Feature Request: Conditional Inclusion of CPU and GPU Versions in Plugin #6

Open joshismyhandle opened 5 months ago

joshismyhandle commented 5 months ago

Issue Description

Currently, the plugin architecture does not dynamically include the necessary files for CPU and GPU support based on the environment it's running in. The codebase has the GPU include only. This setup requires manual intervention to switch between supported CPU and GPU versions, which is not ideal for a seamless development experience.

Proposed Solution

I propose that we enhance the plugin to use conditional statements that automatically determine the environment (CPU or GPU) and include the corresponding version dynamically. This way, the plugin can automatically detect the presence of directories such as dlls or lib within the respective CPU or GPU folders and act accordingly.

The expected structure would be:

The plugin should check for the existence of these directories and utilize the corresponding version based on what's available or specified as the target environment.

Benefits

Implementation Considerations

Request for Comments

I invite contributors to provide feedback on this proposal, especially regarding:

joshismyhandle commented 5 months ago

Automatically detecting supported architecture might not be the best method for all implementations and it could be better to implement a persistent flag in Build.cs or some other method that enables the end-user to decide what environment to use, such as a DefaultGame.ini config setting, so that computational resources can be effectively and individually managed by the user.

joshismyhandle commented 5 months ago

It might also be worth considering to lean on CPU as the default environment rather than GPU, as the official PyTorch CPU lib files are easier to acquire and not everyone has an NVIDIA GPU but everyone of course has a CPU, but didn't include this in the issue directly as its more of a personal QoL feature.