Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bash implementation of opencl-amd AUR package, Install opencl amdgpu amdgpu-pro opencl only. Supports ubuntu and others with standard prefix
#!/bin/bash
# DO NOT run the line 167 standalone. It will remove the necessary files besides the junk!
if echo $@|grep -q "\-\-help\|\-help\|\-h\|help\|\-\-h\|\-\-no\-deb\|\-\-no\-install\|\-\-no\-cleaning\|\-\-assume\-debian"
then :
else echo wrong entry\(ies\) !
help=yes
fi
if echo $@|grep -q "\-\-help\|\-help\|\-h\|help\|\-\-h" || [ "$help" = yes ]
then echo "--no-deb : don't build the debian package on debian based systems
--no-install : don't install anything
--no-cleaning : skip cleaning on direct installs
--assume-debian : assumes system to be debian based
For example to build .deb package on non-debian systems use --no-install and --assume-debian together (still requires \"dpkg\" command)"
exit
fi
prefix='amdgpu-pro-'
postfix='-ubuntu-20.04'
major='21.30'
minor='1290604'
amdver='2.4.106'
shared="opt/amdgpu-pro/lib/x86_64-linux-gnu"
shared2="opt/amdgpu/lib/x86_64-linux-gnu"
tarname="${prefix}${major}-${minor}${postfix}"
cstdir=opencl-amd_aur_ubuntu_dir
srcdir="$(pwd)/${cstdir}"
pkgdir="${srcdir}/pkgdir"
eval $(grep ID /etc/os-release)
if echo $@|grep -q \\-\\-assume\\-debian
then ID_LIKE=debian
fi
if ls -d "${srcdir}"&> /dev/null
then echo Warning: existing \""${srcdir}"\" found, deleting it in five seconds!
sleep 5
if rm -rf "${srcdir}"
then :
else echo Warning: couldn\'t removed the folder, will try with sudo again!
sudo rm -rf "${srcdir}"
fi
fi
mkdir -p "${pkgdir}"
cd "${srcdir}"
echo "Downloading archive and extracting"
if wget --referer https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-21-30 -N -O - "https://drivers.amd.com/drivers/linux/$tarname.tar.xz"|tar -xJ
then echo "Extraction complete, creating the files"
else echo "Extraction or downloading failed, please ping me at the gist page. You can also try running the script with a random argument"
exit
fi
mkdir -p "${srcdir}/opencl"
cd "${srcdir}/opencl"
# roc*
ar x "${srcdir}/$tarname/opencl-rocr-amdgpu-pro_${major}-${minor}_amd64.deb"
tar xJf data.tar.xz
ar x "${srcdir}/$tarname/rocm-device-libs-amdgpu-pro_1.0.0-${minor}_amd64.deb"
tar xJf data.tar.xz
ar x "${srcdir}/$tarname/hsa-runtime-rocr-amdgpu_1.3.0-${minor}_amd64.deb"
tar xJf data.tar.xz
ar x "${srcdir}/$tarname/hsakmt-roct-amdgpu_1.0.9-${minor}_amd64.deb"
tar xJf data.tar.xz
ar x "${srcdir}/$tarname/hip-rocr-amdgpu-pro_${major}-${minor}_amd64.deb"
tar xJf data.tar.xz
# comgr
ar x "${srcdir}/$tarname/comgr-amdgpu-pro_2.1.0-${minor}_amd64.deb"
tar xJf data.tar.xz
# orca
ar x "${srcdir}/$tarname/opencl-orca-amdgpu-pro-icd_${major}-${minor}_amd64.deb"
tar xJf data.tar.xz
cd ${shared}
sed -i "s|libdrm_amdgpu|libdrm_amdgpo|g" libamdocl-orca64.so
mkdir -p "${srcdir}/libdrm"
cd "${srcdir}/libdrm"
ar x "${srcdir}/$tarname/libdrm-amdgpu-amdgpu1_${amdver}-${minor}_amd64.deb"
tar xJf data.tar.xz
cd ${shared2}
rm "libdrm_amdgpu.so.1"
mv "libdrm_amdgpu.so.1.0.0" "libdrm_amdgpo.so.1.0.0"
ln -s "libdrm_amdgpo.so.1.0.0" "libdrm_amdgpo.so.1"
mv "${srcdir}/opencl/etc" "${pkgdir}/"
mkdir -p ${pkgdir}/usr/lib
# roc*
mv "${srcdir}/opencl/${shared}/libamdocl64.so" "${pkgdir}/usr/lib/"
mv "${srcdir}/opencl/${shared}/libamd_comgr.so.2.1.0" "${pkgdir}/usr/lib"
mv "${srcdir}/opencl/${shared}/libamdhip64.so.4.2.21303-" "${pkgdir}/usr/lib"
mv "${srcdir}/opencl/${shared}/libamdhip64.so" "${pkgdir}/usr/lib"
mv "${srcdir}/opencl/${shared}/libamdhip64.so.4" "${pkgdir}/usr/lib"
mv "${srcdir}/opencl/${shared}/libhsa-runtime64.so.1.3.0" "${pkgdir}/usr/lib"
mv "${srcdir}/opencl/${shared}/libhsa-runtime64.so.1" "${pkgdir}/usr/lib"
mv "${srcdir}/opencl/${shared2}/libhsakmt.so.1.0.6" "${pkgdir}/usr/lib"
mv "${srcdir}/opencl/${shared2}/libhsakmt.so.1" "${pkgdir}/usr/lib"
# comgr
cd ${srcdir}/opencl/${shared}
ln -s "libamd_comgr.so.2.0.0" "libamd_comgr.so"
mv "${srcdir}/opencl/${shared}/libamd_comgr.so" "${pkgdir}/usr/lib/"
mv "${srcdir}/opencl/${shared}/libamd_comgr.so.2" "${pkgdir}/usr/lib/libamd_comgr.so"
# orca
mv "${srcdir}/opencl/${shared}/libamdocl-orca64.so" "${pkgdir}/usr/lib/"
mv "${srcdir}/libdrm/${shared2}/libdrm_amdgpo.so.1.0.0" "${pkgdir}/usr/lib/"
mv "${srcdir}/libdrm/${shared2}/libdrm_amdgpo.so.1" "${pkgdir}/usr/lib/"
mkdir -p "${pkgdir}/opt/amdgpu/share/libdrm"
cd "${pkgdir}/opt/amdgpu/share/libdrm"
ln -s /usr/share/libdrm/amdgpu.ids amdgpu.ids
mv "${srcdir}/opencl/opt/amdgpu-pro" "${pkgdir}/opt"
rm -r "${srcdir}/opencl"
rm -r "${srcdir}/libdrm"
cd "${pkgdir}"
if type md5sum&> /dev/null
then if echo -e 3dba553d1fcfeddaa252de13860d7531 ./opt/amdgpu-pro/share/amd_comgr/README.md\\n4000cbaa3eecf22be59c8cea7229ca6a ./opt/amdgpu-pro/share/amd_comgr/NOTICES.txt\\n7754f2a8be21dce24fec9d1e7972a68b ./opt/amdgpu-pro/share/amd_comgr/LICENSE.txt\\ne91050c15b7262e21d55077274d1a0ba ./opt/amdgpu-pro/bin/roc-obj-ls\\n467574e9dbf38f603352d6e70d7ae819 ./opt/amdgpu-pro/bin/roc-obj-extract\\n9eea3d2de3a0335f014f9a3f83e4212c ./opt/amdgpu-pro/bin/hipvars.pm\\n77a2b371ee24f2309bfa8e5dfa06a0ab ./opt/amdgpu-pro/bin/hipify-perl\\n35dec57990df0a33afc41c9f67cbcdb0 ./opt/amdgpu-pro/bin/hipify-cmakefile\\n7def981db985f53f8fc8263a3b3f32b1 ./opt/amdgpu-pro/bin/hipexamine.sh\\ne2710bcee657cf61e5d791b66c0aff6f ./opt/amdgpu-pro/bin/hipexamine-perl.sh\\n0ee195639b292e6c043bfca0ad716585 ./opt/amdgpu-pro/bin/hipdemangleatp\\n144dbd8b9a80c360076bf87ed7c8455b ./opt/amdgpu-pro/bin/hipconvertinplace.sh\\n9b023318378593cd5f7ea5d59f625883 ./opt/amdgpu-pro/bin/hipconvertinplace-perl.sh\\nfcabd42ea6fcede0ff1cd3ae545f7f00 ./opt/amdgpu-pro/bin/hipconfig\\n15d7380c3b56e5a576f425d133b5e416 ./opt/amdgpu-pro/bin/hipcc_cmake_linker_helper\\n0e13a3d69fd5c103427f125491948e43 ./opt/amdgpu-pro/bin/hipcc\\nd9e5aadea0e923f2d292f616d6529059 ./opt/amdgpu-pro/bin/hip_embed_pch.sh\\n99274d27be5d5925c5569c4691395f5e ./opt/amdgpu-pro/bin/finduncodep.sh\\n474244f0c760037fef8f9141c5f1739b ./opt/amdgpu-pro/bin/findcode.sh\\nf0dc40e0af3ec42dd5fb393200042a90 ./opt/amdgpu-pro/bin/.hipVersion\\n1c98781ee06133b16e40d505ac9b49b2 ./opt/amdgpu-pro/amdgcn/bitcode/opencl.bc\\n0d9e53c87d76e76d3a6cff2ce3a4a8bb ./opt/amdgpu-pro/amdgcn/bitcode/ocml.bc\\ndd2f6ff3cb26c1ac605d685667057cfd ./opt/amdgpu-pro/amdgcn/bitcode/oclc_wavefrontsize64_on.bc\\n0277e77cafad2699fc5a5e0bbf709be2 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_wavefrontsize64_off.bc\\n9270dab6d99bb3f92f3cabfa7733b80c ./opt/amdgpu-pro/amdgcn/bitcode/oclc_unsafe_math_on.bc\\n946949d7f013c2c1fe2934adf14cc3d5 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_unsafe_math_off.bc\\n24578350ab27c1ac528ad6636b22a437 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_90c.bc\\n44a05937fcc3792b7f6831e56ccf00ba ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_90a.bc\\nab77d8f122f8fd3a745c8b0b92388a23 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_909.bc\\ne93b243cbe488ab6504ba1a5edec2267 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_908.bc\\n48400385ca8d369d8ea9c745b5b7f694 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_906.bc\\n95613b7e4d759c9f3b725e3a5d5d9465 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_904.bc\\n53e38d463e83c4922b1a214c1274273f ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_902.bc\\n7f716b3a1784f98cf29c1cef444247f7 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_900.bc\\nad7bea62601463242dd30e30f2f0e5d5 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_810.bc\\n7bb5bb3bc16dcb0824f0feefc0f6e4f2 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_805.bc\\n72f013270fb0de6abf944fe3a35f0b67 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_803.bc\\n405c4b17e94c0b97c43a24a6f168ea6c ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_802.bc\\nccacbfe4355e685fb4386055a657269f ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_801.bc\\n31af1ab2966684167f9dd131da195017 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_705.bc\\n920a745d5a54d73df7b8190de7572a5d ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_704.bc\\n2067ab053f1b72479c436904a6fceab5 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_703.bc\\n0fa783e0e74cf3c3ef7c1c7939e2f4f9 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_702.bc\\nd6b8bab0a83e2a37f469f7e9720a6bc3 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_701.bc\\ncfc51b7c9b841b39ce7fef9698715d1b ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_700.bc\\nbc916ec6362ffe7fbb4a4453f9707bb9 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_602.bc\\nb144a23933525a3a9cb5809e0472ffd6 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_601.bc\\ne83d726ae08df78f09c2727e9d3ecf69 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_600.bc\\n5043c1c11ad9727cec4b517f04720224 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1034.bc\\nc9a849b4883bfd98970d2e43e8521191 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1033.bc\\n77a08437e4dfe3b1b58ae59a8b68868d ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1032.bc\\n7cbaeb8e514acffd8c987b8998bd68ca ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1031.bc\\n3db0e8d47a7d694a8c9437a681515a11 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1030.bc\\na3aed269cfbc415d22548d803c966663 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1012.bc\\nb88b229cdad0f7e42a2a3505dd5a2c11 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1011.bc\\n29592e6944367f4b5d7c5a774497cb37 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1010.bc\\n39b6324e34f42b08f1b7cac0fa3a562a ./opt/amdgpu-pro/amdgcn/bitcode/oclc_finite_only_on.bc\\ne8849c60abdfafb40b4e69c0a45881ef ./opt/amdgpu-pro/amdgcn/bitcode/oclc_finite_only_off.bc\\n734d59729fc961ef86ec28b8a07a3753 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_daz_opt_on.bc\\n201f43462f251847a4f24e45f13d873c ./opt/amdgpu-pro/amdgcn/bitcode/oclc_daz_opt_off.bc\\n4d7b29e1b8c0dce0c985f309b299f41d ./opt/amdgpu-pro/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc\\ne659a0ad6cd96708d307ebec73dbc1c4 ./opt/amdgpu-pro/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc\\n3a9ebf5f408a0260ee4c904afaa0a8cb ./opt/amdgpu-pro/amdgcn/bitcode/ockl.bc\\nc28dc2a95d9d805a39c29bbe157261af ./opt/amdgpu-pro/amdgcn/bitcode/hip.bc\\ndfe3cce71d8dd70d2c63151247f367ca ./opt/amdgpu-pro/amdgcn/bitcode/hc.bc\\n218cce187f7dd9f28fbeb110e11c57fe ./opt/amdgpu-pro/amdgcn/bitcode/asanrtl.bc\\n24098ed774d6803942b48650c95ac626 ./opt/amdgpu-pro/lib/.hipInfo\\nd0d6ea1297113dfb839ae456ecdadec7 ./opt/amdgpu-pro/lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake\\n46bcce3d87ed51f0b3fbb8a09e4b9d4d ./opt/amdgpu-pro/lib/x86_64-linux-gnu/libhiprtc-builtins.so.4.2\\n743746e682860ad9cbfe232b79811fb0 ./opt/amdgpu-pro/lib/x86_64-linux-gnu/libcltrace.so\\nbb234ca12828d9f96a03c9460d116596 ./usr/lib/libdrm_amdgpo.so.1.0.0\\n265a629dceb9d5e4d1057b35091f18de ./usr/lib/libamdocl-orca64.so\\n8f6f6e4277c4275acadbdf15ea190ec9 ./usr/lib/libhsakmt.so.1.0.6\\n63c804c9bbce52f7ece516dc7cf589ef ./usr/lib/libhsa-runtime64.so.1.3.0\\n3249872a8ad0cf51fd75bcc7e4bbd74f ./usr/lib/libamdhip64.so.4.2.21303-\\nad96187089aba4988723e3f1e67673df ./usr/lib/libamd_comgr.so.2.1.0\\nc69178d7ac3e989939ccffdbb8a3f87e ./usr/lib/libamdocl64.so\\nd4c720fa080a71b8c960582d9a4857d7 ./etc/OpenCL/vendors/amdocl-orca64.icd\\n45a4b6c5182d693554c287765b369dfe ./etc/OpenCL/vendors/amdocl64.icd|md5sum -c
then echo All files are ok!
else echo File corruption found! Terminating!
exit
fi
else echo Warning: You don\'t have \"md5sum\" installed, skipping sum checking!
fi
mkdir DEBIAN
echo -e \#\!/bin/bash\\nif [ \$\(whoami\) = root ]\\nthen :\\nelse user=\$USER\\nfi\\n\\nn=0\\nfor i in video render\\ndo if getent group \$i \&\> /dev/null\\nthen if getent group \$i\|grep -q \$user\$SUDO_USER\\nthen :\\nelse echo Warning: \$user\$SUDO_USER isn\\\\\'t in the \\\\\"\$i\\\\\" group, will add the user\\ng[\$n]=\$i\\nfi\\nelse echo Warning: group \\\\\"\$i\\\\\" does not exist\\nc[\$n]=\$i\\nfi\\nn=\$\(\(\$n+1\)\)\\ndone\\n\\nif [ \"\${#c[@]}\" -eq 0 ]\\nthen :\\nelse if echo \"\${c[*]}\"\|grep -q video\\nthen echo ERROR: important group \\\\\"video\\\\\" is missing, without that group opencl won\\\\\'t work\!\\nelse echo Warning: non-important group is missing, you can ignore the warning messages\\nfi\\nfi\\n\\nif [ \"\${#g[@]}\" -eq 0 ]\\nthen :\\nelse echo Warning: adding \$user\$SUDO_USER to \\\\\"\$\(echo \${g[*]}\|tr \' \' ,\)\\\\\" group\\\\\(s\\\\\) in five seconds\!\\nsleep 5\\nsudo usermod -a -G \$\(echo \${g[*]}\|tr \' \' ,\) \$user\$SUDO_USER \&\& echo Warning: you\\\\\'ve been added to group\\\\\(s\\\\\), you should login-logback for installation to complete\! \|\| echo ERROR: you\\\\\'ve failed to enter group\\\\\(s\\\\\)\!\\nfi\\n\\necho Warning: remeber to remove \\\\\'mesa-opencl-icd\\\\\' \\\\\!, otherwise you will have each device in both opencl 1.1 and 1.2 modes as seperate devices . clpeak for example will report each gpu twice \\\\\! This is problematic for BOINC > DEBIAN/postinst
if [ "$ID_LIKE" = debian ]
then if echo $@|grep -q \\-\\-no\\-deb
then :
else echo -e Package: amdgpu-pro-opencl\\nVersion: $major.$minor\\nSection: Libraries \(universe\)\\nPriority: extra\\nMaintainer: proje.pdf@outlook.com\\nDescription: implementation of opencl-amd AUR package: https://aur.archlinux.org/packages/opencl-amd\\n script hosted on: https://gist.github.com/tuxutku/79daa2edca131c1525a136b650cdbe0a\\nWebsite: https://gist.github.com/tuxutku/79daa2edca131c1525a136b650cdbe0a\\nInstalled-Size: $(du -s .|cut -f -1)\\nArchitecture: amd64 > DEBIAN/control
find . -type f ! -regex '.*.hg.*' ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '%P ' | xargs md5sum > DEBIAN/md5sums
chmod -R 755 .
dpkg -b . ../$tarname-opencl.deb
if echo $@|grep -q \\-\\-no\\-install
then :
else echo 'installing package'
sudo apt install ../$tarname-opencl.deb
exit
fi
fi
fi
if echo $@|grep -q \\-\\-no\\-install
then exit
fi
echo "will be doing direct installation. Enter sudo password when needed"
sleep 5
if echo $@|grep -q \\-\\-no\\-cleaning
then echo skipping cleaning
else echo
sudo rm -vf /opt/amdgpu-pro/bin/ca /opt/amdgpu-pro/bin/extractkernel /opt/amdgpu-pro/bin/lpl /opt/amdgpu/share/libdrm/amdgpu.ids /usr/lib/libamd_comgr.so /usr/lib/libamd_comgr.so.1.7.0 /usr/lib/libamd_comgr.so.1.9.0 /usr/lib/libamd_comgr.so.2.0.0 /usr/lib/libamdhip64.so /usr/lib/libamdhip64.so.1 /usr/lib/libamdhip64.so.1.5.19245 /usr/lib/libamdhip64.so.4 /usr/lib/libamdhip64.so.4.0.21115- /usr/lib/libamdhip64.so.4.0.21154- /usr/lib/libamdocl12cl64.so /usr/lib/libdrm_amdgpo.so.1 /usr/lib/libhsakmt.so.1 /usr/lib/libhsa-runtime64.so.1 /usr/lib/libhsa-runtime64.so.1.2.0
# DO NOT run the line above standalone. It will remove the necessary files besides the junk!
fi
sudo cp -rv * /
bash DEBIAN/postinst
@cedmundo
Copy link

cedmundo commented Feb 27, 2021

Finally working drivers on Linux Mint 20.1 Cinnamon 5.4.0-66-generic with RX 5700 XT! Thank you very much!

@paranoidfactoid
Copy link

paranoidfactoid commented Mar 6, 2021

Is there any way to get rocm-devices installed too? Davinci Resolve 17 won't work without it. Or use the legacy libs. And if not, how do I properly uninstall so as to install amdgpu-pro opencl and their horrible opengl driver?

@paranoidfactoid
Copy link

paranoidfactoid commented Mar 6, 2021

that's rocm-device-libs

@tuxutku
Copy link
Author

tuxutku commented Mar 6, 2021

@paranoidfactoid I had cleaned mine with synaptic. You have go to sources and select the local repo created by amd installer and try to remove/change versions of every package. Then remove the repo.

Also for rocm-device-libs, I haven't seen that aur package before but jt links to here: https://github.com/RadeonOpenCompute/ROCm-Device-Libs
Edit:
I don't know whether you should remove the repo first or last. also it came to my mind that you can use apt purge to that repo and thus remove the drivers and reinstall the default ones

@paranoidfactoid
Copy link

paranoidfactoid commented Mar 6, 2021

OK. Just to be clear. I'm running Ubuntu 20.04.2. I have a VEGA FE 16GB card. On an old Threadripper 1950x. I have the oibaf bleeding edge gl/vulkan drivers installed. And I used your script to install the opencl components of amdgpu-pro. It all worked. That is, the official build of blender 2.92 sees my AMD Vega card (and the cpu cores). I did a test render of the classroom scene - no problem. BUT, Davinci Resolve doesn't work. And if you dig into the Linux Install forum thread there, folks say the approach you take is broken because of changes AMD is doing to the driver stack - rectifying it with ROCm. blah blah blah The only way to make it work is with the amdgpu-pro 20.45 gl side. And a horrible lib hack you can find elsewhere on github. So, I have to untangle your script (and the opencl components I installed via apt get) to get back to where I was so I can reinstall official amdgpu-pro components.

@paranoidfactoid
Copy link

paranoidfactoid commented Mar 6, 2021

janky amdocl fix lib. You'll need this to get Fairlight working in Resolve with amdgpu-pro 20.45. (just in case anyone wanders over here trying to make Resolve work on Linux with an AMD card)

https://github.com/h33p/resolve-amdocl-fix

EDIT: And... this doesn't work on 17 at all. So... revert to 16 it is I guess.

@iandol
Copy link

iandol commented Apr 9, 2021

aur is updated to 20.50:

prefix='amdgpu-pro-'
postfix='-ubuntu-20.04'
major='20.50'
minor='1234664'
amdver='2.4.100'
shared="opt/amdgpu-pro/lib/x86_64-linux-gnu"
shared2="opt/amdgpu/lib/x86_64-linux-gnu"

The md5 checksums will not now match...

Also, what is the best method to properly remove the changes this script makes? Thank you!

@iandol
Copy link

iandol commented Apr 9, 2021

This is the file list from 20.45, so deleting these reverts us to a clean state (were any of these files present before)?

'etc/OpenCL/vendors/amdocl64.icd' -> '/etc/OpenCL/vendors/amdocl64.icd'
'etc/OpenCL/vendors/amdocl-orca64.icd' -> '/etc/OpenCL/vendors/amdocl-orca64.icd'
'opt/amdgpu/share/libdrm/amdgpu.ids' -> '/opt/amdgpu/share/libdrm/amdgpu.ids'
'usr/lib/libamdocl64.so' -> '/usr/lib/libamdocl64.so'
'usr/lib/libhsa-runtime64.so.1.2.0' -> '/usr/lib/libhsa-runtime64.so.1.2.0'
removed '/usr/lib/libhsa-runtime64.so.1'
'usr/lib/libhsa-runtime64.so.1' -> '/usr/lib/libhsa-runtime64.so.1'
'usr/lib/libhsakmt.so.1.0.6' -> '/usr/lib/libhsakmt.so.1.0.6'
removed '/usr/lib/libhsakmt.so.1'
'usr/lib/libhsakmt.so.1' -> '/usr/lib/libhsakmt.so.1'
'usr/lib/libamdhip64.so.1.5.19245' -> '/usr/lib/libamdhip64.so.1.5.19245'
removed '/usr/lib/libamdhip64.so'
'usr/lib/libamdhip64.so' -> '/usr/lib/libamdhip64.so'
removed '/usr/lib/libamdhip64.so.1'
'usr/lib/libamdhip64.so.1' -> '/usr/lib/libamdhip64.so.1'
'usr/lib/libamd_comgr.so.1.7.0' -> '/usr/lib/libamd_comgr.so.1.7.0'
removed '/usr/lib/libamd_comgr.so'
'usr/lib/libamd_comgr.so' -> '/usr/lib/libamd_comgr.so'
'usr/lib/libamdocl12cl64.so' -> '/usr/lib/libamdocl12cl64.so'
'usr/lib/libamdocl-orca64.so' -> '/usr/lib/libamdocl-orca64.so'
'usr/lib/libdrm_amdgpo.so.1.0.0' -> '/usr/lib/libdrm_amdgpo.so.1.0.0'
removed '/usr/lib/libdrm_amdgpo.so.1'
'usr/lib/libdrm_amdgpo.so.1' -> '/usr/lib/libdrm_amdgpo.so.1'

@tuxutku
Copy link
Author

tuxutku commented Apr 9, 2021

@iandol yes files are supposed to be created by the script. Also aur doesn't clean the previous files. From what I know it just ovewrites onto previous files with cp. However I'm not too verse in aur so aur itself might be automatically cleaning the previous files. I'm thinking of creating a makefile that generates .deb package. That would solve lots of issues. Again however I'm not knowledgeable on makefiles or debian so its just something in my bucket list for now

@hollisticated-horse
Copy link

hollisticated-horse commented Apr 9, 2021

is the script going to be updated to 20.50 ?
I manually changed it and got this:

Downloading archive and extracting
WARNING: timestamping does nothing in combination with -O. See the manual
for details.

--2021-04-09 15:01:29--  https://drivers.amd.com/drivers/linux/amdgpu-pro-20.50-1234664-ubuntu-20.04.tar.xz
Resolving drivers.amd.com (drivers.amd.com)... 2a02:26f0:8c00:1b3::b51, 2a02:26f0:8c00:1ab::b51, 23.212.225.85
Connecting to drivers.amd.com (drivers.amd.com)|2a02:26f0:8c00:1b3::b51|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 697264228 (665M) [text/plain]
Saving to: ‘STDOUT’

-                   100%[===================>] 664,96M  8,75MB/s    in 70s     

2021-04-09 15:02:40 (9,45 MB/s) - written to stdout [697264228/697264228]

Extraction complete, creating the files
ar: /home/user/opencl-amd_aur_ubuntu_dir/amdgpu-pro-20.50-1234664-ubuntu-20.04/comgr-amdgpu-pro_1.7.0-1234664_amd64.deb: No such file or directory
mv: cannot stat '/home/user/opencl-amd_aur_ubuntu_dir/opencl/opt/amdgpu-pro/lib/x86_64-linux-gnu/libamd_comgr.so.1.7.0': No such file or directory
mv: cannot stat '/home/user/opencl-amd_aur_ubuntu_dir/opencl/opt/amdgpu-pro/lib/x86_64-linux-gnu/libamdhip64.so.1.5.19245': No such file or directory
mv: cannot stat '/home/user/opencl-amd_aur_ubuntu_dir/opencl/opt/amdgpu-pro/lib/x86_64-linux-gnu/libamdhip64.so.1': No such file or directory
mv: cannot stat '/home/user/opencl-amd_aur_ubuntu_dir/opencl/opt/amdgpu-pro/lib/x86_64-linux-gnu/libamd_comgr.so.1': No such file or directory
md5sum: ./usr/lib/libamd_comgr.so: No such file or directory
./usr/lib/libamd_comgr.so: FAILED open or read
md5sum: ./usr/lib/libamd_comgr.so.1.7.0: No such file or directory
./usr/lib/libamd_comgr.so.1.7.0: FAILED open or read
md5sum: ./usr/lib/libamdhip64.so: No such file or directory
./usr/lib/libamdhip64.so: FAILED open or read
md5sum: ./usr/lib/libamdhip64.so.1: No such file or directory
./usr/lib/libamdhip64.so.1: FAILED open or read
md5sum: ./usr/lib/libamdhip64.so.1.5.19245: No such file or directory
./usr/lib/libamdhip64.so.1.5.19245: FAILED open or read
./usr/lib/libamdocl12cl64.so: FAILED
./usr/lib/libamdocl64.so: FAILED
./usr/lib/libamdocl-orca64.so: FAILED
./usr/lib/libdrm_amdgpo.so.1: OK
./usr/lib/libdrm_amdgpo.so.1.0.0: OK
./usr/lib/libhsakmt.so.1: FAILED
./usr/lib/libhsakmt.so.1.0.6: FAILED
./usr/lib/libhsa-runtime64.so.1: FAILED
./usr/lib/libhsa-runtime64.so.1.2.0: FAILED
./etc/OpenCL/vendors/amdocl64.icd: OK
./etc/OpenCL/vendors/amdocl-orca64.icd: OK
./opt/amdgpu-pro/amdgcn/bitcode/hc.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/hip.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/ockl.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_daz_opt_off.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_daz_opt_on.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_finite_only_off.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_finite_only_on.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1010.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1011.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1012.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_1030.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_700.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_701.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_702.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_801.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_802.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_803.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_810.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_900.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_902.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_904.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_906.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_isa_version_908.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_unsafe_math_off.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_unsafe_math_on.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_wavefrontsize64_off.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/oclc_wavefrontsize64_on.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/ocml.bc: FAILED
./opt/amdgpu-pro/amdgcn/bitcode/opencl.bc: FAILED
md5sum: ./opt/amdgpu-pro/share/amd_comgr/LICENSE.txt: No such file or directory
./opt/amdgpu-pro/share/amd_comgr/LICENSE.txt: FAILED open or read
md5sum: ./opt/amdgpu-pro/share/amd_comgr/NOTICES.txt: No such file or directory
./opt/amdgpu-pro/share/amd_comgr/NOTICES.txt: FAILED open or read
md5sum: ./opt/amdgpu-pro/share/amd_comgr/README.md: No such file or directory
./opt/amdgpu-pro/share/amd_comgr/README.md: FAILED open or read
./opt/amdgpu/share/libdrm/amdgpu.ids: OK
./opt/amdgpu-pro/lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake: FAILED
md5sum: WARNING: 8 listed files could not be read
md5sum: WARNING: 39 computed checksums did NOT match
File corruption found! Terminating!```

@tuxutku
Copy link
Author

tuxutku commented Apr 9, 2021

@hollisticated-horse I've updated the script to 20.50

@iandol
Copy link

iandol commented Apr 21, 2021

There has been another driver release, https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-21-10

major='21.10'
minor='1247438'
amdver='2.4.100'

@tuxutku
Copy link
Author

tuxutku commented Apr 26, 2021

updated the script. It also now deletes the files that are reminiscent from previous installations.
From my testings clpeak works, blender detects gpus but crashes when rendering! (carrizo and polaris gpus)

@OdinVex
Copy link

OdinVex commented May 4, 2021

@tuxutku, Could you add a command-line argument to uninstall (current version)? Doing it manually bites (takes a little while). While Blender finally recognizes my devices, I get nothing but crashes when attempting to merely access GPU-stuff (even just menus). CPU-based OpenCL is fine. (Tried 2.92, 3.0, same issue. Mint.) By the way, why do you rename "libdrm_amdgpu" to "libdrm_amdgpo?

From my testings clpeak works, blender detects gpus but crashes when rendering! (carrizo and polaris gpus)

Ellesmere also crashes.

@iandol
Copy link

iandol commented Jun 2, 2021

For those having Blender crashes, you need to be using 2.93beta...

This PPA has a nice and regularly updated blender-git if you prefer to use APT: https://launchpad.net/~savoury1/+archive/ubuntu/blender

@OdinVex
Copy link

OdinVex commented Jun 2, 2021

For those having Blender crashes, you need to be using 2.93beta...

This PPA has a nice and regularly updated blender-git if you prefer to use APT: https://launchpad.net/~savoury1/+archive/ubuntu/blender

I had tried the 3.0 version directly (compiled it myself), and it crashed as well. I usually try to run my own compiles now so that I can disable some awful features (anyone can Google my username and Blender to determine) but I went from 2.92 to 3.0. I wonder what difference there is in the 2.93b that'd it would run without issue…? That PPA has a lot of other PPA-dependencies... I'm not keen on adding too many PPAs. Probably best to run Manjaro or Endeavour, Ubuntu and derivatives alike tend to crap out if too many pieces of software are upgraded out of their archaic old versions.

@iandol
Copy link

iandol commented Jun 2, 2021

No idea but it's possible fixes in 2.93 have not yet been ported to V3.0, or that there are brand new crashes in V3.0 (considering they are completely rewriting Cycles, and it isn't optimised for AMD at all that seems highly likely...)

@OdinVex
Copy link

OdinVex commented Jun 2, 2021

No idea but it's possible fixes in 2.93 have not yet been ported to V3.0, or that there are brand new crashes in V3.0 (considering they are completely rewriting Cycles, and it isn't optimised for AMD at all that seems highly likely...)

I've been hoping for quite some time that Blender would open up to Mesa OpenCL so that no one would ever need "Pro" drivers... Just AMDVLK and Mesa OpenCL. All the support for highly overpriced "green" cards using biased software frustrates me to no end.

@shadowStreamCode
Copy link

shadowStreamCode commented Jun 4, 2021

Great job !!
I'm trying to get functionality for AMD R9 270x on Linux Mint 20.1 (5.4.0-74-generic kernel).I have struggled with trying to install working opencl for days with no success. At this point I will go for anything that can run on this version of mint even downgrading kernel is OK.

DarkTable-cltest results: [opencl_init] could not create command queue for device 1: -6

What script mods need to be done to work?

@OdinVex
Copy link

OdinVex commented Jun 5, 2021

Great job !!
I'm trying to get functionality for AMD R9 270x on Linux Mint 20.1 (5.4.0-74-generic kernel).I have struggled with trying to install working opencl for days with no success. At this point I will go for anything that can run on this version of mint even downgrading kernel is OK.

DarkTable-cltest results: [opencl_init] could not create command queue for device 1: -6

What script mods need to be done to work?

Just curious, why are you using such an ancient kernel? Mint brought 5.8 quite a long time ago, now...it has a lot of AMD fixes including for GPU. You can use Update Manager to install the newer kernel. Mint offered it because of tons of fixes for things. It's one of the reasons I dropped Mint, though. Hangs onto the past far too much. Manjaro/Endeavour for me. I've no idea if the 270X can run the amdgpu-pro OpenCL.

@shadowStreamCode
Copy link

shadowStreamCode commented Jun 6, 2021

Just curious, why are you using such an ancient kernel? Mint brought 5.8 quite a long time ago, now...it has a lot of AMD fixes including for GPU. You can use Update Manager to install the newer kernel. Mint offered it because of tons of fixes for things. It's one of the reasons I dropped Mint, though. Hangs onto the past far too much. Manjaro/Endeavour for me. I've no idea if the 270X can run the amdgpu-pro OpenCL.

Running that old kernel for stability but yes I will have to move on to the 5.8 permanently with all the new fixes. If only the AMD driver issues were easily solved mint would be a solid distro. I wonder how problematic opencl is on manjaro for the 270x.

@shadowStreamCode
Copy link

shadowStreamCode commented Jun 7, 2021

After installing 5.8.0-55 and further testing I noticed opencl works but only when i run clinfo with root privileges. In-order to run under my user do I need to symlink files or add my user to videos or render groups?

@OdinVex
Copy link

OdinVex commented Jun 7, 2021

After installing 5.8.0-55 and further testing I noticed opencl works but only when i run clinfo with root privileges. In-order to run under my user do I need to symlink files or add my user to videos or render groups?

Check out the second half of the script, 130 onward. video and render, I believe.

@shadowStreamCode
Copy link

shadowStreamCode commented Jun 8, 2021

Check out the second half of the script, 130 onward. video and render, I believe.
Thanks for the feedback @OdinVex, after alot of testing and reinstalling I found the solution for this specific GPU.

Got it working with the following process: (This might help those running gcn 1.0 gpus)

  • Run the script
  • Added user to the groups but still no dice.
  • After long searching I learnt that GCN 1.0 cards need environment variables set for them to run openCL properly without requiring root for every terminal or application.
  • Add these to the environment variables 👍 Might need to add these manually.
    GPU_FORCE_64BIT_PTR=1
    GPU_USE_SYNC_OBJECTS=1
    GPU_MAX_ALLOC_PERCENT=100
    GPU_SINGLE_ALLOC_PERCENT=100
    GPU_MAX_HEAP_SIZE=100
  • Reboot.

Thanks for the openCL script @tuxutku .

@OdinVex
Copy link

OdinVex commented Aug 8, 2021

Outdated? 21.20.1271047

@oneblackcrayon
Copy link

oneblackcrayon commented Aug 23, 2021

Hello what do I have to do for remove mesa-opencl-icd please?
Beginner/Novice to Linux systems.
Great script @tuxutku!
Got it to install.

@OdinVex
Copy link

OdinVex commented Aug 25, 2021

Hello what do I have to do for remove mesa-opencl-icd please?
Beginner/Novice to Linux systems.
Great script @tuxutku!
Got it to install.

Ubuntu(-Like): sudo apt remove mesa-opencl-icd
Other Distros: Google "[Distro] remove package" Ex: Manjaro remove package

@oneblackcrayon
Copy link

oneblackcrayon commented Aug 25, 2021

Thank you @OdinVex

Hello what do I have to do for remove mesa-opencl-icd please?
Beginner/Novice to Linux systems.
Great script @tuxutku!
Got it to install.

Ubuntu(-Like): sudo apt remove mesa-opencl-icd
Other Distros: Google "[Distro] remove package" Ex: Manjaro remove package

@tuxutku
Copy link
Author

tuxutku commented Oct 12, 2021

Updated the script. Added all recorded unused files from previous scripts to the remove list. However due to mistakes I made generating the list, it might not be complete

@tuxutku
Copy link
Author

tuxutku commented Oct 16, 2021

Updated the script so that now it generates .deb package then installs that package.
here is a pre-built one: https://files.catbox.moe/02i5tf.deb
For other distros it still does direct install

--no-deb        : don't build the debian package on debian based systems
--no-install    : don't install anything
--no-cleaning   : skip cleaning on direct installs
--assume-debian : assumes system to be debian based
For example to build .deb package on non-debian systems use --no-install and --assume-debian together (still requires "dpkg" command)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment