You are not logged in.
Pages: 1
Hi,
Just installed intel-mkl but not sure how to set it up so programs (octave in this case) can use it instead of default libblas
I looked at the archwiki and forum posts but everything that turns up is about how to install it rather than how to actually use it. I am able to get it working but it is kind of ugly.
I first make symlinks of /opt/intel64/libmkl_rt.so to /usr/local/lib/libblas.so3 and same to /usr/local/lib/liblapack.so.3 then run octave, but it doesn't work, it is still using libblas and liblapack from /usr/lib.
Next I created a file call local.conf in /etc/ld.conf.d with just one line "/usr/local/lib" then run
sudo ldconfig
But that doesn't work either (I have rebooted on the safe side). So I put export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH in .bash_profile, reboot. It works for the octave-cli but not for octave --gui
Finally I have to edit octave's .desktop file and put EXEC=env LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ...
and then it works.
So 1) is /usr/local/lib supposed to override /usr/lib?
2) why didn't adding local.conf to /etc/ld.conf.d work?
3) why didn't export LD_LIBRARY_PATH in .bash_profile work for the gui?
4) Is there a more elegant way to achieve what I want to do? In Debian systems it is very simple, you can use update-alternatives to switch between different blas as system default on the fly and link binaries to it seamlessly at run time (e.g R, octave, python) I know arch doesn't have that mechanism, but I don't think what I just did was optimal and probably not correct even though it works. So what is the recommended way?
Thanks.
Last edited by kmod (2021-07-29 04:27:02)
Offline
LD_PRELOAD?
.bash_profile only applies to login shells. If bash isn't your login shell (eg. during a GUI session…) then it's not invoked.
To limit and control the impact (I'm not sure whether mkl is a perfect drop-in, eg. there's a specific build for R) I'd probably go for a wrapper script, sth. along
/usr/bin/mklwrap
#!/bin/sh
export LD_PRELOAD=/opt/intel64/libmkl_rt.so:$LD_PRELOAD
$@Offline
Hi, I think LD_PRELOAD would work but this is along the same vein of using LD_LIBRARY_PATH, also, I think you need to link libmkl_rt.so to libblas.so.3 since ldd octave binary shows that it is looking for libblas.so.3
Now in Debian/Ubuntu update-alternatives basically creates a symlink to a default library path like /usr/lib and switch the source on the fly (On Ubuntu /usr/lib/libblas.so is a symlink to whatever alternative in use) Here since /usr/lib is already used (not a symlink) I am thinking I could link to /usr/local/lib instead but why is it not being loaded without explicitly told to either with LD_LIBRARY_PATH or LD_PRELOAD?
Since /usr/local/bin is in the $PATH and takes precedent over /usr/bin I would think the same should be true for /usr/local/lib and /usr/lib. Where is this configuration stored?
Re. R-mkl. Yes that is an AUR package. Maybe I am missing something but I can link it to whatever blas I want at run time by changing system blas so I am not seeing any advantage of compiling with mkl.
I switch between openblas and mkl all the time for benchmarking via update-alternatives in Ubuntu. I just got R from CRAN, no special juice there. Same with numpy (aur also has a numpy-mkl package)
Last edited by kmod (2021-07-29 08:55:43)
Offline
deleted. This should be in the end of the thread, not sure why it got inserted in the middle
Last edited by kmod (2021-08-08 03:38:58)
Offline
/usr/bin/gnome-shell
#!/bin/sh
if [ "x$XDG_SESSION_TYPE" = "xwayland" ] &&
[ "x$XDG_SESSION_CLASS" != "xgreeter" ] &&
[ -n "$SHELL" ] &&
grep -q "$SHELL" /etc/shells &&
! (echo "$SHELL" | grep -q "false") &&
! (echo "$SHELL" | grep -q "nologin"); then
if [ "$1" != '-l' ]; then
exec bash -c "exec -l '$SHELL' -c '$0 -l $*'"
else
shift
fi
fi
SETTING=$(G_MESSAGES_DEBUG='' gsettings get org.gnome.system.locale region)
REGION=${SETTING#\'}
REGION=${REGION%\'}
if [ -n "$REGION" ]; then
unset LC_TIME LC_NUMERIC LC_MONETARY LC_MEASUREMENT LC_PAPER
if [ "$LANG" != "$REGION" ] ; then
export LC_TIME=$REGION
export LC_NUMERIC=$REGION
export LC_MONETARY=$REGION
export LC_MEASUREMENT=$REGION
export LC_PAPER=$REGION
fi
fi
exec /usr/lib/gnome-session-binary "$@"Is one of the conditions for exec bash -c "exec -l '$SHELL' -c '$0 -l $*'" being executed not being met?
Offline
/usr/bin/gnome-shell
#!/bin/sh if [ "x$XDG_SESSION_TYPE" = "xwayland" ] && [ "x$XDG_SESSION_CLASS" != "xgreeter" ] && [ -n "$SHELL" ] && grep -q "$SHELL" /etc/shells && ! (echo "$SHELL" | grep -q "false") && ! (echo "$SHELL" | grep -q "nologin"); then if [ "$1" != '-l' ]; then exec bash -c "exec -l '$SHELL' -c '$0 -l $*'" else shift fi fi SETTING=$(G_MESSAGES_DEBUG='' gsettings get org.gnome.system.locale region) REGION=${SETTING#\'} REGION=${REGION%\'} if [ -n "$REGION" ]; then unset LC_TIME LC_NUMERIC LC_MONETARY LC_MEASUREMENT LC_PAPER if [ "$LANG" != "$REGION" ] ; then export LC_TIME=$REGION export LC_NUMERIC=$REGION export LC_MONETARY=$REGION export LC_MEASUREMENT=$REGION export LC_PAPER=$REGION fi fi exec /usr/lib/gnome-session-binary "$@"Is one of the conditions for exec bash -c "exec -l '$SHELL' -c '$0 -l $*'" being executed not being met?
/usr/bin/gnome-shell is a binary apparently. I tried to cat it and get only gibberish.
Last edited by kmod (2021-07-30 01:07:05)
Offline
gnome-session not gnome-shell sorry.
Offline
Hi, mine is exactly the same as yours.
shopt login_shell is off for both wayland and x11, xsession is not sourcing .bash_profile but wayland is.
However putting the path in .bashrc istead of .bash_profile works for xsession.
Last edited by kmod (2021-07-30 02:38:34)
Offline
In wayland the $PATH include ~/.local/bin and ~/bin as defined in bash_profile but they are missing in x session.
Is one of the conditions for exec bash -c "exec -l '$SHELL' -c '$0 -l $*'" being executed not being met?
if [ "x$XDG_SESSION_TYPE" = "xwayland" ] &&
shopt login_shell is off for both wayland and x11
In the shell parenting gnome-session or some gnome-terminal window running bash (where this is totally expected because *that* bash is not a login shell for sure)
In general, you cannot expect or rely on random shells (gnome-shell) to source other shell specific configurations, https://wiki.archlinux.org/title/Environment_variables
I can link it to whatever blas I want at run time by changing system blas so I am not seeing any advantage of compiling with mkl.
My point was that its existence might implicate that mkl is not necessarily a binary-copatible perfect drop-in for openblas.
Since /usr/local/bin is in the $PATH and takes precedent over /usr/bin I would think the same should be true for /usr/local/lib and /usr/lib. Where is this configuration stored?
ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified
on the command line, in the file /etc/ld.so.conf, and in the trusted directories, /lib and /usr/lib (on some 64-bit
architectures such as x86-64, /lib and /usr/lib are the trusted directories for 32-bit libraries, while /lib64 and
/usr/lib64 are used for 64-bit libraries).
ldconfig is picky about symlinks and only picks up the newest versions of libraries.
If you want to control the resolution order, you need to set LD_LIBRARY_PATH accordingly (again: LIMITING THE IMPACT AS MUCH AS POSSIBLE, don't set that as a global variable, use some wrapper script for eg. octave )
Offline
Actually the problem appears to be more serious and systemic that I thought. I use gnome-shell as my DE. It appears that .bashrc and .bash_profile are not being sourced when login to xorg session.
In wayland the $PATH include ~/.local/bin and ~/bin as defined in bash_profile but they are missing in x session.
So the user defined environmental variables are not being loaded at login for xorg. It looks like this issue but it is the other way around https://bbs.archlinux.org/viewtopic.php?id=218197 In the link .bashrc and .bash_profile are not sourced in wayland session but here in xorg.
It looks like something is broken in gnome-shell shipped with Arch (doesn't happen in Fedora)
While I still don't have a satisfactory solution to the problem in this thread. I did find a way to fix this. It appears that xorg session ignores .bash_profile, but renaming it to .profile or making a copy (cp ~/.bash_profile ~/.profile) works. Now xorg session picks up ~/.local/bin and ~/bin in $PATH
But wayland does pick up .bash_profile.
https://askubuntu.com/questions/121073/ … a-terminal
Last edited by kmod (2021-08-08 03:40:22)
Offline
It appears that xorg session ignores .bash_profile
Yes…?
.bash_profile only applies to login shells. If bash isn't your login shell (eg. during a GUI session…) then it's not invoked.
But wayland does pick up .bash_profile.
Yes, that's in the gnome-session script that loqs posted.
It's restarted with a login shell if $XDG_SESSION_TYPE is wayland … I pointed out why that happens in #9 :\
Offline
It appears that xorg session ignores .bash_profile
Yes…?
seth wrote:.bash_profile only applies to login shells. If bash isn't your login shell (eg. during a GUI session…) then it's not invoked.
But wayland does pick up .bash_profile.
Yes, that's in the gnome-session script that loqs posted.
It's restarted with a login shell if $XDG_SESSION_TYPE is wayland … I pointed out why that happens in #9 :\
Sorry man I missed your post. As I was asking question in Newbie corner here I was giving instruction to a newbie on another forum for another distro which I am more familiar with. Something got lost in the multitasking when I had two systems in front of me and posting on two forums. ![]()
Offline
Pages: 1