Taken from StackExchange
Thanks to LangLangC
For temperature and other improvements see https://gist.github.com/cdleon/d16e7743e6f056fedbebc329333d79df
Shutdown, unplug everything except power and hold
leftShift + Ctrl + Option + Power
I holded for 5 seconds, but holding just for an instant should work
Command + Option + p + r
Until you hear the startup chime two times.
if you are on high sierra 10.13.6+ you might need to use
Command + r
instead
Command + r + s
csrutil disable
nvram fa4ce28d-b62f-4c99-9cc3-6815686e30f9:gpu-power-prefs=%01%00%00%00
nvram boot-args="-v"
reboot
Command + s
It might look as if it hanged, but press enter and you should see the shell (root#)
/sbin/mount -uw /
mkdir -p /System/Library/Extensions-off
mv /System/Library/Extensions/AMDRadeonX3000.kext /System/Library/Extensions-off/
touch /System/Library/Extensions/
reboot
It will show a bunch of text in the screen (don't be alarmed, let it finish) and then it will restart again In second restart it will show text in the screen again and then it will show normal login screen Your computer now should work properly (dGPU off and iGPU on, shown as i in gfxCardStatus
If an update that contains changes to the AMD drivers is about to take place it is advisable to move back the AMDRadeonX3000.kext to its default location before the update process. Otherwise the updater writes at least another kext of a different version to its default location or at worst you end up with an undefined state of partially non-matching drivers.
After any system update the folder /System/Library/Extensions has to be checked for the offending kext. Its presence there will lead to e.g. a boot hang on Yosemite and Sierra, an overheating boot-loop in High Sierra.
Yes, of course and glad to help @smabe2021
If you load the whole reply thread, in 2019 @artkirienko (1st comment in the thread) transcribed step by step how he did it. I followed step by step exactly the same.
(If you compare, they are practically the same commands that the author of the post @cdleon transcribed in another order).
In case it helps you and if you read carefully (I recommend it if you are not familiar with UNIX commands and the terminal app as I am) they have done it from MacOS High Sierra (10.13.6 latest version) and I think the commands differ in some things, so for example, I had to use cmd+s+r (point 1 of @artkirienko) to boot in Single User Recovery mode as @cdleon said.
Another important thing, My MBP 17 was plugged to internet router with RJ45 cable, because when booting in recovery mode you need stable internet connection.
Finally, when you reboot in @artkirienko's process (point 4) and boot in recovery mode (point 5) keep pressing until you see the white text on black screen (verbose mode) and make sure you don't start to see a lot of "r" letters together... release the cmd+r keys !!!! DO NOT WAIT TO SEE the recovery mode screen with OSX reinstallation, utility disk... to release them.
Once you are there, you HAVE TO OPEN THE TERMINAL APPLICATION (utilities menu) to enter the following commands (points 6, 7, 8 and 9)
I hope I helped you!