There are install issues because torch is imported in the setup.py of the project but it is not in the minimum environment by default. This results in pip install -e . failing for a working environment with torch listed when pip list is run.
To resolve this, I commented out these imports:
import torch
from torch.utils.cpp_extension import (BuildExtension, CppExtension,
CUDAExtension)
And preformed them in a try catch. The build should safely fail later when the module cannot be imported successfully but allows the build to complete gracefully until that time.
# --- START OF NEW CODE ---
try:
import torch
from torch.utils.cpp_extension import (BuildExtension, CppExtension,
CUDAExtension)
# Define placeholder class that acts as a real class
class BuildExtensionPlaceholder(BuildExtension):
pass
except ImportError:
# --- Safe Fallback Classes if torch is not found ---
class ExtensionPlaceholder(object):
def __init__(self, *args, **kwargs):
pass
def __call__(self, *args, **kwargs):
return {}
class BuildExtensionPlaceholder(object):
def __init__(self, *args, **kwargs):
pass
def run(self):
print("Warning: Skipping custom C++/CUDA extension build because PyTorch could not be imported.")
# Assign placeholders
CUDAExtension = ExtensionPlaceholder
CppExtension = ExtensionPlaceholder
BuildExtension = BuildExtensionPlaceholder
# Define a mock torch object for make_cuda_ext's use
class MockTorch:
@staticmethod
def cuda():
class MockCuda:
@staticmethod
def is_available():
return False
return MockCuda
torch = MockTorch()
This was provided by Gemini so please try this in a testing environment if yours has already successfully run the training script.
You can also add this argument to the setup() parameters to allow for successful build when torch is not available and CPU only will be used.
cmdclass={'build_ext': BuildExtensionPlaceholder},
There are install issues because torch is imported in the setup.py of the project but it is not in the minimum environment by default. This results in
pip install -e .failing for a working environment with torch listed whenpip listis run.To resolve this, I commented out these imports:
And preformed them in a try catch. The build should safely fail later when the module cannot be imported successfully but allows the build to complete gracefully until that time.
This was provided by Gemini so please try this in a testing environment if yours has already successfully run the training script.
You can also add this argument to the setup() parameters to allow for successful build when torch is not available and CPU only will be used.
cmdclass={'build_ext': BuildExtensionPlaceholder},