How to use external gpu on VisionFive v2

Hello,
I would like to use an old amd gpu with the open source amd drivers if they run on VisionFive V2. What do I need and how can I attach the gpu to the VisionFive v2?

Thanks!

That is one Interesting question.

I’m going to guess that a PCIe extender similar to those boards with cables that that were used by bitcoin miners half a dozen years back mostly to fit like 8 double width GPU boards into a motherboard that they physically could not fit into due to the single width spacing. But instead of a PCIe to PCIe you would need some kind of M.2 M-Key to PCIe cable.

Yes, I was looking at this Amazon link. Do you think it’s compatible?

2 Likes

First you need to rebuild your kernel to have appropriate eGPU modules. One guy I know tested nouveau with an old 600 series Nvidia GPU, but you may also try radeon/amdgpu.

Install RISC-V toolchain on your build machine first (Or build directly on VF2, you should omit the CROSS_COMPILE variables mentioned here then)
Get kernel sources from here: GitHub - starfive-tech/linux at JH7110_VisionFive2_devel
Use exactly the branch I put in the link, it’s the 5.15 kernel. Other versions are not yet ready.
Get config-5.15.0-starfive from your /boot partition, rename into .config in the kernel source tree.
Run make menuconfig CROSS_COMPILE=riscv64-linux-gnu-
Go into Device Drivers → Graphics → Set [M] in boxes mentioning GPUs you want to use (Nvidia, Radeon).
Run make bindeb-pkg CROSS_COMPILE=riscv64-linux-gnu-
This should have dropped linux-image-??.deb files in upper directory after compiling. DO NOT INSTALL THEM! The current way the VF2 image is built it will brick your install. You should instead unpack the deb package with an archiver, then replace vmlinuz-5.15.0-starfive file on your /boot partition. After that, copy lib/modules from the package to be /lib/modules in root.

The tricky part is mostly over. You now need to install Mesa packages for userspace GPU drivers, connect your GPU using an M.2 → PCIe riser and it should work.

There are some issues concerning the preinstalled distro, namely the PVR GPU driver conflicts in one way or another, so the guy who tested my approach simply replaced the Debian userland with Arch. Any further research is welcome.

4 Likes

I see, thanks it’s helpful. I will try your instructions whenever I order the m.2 to pcie kit.

1 Like

One of the images (5th one down) says “M.2 Key-M”, so I would say yes it “should” be compatible!

1 Like

Would it even be worth it to have a 1x PCIe Gen 2 connection?

2 Likes

A Star64 might be a simpler solution. They should start to be available any day now.

2 Likes

Unfortunately, the Star64 keeps getting delayed by what seems to be incompetent hardware designers. That could mean a multi-month wait (if they don’t complete validation by Chinese new year) so depending on your situation it might not be worth it if the HiFive Pro is coming just a couple months after that.

1 Like

Pretty much OK, this would be much faster than the internal GPU anyways. The other issue is on the software side (PVR GPU drivers are in a very ugly state) so this is a cool option if people want a GPU with more stable & open driver.

2 Likes

This is ambitious and I love it :slight_smile: Please keep us posted on the journey

Great, I even wanted to play with it myself. Please keep us updated

5 Likes

Any way to disable the PVR gpu in debian? I recompiled the kernel with amd and nvidia drivers and swapped them out in on vf2 debian install. I can see the gt730 i have connected to an m2 to pcie adapter when I run lspci but can’t seem to actually initialize it.

Would recompiling the kernel with the powervr drivers be sufficient?

EDIT:
I’m dumb and named the modules folder wrong, renaming it gave me console output, but no xorg. I have the nouveau xorg drivers installed but xorg thinks they aren’t. Am I missing something?

The VF2 debian image is somehow broken in this regard. They replaced stock DRI path /usr/lib/riscv64-linux-gnu/dri with /usr/local/lib/dri or sth like that.

I wasn’t able to get over this and simply told the guy with the board to replace the Debian userland with an Arch rootfs. Ubuntu worked as well.
Hope you can debug this somehow, my own board is yet to arrive(

3 Likes

In a shell did you try:
$ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/dri
And then in the same shell whatever command launches the application. And if that works add the new library path to a new configuration file, or an existing one, in /etc/ld.so.conf.d/

Should work as a workaround.

1 Like

Hi, both make commands were missing ARCH=riscv for anyone looking. Also I’m getting the follow error trying to compile the kernel:

In file included from drivers/gpu/drm/verisilicon/vs_dc.c:24:
drivers/gpu/drm/verisilicon/vs_dc.c: In function ‘update_fb’:
./include/soc/starfive/vic7100.h:8:9: error: implicit declaration of function ‘sifive_l2_flush64_range’ [-Werror=implicit-function-declaration]
8 | sifive_l2_flush64_range(start, len)

Nvm, I got it to work with arch rootfs. The build was failling because I did make clean. I had to reclone the linux kernel git repo. Thanks everyone for your help. Its working good the external amd gpu on the VF2. :sunglasses:

4 Likes

did you use that mzhou riser card you linked above for your working experiment in the end?

2 Likes

Yes, the exact same one on Amazon I linked. But it looks a little fragile. It works good though. The amd card im using with it is the cheap HD6450.

4 Likes

Did you just enable the radeon module and rebuild the kernel, or did you have to patch anything to get it working? And were you able to get any output beyond just console?