Skip to content

Commit 71ba853

Browse files
Add BNB_TEST_DEVICE env var to manually select device for unit tests
1 parent ffee75c commit 71ba853

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: tests/helpers.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import functools
22
from io import BytesIO
33
from itertools import product
4+
import os
45
import random
56
from typing import Any
67

@@ -16,6 +17,10 @@
1617

1718
@functools.cache
1819
def get_available_devices():
20+
if "BNB_TEST_DEVICE" in os.environ:
21+
# If the environment variable is set, use it directly.
22+
return [os.environ["BNB_TEST_DEVICE"]]
23+
1924
devices = ["cpu"]
2025

2126
if hasattr(torch, "accelerator"):

0 commit comments

Comments
 (0)