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 on WSL #5275

Open
justinkb opened this issue Jun 25, 2024 · 7 comments
Open

ROCm on WSL #5275

justinkb opened this issue Jun 25, 2024 · 7 comments
Assignees
Labels
amd Issues relating to AMD GPUs and ROCm feature request New feature or request wsl Issues using WSL

Comments

@justinkb
Copy link

Recently, AMD released preview drivers for Windows that, alongside userspace packages for WSL, enable one to use ROCm through WSL. Ollama detection of AMD GPUs in linux, however, uses the presence of loaded amdgpu drivers and other sysfs stuff to determine various properties of the GPU. These are not available with this WSL ROCm setup, nor is rocm-smi used for querying VRAM size and its usage etc. I was wondering if it was feasible to add some detection for this setup, so it can be used anyway, even if some runtime information is not available. Is runtime knowledge of the available VRAM strictly necessary? Could a user just not make sure not to load too big of a model, and in case of failing to do so, accept that the ROCm runtime will hard error out on failing hipMallocs etc? Perhaps we could warn users in the output that this might happen.

@justinkb justinkb added the feature request New feature or request label Jun 25, 2024
@jmorganca jmorganca added amd Issues relating to AMD GPUs and ROCm wsl Issues using WSL labels Jun 25, 2024
@jmorganca
Copy link
Member

cc @dhiltgen

@dhiltgen dhiltgen self-assigned this Jun 25, 2024
@dhiltgen
Copy link
Collaborator

dhiltgen commented Jun 25, 2024

The installation docs seem to imply the amdgpu driver is installed. I'll have to set up a test system so I can poke around and see what discovery options we've got. @justinkb if you have already done so, can you check out the following paths on your system?

ls /sys/class/kfd/kfd/topology/nodes/*
cat /sys/class/kfd/kfd/topology/nodes/*/properties
ls /sys/class/drm/card*/device

@justinkb
Copy link
Author

justinkb commented Jun 25, 2024 via email

@justinkb
Copy link
Author

justinkb commented Jun 25, 2024

I just noticed those docs specify installing with "amdgpu-install -y --usecase=wsl,rocm --no-dkms" specifically, meaning the kernel driver source for dkms won't be installed. this isn't to say getting it installed and loaded isn't possible on wsl, but I doubt it will be, since I don't think any of the drm subsystem is actually available in wsl linux kernel. In any case, compiling the dkms driver isn't trivial, since I'll need to install the WSL2 kernel headers in a way dkms expects them. Again, even if and when I get that set up, I cannot imagine that'll actually work to load the actual amdgpu driver. I checked the sources, it is just the same amdgpu driver as used in actual linux, not some forwarding stub, so I don't see how it could work when there is no way the underlying vm for wsl2 can somehow paravirtualize the actual GPU while windows is also using it.

@justinkb
Copy link
Author

The installation docs seem to imply the amdgpu driver is installed. I'll have to set up a test system so I can poke around and see what discovery options we've got. @justinkb if you have already done so, can you check out the following paths on your system?

ls /sys/class/kfd/kfd/topology/nodes/*
cat /sys/class/kfd/kfd/topology/nodes/*/properties
ls /sys/class/drm/card*/device

the devices in /sys/class/drm/card0 and /sys/class/drm/render128 just point to vgem the virtual GEM provider, /sys/class/kfd is completely absent. and as expected, I wasn't able to load amdgpu driver on wsl

@justinkb
Copy link
Author

I managed to hack this into working order, see https://github.com/justinkb/ollama/tree/wsl-rocm-hack - can confirm it works perfectly like this. theoretically, I could write a windows program that updates the referenced text file that contains the used memory periodically, which would enable ollama to monitor the memory usage.

@xaxaxa7b9
Copy link

@justinkb how do i install your solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
amd Issues relating to AMD GPUs and ROCm feature request New feature or request wsl Issues using WSL
Projects
None yet
Development

No branches or pull requests

4 participants