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

Unsloth Crashes on Import When GPU Is Missing #1535

Open
Axel-At-Apollo opened this issue Jan 13, 2025 · 1 comment
Open

Unsloth Crashes on Import When GPU Is Missing #1535

Axel-At-Apollo opened this issue Jan 13, 2025 · 1 comment

Comments

@Axel-At-Apollo
Copy link

Hi! Is there a way to import unsloth without it throwing an error when a GPU is not available? This complicates unit testing setups since some of my tests will be run on a CPU-only machine. These tests subsequently fail, as they rely on functionality from files that import the library. Is there a workaround for this? If not, I suggest modifying unsloth so that it only raises an error when a GPU-dependent method is called, rather than at the import stage.

Current behaviour:

root@ef936059842d:/app# python -c "import unsloth"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.12/dist-packages/unsloth/__init__.py", line 120, in <module>
    major_version, minor_version = torch.cuda.get_device_capability()
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/cuda/__init__.py", line 509, in get_device_capability
    prop = get_device_properties(device)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/cuda/__init__.py", line 523, in get_device_properties
    _lazy_init()  # will define _get_device_properties
    ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/cuda/__init__.py", line 319, in _lazy_init
    torch._C._cuda_init()
RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx
root@ef936059842d:/app# pip show unsloth
Name: unsloth
Version: 2025.1.5
Summary: 2-5X faster LLM finetuning
Home-page: http://www.unsloth.ai
...

Proposed Behaviour:

root@ef936059842d:/app# python -c "import unsloth"
root@ef936059842d:/app# 
@Axel-At-Apollo Axel-At-Apollo changed the title unsloth Crashes on Import When GPU Is Missing Unsloth Crashes on Import When GPU Is Missing Jan 13, 2025
@danielhanchen
Copy link
Contributor

Would a try except work? Unsloth for now requires a GPU

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

No branches or pull requests

2 participants