Skip to content

Commit e78b887

Browse files
committed
[tt plugin] Implement logic to detect Tenstorrent devices
1 parent 45de3aa commit e78b887

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/accelerators/TT.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,23 @@ function __init__()
1616
end
1717
end
1818

19-
has_tt() = true
19+
force_tt_init() = haskey(ENV, "REACTANT_FORCE_TT_INIT")
20+
21+
function has_tt()
22+
if force_tt_init()
23+
return true
24+
end
25+
26+
# To find whether we have Tenstorrent devices, we can either
27+
#
28+
# * look for devices in `/dev/tenstorrent`, or
29+
# * look for devices in `/sys/bus/pci/devices` with `vendor` equal to `0x1e52`, something like
30+
# any(readchomp(joinpath(dir, "vendor")) == "0x1e52" for dir in readdir("/sys/bus/pci/devices"; join=true))
31+
#
32+
# The former is simpler for our current purposes, so we can go that way.
33+
dev_tt = "/dev/tenstorrent"
34+
return isdir(dev_tt) && length(readdir(dev_tt)) > 0
35+
end
2036

2137
function setup_tt_pjrt_plugin!()
2238
plugin_dir_from_env = get(ENV, "TT_PJRT_PLUGIN_DIR", nothing)

0 commit comments

Comments
 (0)