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

RocM: filter VRAM fetch by HIP_VISIBLE_DEVICES / CUDA_VISIBLE_DEVICES #1106

Open
wants to merge 1 commit into
base: concedo
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions koboldcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,16 @@ def fetch_gpu_properties(testCL,testCU,testVK):
getamdvram = subprocess.run(['rocm-smi', '--showmeminfo', 'vram', '--csv'], capture_output=True, text=True, check=True, encoding='utf-8').stdout # fetch VRAM of devices
if getamdvram:
FetchedCUdeviceMem = [line.split(",")[1].strip() for line in getamdvram.splitlines()[1:] if line.strip()]

visible_devices = os.environ.get('HIP_VISIBLE_DEVICES') or os.environ.get('CUDA_VISIBLE_DEVICES')
if visible_devices:
use_devices = [int(n.strip()) for n in visible_devices.split(',')]

# note: can legit be an empty array, which means no GPU should be used
if use_devices is not None:
FetchedCUdevices = [FetchedCUdevices[i] for i in use_devices]
FetchedCUdeviceMem = [FetchedCUdeviceMem[i] for i in use_devices]

except Exception as e:
pass
lowestcumem = 0
Expand Down