Skip to content

Commit b2b2a25

Browse files
Add BNB_TEST_DEVICE env var to manually select device for unit tests
1 parent 4e6006a commit b2b2a25

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tests/helpers.py

Lines changed: 5 additions & 0 deletions
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)