Install OpenCL(AMD SDK kit) on linux without ROOT privilege - linux

I am trying to install OpenCL(AMD) on linux, but I am stuck on the last step(install ICD)
It seems like ICD HAS to be installed at /etc/OpenCL/vendor, but I don’t have root access to the computer.
Is there any way to make OpenCL work without installing ICD? (or maybe through an environment variable to add search path for ICD files?)
It just seems really inconvenient for people like us when ICD file path is hardcoded.

Put the ICD-files in /some/path/icd and then export the path like so:
export OPENCL_VENDOR_PATH=/some/path/icd
It used to work in previous versions at least. I would be surprised if they changed it.

Here is a sketch of how to do a "user" or "local" install of the AMD OpenCL SDK without administrator privileges. Step 9 also provides a method to use the AMD OpenCL platform along with selected platforms installed system-wide.
The installation directory /local/install/path and current SDK version just need to be modified to suit.
Download the AMD OpenCL SDK 64 bit.
$ tar -xvzf AMD-APP-SDK-v2.8-RC-lnx64.tgz
$ tar -xvzf icd-registration.tgz
$ cd AMD-APP-SDK-v2.8-RC-lnx64
$ mkdir /local/install/path
$ cp -r lib /local/install/path
$ cp -r include /local/install/path
$ cp -r ../etc /local/install/path
Optional: make symbolic links for desired system installed platforms:
$ ln -s /etc/OpenCL/vendors/nvidia.icd /local/install/path/etc/vendors/nvidia.icd
$ export OPENCL_VENDOR_PATH=/local/install/path/etc/vendors
$ export LD_LIBRARY_PATH=/local/install/path/lib/x86_64:$LD_LIBRARY_PATH
$ cc -I/local/install/path/include -L/local/install/path/lib/x86_64 -lOpenCL demo.c
$ ./a.out

Just an update on this as I suddenly found myself having the same issue (again). I had to disable the buggy Mesa icd which apparently is crashing under non-root runs. Frustrating as it's more a problem with the API handling errors while listing each platform more than an error with permissions or clinfo. Make sure to disable each platform icd to isolate which one is having issues. Hope this helps someone later.

Related

Making gfortran version 11 as default

My code runs fine with the command
gfortran-11 Hello.f90 -o Hello
but if I check the version of the gfortran, it shows 9.3.0 on Ubuntu 20.04.
So my concern is how to make it default or do I have to type gfortran-11 every time I use it?
One way to solve this is to create a symlink to gfortran-11 called gfortran, and to add this symlink to your PATH with higher priority than the original gfortran.
This could be acheived by e.g. running
mkdir ~/.bin
ln -s [path_to_gfortran-11] ~/.bin/gfortran
and then adding
export PATH=~/.bin:$PATH
to your .bashrc or equivalent.
This is really a system administration question. Since it tangentially deals with a compiler, it might be on-topic.
There are various ways how concurrent versions are treated in various operating systems. If you use Linux, you can use
alias gfortran=gfortran-11
You can put this into your ~/.bashrc or some equivalent, if you use one (e.g., the ~/.bash_aliases file - see https://askubuntu.com/questions/1414/how-to-create-a-permanent-alias).
For tools like Make you can normally set
export FC=gfortran-11
or
FC=gfortran-11 ./make
or some other variable name that your Makefile happens to use. I use this routinely with SCons.
Another good option is the update-alternatives system. See https://askubuntu.com/questions/26498/how-to-choose-the-default-gcc-and-g-version
If you configure (install) the appropriate options according to the instructions (change g++ to gfortran), you will be able to switch between the versions using
sudo update-alternatives --config gfortran

Install go (golang) on Raspbian

I checked diverse forums but I still did not make it working.
I like to install go (golang) on my Raspberry PI - Raspbian:
With
sudo apt-get install golang
I installed go and with
export GOPATH=$home/pi/gocode
i set the GOPATH so i tryed to install from a homepage a new program with (sudo go get -u github.com/....) but, I only get "cannot download, $GOPATH not set. For more details see: go help gopath".
I really get crazy for my studip simple mistake that i do not see.
I would be pleased if i get a very detailed "how to do" discription since I am new to Linux and Raspbian, so everything which is made for real dummys should be good enough for me.
Thank you for your help.
This are detailed instructions about how to install Go on Raspbian Stretch from the repositories.
As of today, 2018-01-30, this will install Go 1.7. The most actual version for manual installation from the downloads is Go 1.9.3.
I. Login to your user on the Raspberry Pi (I'm using the default user pi).
II. Install Go (golang)
pi#pi3-2:~ $ sudo apt update
pi#pi3-2:~ $ sudo apt install golang
III. Create a working directory for all your go projects in your $HOME directory. It's best to name it go, as this defaults to the GOPATH in future Go versions (starting with Go 1.8).
pi#pi3-2:~ $ mkdir go
IV. Append the $GOPATH environment variable and modified PATH settings to your .profile
pi#pi3-2:~ $ echo 'export GOPATH=$HOME/go' >> ~/.profile
pi#pi3-2:~ $ echo 'PATH="$HOME/go/bin:$PATH"' >> ~/.profile
V. Logout and Relog with the new settings then check your settings
pi#pi3-2:~ $ go env
GOARCH="arm"
GOBIN=""
GOEXE=""
GOHOSTARCH="arm"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/pi/go"
GORACE=""
GOROOT="/usr/lib/go-1.7"
GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_arm"
CC="gcc"
GOGCCFLAGS="-fPIC -marm -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build187598155=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
Especially make sure GOPATH points to your previously created Go working directory. Don't care about setting GOBIN as mentioned in some documentation. It's usually not necessary and Go will automatically use $GOPATH/bin/ for your Go installs.
However, you might also want to check the path settings (/home/pi/go/bin should be included) to make sure you can run the code you installed with go install.
pi#pi3-2:~ $ echo $PATH
/home/pi/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
VI. A few words about the Go working directory structure
Over time, the Go working directory will contain three sub-directories: bin, src and pkg. Except src they will be automatically created, when needed the first time. The structure for user pi will look like this:
/home
/pi
/go
/src
/pkg
/bin
bin will contain all Go executable's you have installed using go install command.
pkg will contain all compiled packages that can be imported into your projects.
src will contain all your source files, either your own or sources downloaded from external repositories.
For eksample the command go get github.com/petergloor/hello-go will automatically fetch and place the source files from the corresponding external Github repository into the local directory $HOME/go/src/github.com/petergloor/hello-go.
As it's rather common to fetch external repositories either for reference or contribution it becomes important to keep your directory structure always well organized and clean.
Apart from that you are free to organize your projects as long they are hierarchically structured below the $HOME/go/src/ directory and follow the rules mentioned in the documentation.
However, to clearly organize my projects I personally always place my projects into $HOME/go/src/github.com/my-github-account even if I don't have an external repository for it.
If you don't have a github account you can likewise use any other external repository account.
As I mentioned, even it's not needed at all I prefere to use my Github account to clearly identify my projects. And even it's not needed I will use the username pi to distinct the user from other project maintainers in the following example.
VII. So let's add a "hello world" project to test our installation.
a) First let's create the project folder and cd into its directory.
pi#pi3-2:~ $ mkdir -p $HOME/go/src/pi/helloworld
pi#pi3-2:~ $ cd $HOME/go/src/pi/helloworld
pi#pi3-2:~/go/src/pi/helloworld $
b) With an editor of your choice create a file main.go with the following content
// helloworld project main.go.
package main
import ("fmt")
// main is the entrypoint of the application.
func main() {
fmt.Println("Hello world! Greetings from Raspberry Pi")
}
Spacing doesn't matter at this point. Go provides a nice tool to do this for you.
c) Now try to run the program.
pi#pi3-2:~/go/src/pi/helloworld $ go run main.go
Hello world! Greetings from Raspberry Pi
pi#pi3-2:~/go/src/pi/helloworld $
In case you get an error, fix it! Carefully, check the spelling and cases (Go is case-sensitive).
d) Next lets format the code:
pi#pi3-2:~/go/src/pi/helloworld $ go fmt
Without a file name this will properly (re-)format all source files within this directory and below.
e) Next let's build helloworld as an executable procram, within this directory.
pi#pi3-2:~/go/src/pi/helloworld $ go build
pi#pi3-2:~/go/src/pi/helloworld $ ls
helloworld main.go
pi#pi3-2:~/go/src/pi/helloworld $
f) Now you can run it.
pi#pi3-2:~/go/src/pi/helloworld $ ./helloworld
Hello world! Greetings from Raspberry Pi
pi#pi3-2:~/go/src/pi/helloworld $
g) Finally let's install the program into the $HOME/go/bin/ directory.
pi#pi3-2:~/go/src/pi/helloworld $ go install
pi#pi3-2:~/go/src/pi/helloworld $ ls $HOME/go/bin
hello-go helloworld
pi#pi3-2:~/go/src/pi/helloworld $
h) If everything is done right it can be run by our pi user from anywhere by just entering the name of the command.
pi#pi3-2:~/go/src/pi/helloworld $ helloworld
Hello world! Greetings from Raspberry Pi
pi#pi3-2:~/go/src/pi/helloworld $ cd ~
pi#pi3-2:~ $ helloworld
Hello world! Greetings from Raspberry Pi
pi#pi3-2:~ $
Congratulations!
as of Nov 2019. (Please note if you need version 1.13+ please wget go1.13.3.linux-amd64.tar.gz manually)
OR sudo apt-get install golang-go - source
You just have to type following commands on your RPi
sudo apt-get update
sudo apt-get install golang --fix-missing
and when you type now go version following should be your output
pi#rpi1:~ $ go version
go version go1.11.6 linux/arm
Additionally, I also had the following installed before running everything
sudo apt-get install make gcc g++
How to install golang:
Download the latest tarball, go1.9.linux-armv6l.tar.gz, to a directory such as /home/pi/downloads.
Then use:
sudo tar -C /home/pi -xzf go1.9.linux-armv6l.tar.gz
to extract the go installation to the directory
/home/pi
creating /home/pi/go
to check use
go version
Which will give you the actual version of go.
It should be go1.9 linux/arm.
Please check with:
go env
or
go env GOPATH
the GOPATH direction
with
ls -a # (used in /home/pi/ )
give you a list of all files and also shows you ~/.profile
with
sudo nano ~/.profile
you can open that file an add the reccommended code for the go directory
export GOROOT=/home/pi/go
export GOPATH=/home/pi/go/bin
close with STRG + O and ENTER and STRG + X
check with
go env GOPATH
then use
source ~/.profile
then you can check again with
go env
Now go should be running on the latest version and should have the correct GOPATH directory
For me helpful was this link: https://tecadmin.net/install-go-on-debian/#
I really hope some others also give detailed descriptions of how to install a program in a brief and detailed way. Instead of 3 lines of single code.

OpenShift oc command line with Cygwin

I'm running Cygwin 64bit but can't seem to get OpenShift oc command line to work
I downloaded oc.tar.gz ( from here https://mirror.openshift.com/pub/openshift-v3/clients/3.6.173.0.5/linux/oc.tar.gz ), unzipped it and placed it in my path in /usr/bin
When I try to run: oc login I get the following.
-bash: /usr/bin/oc: cannot execute binary file: Exec format error
Do I need to somehow 'install' the executable ?
Any help would be much appreciated.
In addition to #Graham Dumpleton's answer:
open cygwin and check for directory /usr/local/bin
mkdir -p local/bin
$ cd /usr/local/bin
if it does not exists:
$ mkdir -p local/bin
finally extract the windows package:
$ cp /cygdrive/c/Users/me/Downloads/oc-3.5.5.31.24-windows.zip /usr/local/bin/
unzip oc-3.5.5.31.24-windows.zip
$ oc version
oc v3.5.5.31.24
kubernetes v1.5.2+43a9be4
features: Basic-Auth
Use the Windows binary from the following page:
https://github.com/openshift/origin/releases
From project homepage
https://www.cygwin.com/
Cygwin is not:
a way to run native Linux apps on Windows. You must rebuild your
application from source if you want it to run on Windows.
a way to magically make native Windows apps aware of UNIX®
functionality like signals, ptys, etc. Again, you need to build your
apps from source if you want to take advantage of Cygwin
functionality.

sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory

Please suggest a solution for solving this issue?? While giving the command:
sqlplus /nolog
the error that occurred:
sqlplus: error while loading shared libraries:
libsqlplus.so: cannot open shared object file: No such file or directory
The minimum configuration to properly run sqlplus from the shell is to set ORACLE_HOME and LD_LIBRARY_PATH. For ease of use, you might want to set the PATH accordingly too.
Assuming you have unzipped the required archives in /opt/oracle/instantclient_11_1:
$ export ORACLE_HOME=/opt/oracle/instantclient_11_1
$ export LD_LIBRARY_PATH="$ORACLE_HOME"
$ export PATH="$ORACLE_HOME:$PATH"
$ sqlplus
SQL*Plus: Release 11.1.0.7.0 - Production on Wed Dec 31 14:06:06 2014
...
sudo sh -c "echo /usr/lib/oracle/12.2/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf";sudo ldconfig
from https://help.ubuntu.com/community/Oracle%20Instant%20Client
I did solve this error by setting
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME
yes, not only $ORACLE_HOME/lib but $ORACLE_HOME too.
You should already have all needed variables in /etc/profile.d/oracle.sh. Make sure you source it:
$ source /etc/profile.d/oracle.sh
The file's content looks like:
ORACLE_HOME=/usr/lib/oracle/11.2/client64
PATH=$ORACLE_HOME/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_HOME
export LD_LIBRARY_PATH
export PATH
If you don't have it, create it and source it.
I know it's an old thread, but I got into this once again with Oracle 12c and LD_LIBRARY_PATH has been set correctly.
I have used strace to see what exactly it was looking for and why it failed:
strace sqlplus /nolog
sqlplus tries to load this lib from different dirs, some didn't exist in my install. Then it tried the one I already had on my LD_LIBRARY_PATH:
open("/oracle/product/12.1.0/db_1/lib/libsqlplus.so", O_RDONLY) = -1
EACCES (Permission denied)
So in my case the lib had 740 permissions, and since my user wasn't an owner or didn't have oracle group assigned I couldn't read it. So simple chmod +r helped.
On Ubuntu Server 20.04 and using instant client version 19.10.0.0, I used alien to install the rpm package. I got this error when I just used the -i option. However when, I added -c I did not have this issue. from the man page for alien:
-c, --scripts
Try to convert the scripts that are meant to be run when the package is installed and removed. Use this with caution,
because these scripts might be designed to work on a system unlike
your own, and could cause problems. It is recommended that you
examine the scripts by hand and check to see what they do before using
this option.
So it seems the correct configuration (in 19c) or the environment variables (in earlier versions) are set in these scripts which are not generated unless you run alien like this. (Thanks #Christopher Jones for correcting me on this)
sudo alien -i -c BasicPackage.rpm
sudo alien -i -c SqlPlus.rpm
PERMISSIONS:
I want to stress the importance of permissions for "sqlplus".
For any "Other" UNIX user other than the Owner/Group to be able to run sqlplus and access an ORACLE database , read/execute permissions are required (rx) for these 4 directories :
$ORACLE_HOME/bin , $ORACLE_HOME/lib, $ORACLE_HOME/oracore, $ORACLE_HOME/sqlplus
Environment. Set those properly:
A. ORACLE_HOME
(example: ORACLE_HOME=/u01/app/oranpgm/product/12.1.0/PRMNRDEV/)
B. LD_LIBRARY_PATH
(example: ORACLE_HOME=/u01/app/oranpgm/product/12.1.0/PRMNRDEV/lib)
C. ORACLE_SID
D. PATH
export PATH="$ORACLE_HOME/bin:$PATH"
You can try usage:
# echo "/usr/lib/oracle/12.2/client64/lib" > /etc/ld.so.conf.d/oracle.conf
# ldconfig
This problem are because oracleinstant client not configure shared library.
Could you please check if LD_LIBRARY_PATH points to the oracle libs
Don't forget
apt-get install libaio1 libaio-dev
or
yum install libaio
On Oracle's own Linux (Version 7.7, PRETTY_NAME="Oracle Linux Server 7.7"
in /etc/os-release), if you installed the 18.3 client libraries with
sudo yum install oracle-instantclient18.3-basic.x86_64
sudo yum install oracle-instantclient18.3-sqlplus.x86_64
then you need to put the following in your .bash_profile:
export ORACLE_HOME=/usr/lib/oracle/18.3/client64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME
in order to be able to invoke the SQLPlus client, which, incidentally, is called sqlplus64 on this platform.
This worked for me: sudo dnf install libnsl
It means you didn't set ORACLE_HOME and ORACLE_SID variables. Kindly set proper working $ORACLE_HOME and $ORACLE_SID and after that execute sqlplus /nolog command. It will be working.
#laryx-decidua: I think you are only seeing the 18.x instant client releases that are in the ol7_oci_included repo. The 19.x instant client RPMs, at the moment, are only in the ol7_oracle_instantclient repo. Easiest way to access that repo is:
yum install oracle-release-el7

Where can I find the Java SDK in Linux after installing it?

I installed JDK using apt-get install but I don't know where my jdk folder is. I need to set the path for that. Does any one have a clue on the location?
This depends a bit from your package system ... if the java command works, you can type readlink -f $(which java) to find the location of the java command. On the OpenSUSE system I'm on now it returns /usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/bin/java (but this is not a system which uses apt-get).
On Ubuntu, it looks like it is in /usr/lib/jvm/java-6-openjdk/ for OpenJDK, and in some other subdirectory of /usr/lib/jvm/ for Suns JDK (and other implementations as well, I think).
Debian is the same.
For any given package you can determine what files it installs and where it installs them by querying dpkg. For example for the package 'openjdk-6-jdk': dpkg -L openjdk-6-jdk
update-java-alternatives -l
will tell you which java implementation is the default for your system and where in the filesystem it is installed. Check the manual for more options.
$ which java
should give you something like
/usr/bin/java
This question will get moved but you can do the following
which javac
or
cd /
find . -name 'javac'
Use find to located it. It should be under /usr somewhere:
find /usr -name java
When running the command, if there are too many "Permission denied" message obfuscating the actual found results then, simply redirect stderr to /dev/null
find /usr -name java 2> /dev/null
Another best way to find Java folder path is to use alternatives command in Fedora Linux (I know its for Ubuntu but I hit this post from google just by its headline). Just want to share incase people like me looking for answers for fedora flavour.
To display all information regarding java
alternatives --display java
Three Step Process:
First:
open Terminal->$ whereis java
it would give output like this:
java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz
Second:
ls -l /usr/bin/java
It would give output like this:
lrwxrwxrwx 1 root root 22 Feb 9 10:59 /usr/bin/java -> /etc/alternatives/java
Third:
ls -l /etc/alternatives/java
output is the JDK path:
lrwxrwxrwx 1 root root 46 Feb 9 10:59 /etc/alternatives/java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Simple, try it:
It's /usr/local/java/jdk[version]
This question still seems relevant, and the answer seems to be a moving target.
On my debian system (buster):
> update-java-alternatives -l
java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64
However, if you actually go look there, you'll see there are multiple directories and symbolic links placed there by the package system to simplify future maintenance.
The actual directory is java-11-openjdk-amd64, with another symlink of default-java. There is also an openjdk-11 directory, but it appears to only contain a source.zip file.
Given this, for Debian ONLY, I would guess the best value to use is /usr/lib/jvm/default-java, as this should always be valid, even if you decide to install a totally different version of java, or even switch vendors.
The normal reason to want to know the path is because some application wants it, and you probably don't want that app to break because you did an upgrade that changed version numbers.
the command: sudo update-alternatives --config java will find the complete path of all installed Java versions
On Linux Fedora30 several versions of the full java JDK are available, specifically package names:
java-1.8.0-openjdk-devel.x86_64
java-11-openjdk-devel.x86_64
Once installed, they are found in: /usr/lib/jvm
To select the location/directory of a full development JDK (which is different from the simpler runtime only JRE) look for entries:
ls -ld java*openjdk*
Here are two good choices, which are links to specific versions, where you will have to select the version:
/usr/lib/jvm/java-1.8.0-openjdk
/usr/lib/jvm/java-11-openjdk
on OpenSUSE 13.1/13.2 its: /usr/lib64/jvm/java-1.6.0-openjdk-(version-number)
version-number can be 1.7.x 1.8.x etc. check software manager witch version you have installed...
André
This is the best way which worked for me
Execute this Command:-
$(dirname $(readlink $(which javac)))/java_home
below command worked in my debain 10 box!
root#debian:/home/arun# readlink -f $(which java)
/usr/lib/jvm/java-11-openjdk-amd64/bin/java

Resources