-
-
Notifications
You must be signed in to change notification settings - Fork 710
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
Lenovo Legion 15ach6h : amdgpuBusId seems incorrect #1388
Comments
I don't have this model to test. Has anyone else seen identical models with different IDs? |
Sometimes Lenovo has different versions of the same model depending on the location you buy it. |
Is there a way to accustom for both pcie ids? |
Would there be a way to detect the PCI ports dynamically? |
Hello, sorry for the late reply. I've been pretty busy with work and some personal stuff. On my machine
I'm pretty busy with work for the next few weeks, but I cannot see why we couldn't do this dynamically, not just for this, but the entire repo via a "compile time" script. I think if we were to do this, a simple pattern match should work. The prefix seems to be always This can be merged into the higher level nvidia and amd files, with lower level dedicated nix files such as this for specific machines as overwrites. This should be fairly trivial with default values that nix supports. Personally, I've just switched to just using the Nvidia GPU only as I've had loads of random crashes and during gaming and general usage trying to use both GPUs. The only real advantage that I saw from using both is potentially lower power usage, as well as VRAM usage. But overall, I've found using just the Nvidia GPU is the best for stability and performance. If that is something that you could do, it's the best way to use this laptop for me. I've found that I'm rarely requiring the lower power usage of shutting down the Nvidia GPU. It's a gaming laptop so I'm pretty much always plugged in. |
If we can do this more dynamically, this should be preferred over our current approach. |
I've written a script to get the string for the GPUs as per the specs: https://search.nixos.org/options?channel=unstable&query=busid and NixOS/nixpkgs#365241 #!/usr/bin/env bash
lspci_output="$(lspci)"
amdID=$(echo "$lspci_output" | grep VGA | grep -i AMD | grep -o '^[0-9]*:[0-9]*.[0-9]*')
nvidiaID=$(echo "$lspci_output" | grep VGA | grep -i nvidia | grep -o '^[0-9]*:[0-9]*.[0-9]*')
amdChunks=("$(echo $amdID | grep -o '[0-9 a-f A-F]*')")
nvidiaChunks=("$(echo $nvidiaID | grep -o '[0-9 a-f A-F]*')")
AMDSTR='PCI'
for c in $amdChunks; do
AMDSTR+=":$((16#$c))"
done
echo $AMDSTR
NVIDIASTR='PCI'
for c in $nvidiaChunks; do
#echo "hex:$c dec: $((16#$c))"
NVIDIASTR+=":$((16#$c))"
done
echo $NVIDIASTR Please test this on your machines and let me know if there are any bugs or changes that need to be done. I've tried to simply use the outputs of this as a string, but I've not had any luck. The closest I've gotten was with this: https://discourse.nixos.org/t/how-to-create-a-timestamp-in-a-nix-expression/30329/3 To include this as a string will require break chars and a bunch of conversions in order to import it directly as a string. I'm not sure what the cleanest way to do this is, but I hope this has helped in the meantime. Here is also a generic version that takes the first var as the name of the GPU vendor, and then searches it.
#!/usr/bin/env bash
help() {
echo "GPU vendor required!"
echo "Usage: $0 GPU_VENDOR_NAME_HERE"
echo "Example: $0 nvidia"
}
if [ $# != 1 ]; then
help
exit
fi
lspci_output="$(lspci)"
gpuID=$(echo "$lspci_output" | grep VGA | grep -i $1 | grep -o '^[0-9]*:[0-9]*.[0-9]*')
if [ -z "$gpuID" ]; then
echo "NO GPU DETECTED"
exit
fi
gpuChunks=("$(echo $gpuID | grep -o '[0-9 a-f A-F]*')")
PCISTR='PCI'
for c in $gpuChunks; do
PCISTR+=":$((16#$c))"
done
echo $PCISTR |
Also, as per the README.md (https://github.com/NixOS/nixos-hardware/tree/master/lenovo/legion/15ach6h#using-multiple-drives-with-this-configuration) this is due to having more than 1 drive. Should we change the default ID to assume users only have 1 drive instead of 2? I don't really know the statistics, but I personally dual boot with Windows, and even if I didn't, I'd probably have 2 drives anyway. |
There are some docs here that could facilitate this (https://nix.dev/manual/nix/2.26/language/import-from-derivation). @Mic92 You seem to be one of the largest maintainers here, what are your thoughts on doing something like this? In my honest opinion this could cause more problems then it solves. This is really a vendor (nvidia) issue. I don't think it's user friendly to inspect the IDs manually and set it. In an ideal world the nvidia driver would be able to see that it has the right GPUs and set all of this info at the driver level instead. However, I don't think the current approach is very user friendly. The right approach to be to do this at runtime instead of trying to set all of this statically, that includes detecting the PCI ports using a script as this will at the very minium require the user to rebuild their system to get the right config. imo, this is either a can't fix/won't fix as it goes against the very philosophy of nix. In the meantime, this is still an issue, any hack we put in is just that, a hack. I think we need to open this discussion up to the greater nix community before any meaningful work can be done. In lieu of this, should we make a new ticket and move the discussion there? I don't want to clutter up this ticket any more. |
Mhm. If you try to use import-from-derivation here, I don't think this is feasible for two reasons:
The configuration that uses this information seems to be passed directly to the xorg server via commandline flag. I haven't seen a way to add dynamic configuration to that file. |
On my machine (a factory-modified-issued Lenovo Legion 15ach6h), the amdgpuBusId seems to be
PCI:5:0:0
instead ofPCI:6:0:0
Subject
https://github.com/NixOS/nixos-hardware/tree/master/lenovo/legion/15ach6h#setup-at-the-time-of-testing
nixos-hardware/lenovo/legion/15ach6h/hybrid/default.nix
Line 31 in 18e9f97
Log
fastfetch
lspci
nix-info -m
The text was updated successfully, but these errors were encountered: