Setting Up a Debian Docker image with older boost library - linux

I have an already compiled Linux app which has become dated. To use it, I want to create a Docker image and an appropriate environment to work with. My problem is that is app requires an older version of the boost libraries. 1.57.0 to be specific.
I have been able to get boost installed (I believe correctly) but the app errors out.
The error that I am getting is:
undefined symbol: _ZN5boost15program_options3argE
I am hoping someone has experience with this. Briefly, my pipeline is:
get the rocker/verse Docker image that has Debian and R and some more goodies I need.
Bash in to it, apt-get install ... etc.
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev build-essential libbz2-dev libboost-all-dev
cd home
wget -O boost_1_57_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.tar.gz/download
tar xzvf boost_1_57_0.tar.gz
cd boost_1_57_0
./bootstrap.sh --with-libraries=atomic,chrono,context,coroutine,container,date_time,exception,filesystem,graph,graph_parallel,iostreams,locale,log,math,mpi,program_options,python,random,regex,serialization,signals,system,test,thread,timer,wave
./b2 toolset=gcc cxxflags=-std=gnu++0x
sudo ./b2 install
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
-----Edit: added additional bash code that was missing here
sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/local.conf’

Related

Installing .NET SDK on Ubuntu produces no executable dotnet file

Installing .NET SDK on Ubuntu 20.04 with the commands listed in the Install .NET on Ubuntu docs:
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-6.0
produces no dotnet executable.
Command 'dotnet' not found, but can be installed with:
sudo snap install dotnet-sdk
Listing files from the package:
dpkg -L dotnet-sdk-6.0 | grep -P "dotnet$"
gives
/usr/share/dotnet
The /usr/share/dotnet directory contains no executable. I compared this result with my other Ubuntu installation where I installed dotnet ages ago, and there it is installed in /usr/share/dotnet but there exists a /usr/share/dotnet/dotnet executable.
What am I doing wrong? How to install dotnet on Ubuntu with APT?
Using snap is not an option.
sudo apt reinstall dotnet-host and then sudo apt install dotnet-sdk-6.0 fixed the issue.
See: https://github.com/dotnet/installer/issues/12939
dpkg -S /usr/bin/dotnet says that it was created by dotnet-host.
So maybe that package is missing in dotnet-sdk-6.0 and must be installed separately. I imagine they will fix it in some future version.
tl;dr $ sudo apt install dotnet-host

Getting an error when installing the .Net 5 Runtime on Armbian (on an Orange Pi Zero)

I'm trying to install the .Net 5 Runtime on Armbian Focal (Ubuntu 20.04) or Buster (Debian 10), running on an Orange Pi Zero.
So I followed Microsoft's instructions here:
https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu
but on the last step:
sudo apt-get install -y aspnetcore-runtime-5.0
I get this error:
E: Unable to locate package aspnetcore-runtime-5.0
E: Couldn't find any package by glob 'aspnetcore-runtime-5.0'
E: Couldn't find any package by regex 'aspnetcore-runtime-5.0'
I then followed Microsoft's suggestion for installing it manually from here:
https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#apt-troubleshooting
But on the last step, again I get the same error.
Any ideas?
In summary, these are the steps I tried first:
wget https://packages.microsoft.com/config/ubuntu/20.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y aspnetcore-runtime-5.0
and these are the steps I tried when the above failed:
sudo dpkg --purge packages-microsoft-prod && sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y gpg
wget -O - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget https://packages.microsoft.com/config/ubuntu/{os-version}/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y aspnetcore-runtime-5.0
EDIT:
I've previously installed the .Net Core 3.1 Runtime on this exact same setup without any issues. I'm not sure if there is something in .Net 5 that is different which won't allow me to install it
From the first URL you linked: https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu
Package manager installs are only supported on the x64 architecture. Other architectures, such as ARM, must install .NET by some other means such as with Snap, an installer script, or through a manual binary installation.
A Pi is an ARM device, so the installation method you are trying to use is not supported.

lsb_release: command not found in latest Ubuntu Docker container

I just wanted to test something out real quick. So I ran a docker container and I wanted to check which version I was running:
$ docker run -it ubuntu
root#471bdb08b11a:/# lsb_release -a
bash: lsb_release: command not found
root#471bdb08b11a:/#
So I tried installing it (as suggested here):
root#471bdb08b11a:/# apt install lsb_release
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package lsb_release
root#471bdb08b11a:/#
Anybody any idea why this isn't working?
It seems lsb_release is not installed.
you can install it via
apt-get update && apt-get install -y lsb-release && apt-get clean all
This error can happen due to uninstalling or upgrading the default python3 program version in ubuntu 16.04
The way to correct this is by reinstalling the original python3 version which comes with ubuntu and relinking again. (in ubuntu 16.04 - the default python3 version is python 3.5
sudo rm /usr/bin/python3
sudo ln -s /usr/bin/python3.5 /usr/bin/python3
Just use cat /etc/os-release and that should display the OS details.
Screenshot from debian.
Screenshot from ubuntu.
Screenshot from fedora.
lsb_release.py lives in /usr/share/pyshared which to me doesn't look like python3.6 and above is referencing.
I found the following will create a link back from a later Python install to this /usr/share script:
sudo ln -s /usr/share/pyshared/lsb_release.py /usr/lib/python3.9/site-packages/lsb_release.py
In case one is trying to deal with lsb_release: command not found on fedora or redhat, the package to install is redhat-lsb-core , so sudo dnf install redhat-lsb-core
While writing Dockerfile we can add lsb-release package - like this
RUN apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install lsb-release -y \
&& apt-get clean all
Assuming OS is Ubuntu.

How to enable multithreading with Caffe?

I would like to compile / configure Caffe so that when I trained an artificial neural network with it, the training is multi-threaded (CPU only, no GPU). How to enable multithreading with Caffe? I use Caffe on Ubuntu 14.04 LTS x64.
One way is to use OpenBLAS instead of the default ATLAS. To do so,
sudo apt-get install -y libopenblas-dev
Before compiling Caffe, edit Makefile.config, replace BLAS := atlas by BLAS := open
After compiling Caffe, running export OPENBLAS_NUM_THREADS=4 will cause Caffe to use 4 cores.
If interested, here is a script to install Caffe and pycaffe on a new Ubuntu 14.04 LTS x64 or Ubuntu 14.10 x64. CPU only, multi-threaded Caffe. It can probably be improved, but it's good enough for me for now:
# This script installs Caffe and pycaffe on Ubuntu 14.04 x64 or 14.10 x64. CPU only, multi-threaded Caffe.
# Usage:
# 0. Set up here how many cores you want to use during the installation:
# By default Caffe will use all these cores.
NUMBER_OF_CORES=4
# 1. Execute this script, e.g. "bash compile_caffe_ubuntu_14.04.sh" (~30 to 60 minutes on a new Ubuntu).
# 2. Open a new shell (or run "source ~/.bash_profile"). You're done. You can try
# running "import caffe" from the Python interpreter to test.
#http://caffe.berkeleyvision.org/install_apt.html : (general install info: http://caffe.berkeleyvision.org/installation.html)
cd
sudo apt-get update
#sudo apt-get upgrade -y # If you are OK getting prompted
sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y -q -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" # If you are OK with all defaults
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev
sudo apt-get install -y --no-install-recommends libboost-all-dev
sudo apt-get install -y libatlas-base-dev
sudo apt-get install -y python-dev
sudo apt-get install -y python-pip git
# For Ubuntu 14.04
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler
# LMDB
# https://github.com/BVLC/caffe/issues/2729: Temporarily broken link to the LMDB repository #2729
#git clone https://gitorious.org/mdb/mdb.git
#cd mdb/libraries/liblmdb
#make && make install
git clone https://github.com/LMDB/lmdb.git
cd lmdb/libraries/liblmdb
sudo make
sudo make install
# More pre-requisites
sudo apt-get install -y cmake unzip doxygen
sudo apt-get install -y protobuf-compiler
sudo apt-get install -y libffi-dev python-dev build-essential
sudo pip install lmdb
sudo pip install numpy
sudo apt-get install -y python-numpy
sudo apt-get install -y gfortran # required by scipy
sudo pip install scipy # required by scikit-image
sudo apt-get install -y python-scipy # in case pip failed
sudo apt-get install -y python-nose
sudo pip install scikit-image # to fix https://github.com/BVLC/caffe/issues/50
# Get caffe (http://caffe.berkeleyvision.org/installation.html#compilation)
cd
mkdir caffe
cd caffe
wget https://github.com/BVLC/caffe/archive/master.zip
unzip -o master.zip
cd caffe-master
# Prepare Python binding (pycaffe)
cd python
for req in $(cat requirements.txt); do sudo pip install $req; done
echo "export PYTHONPATH=$(pwd):$PYTHONPATH " >> ~/.bash_profile # to be able to call "import caffe" from Python after reboot
source ~/.bash_profile # Update shell
cd ..
# Compile caffe and pycaffe
cp Makefile.config.example Makefile.config
sed -i '8s/.*/CPU_ONLY := 1/' Makefile.config # Line 8: CPU only
sudo apt-get install -y libopenblas-dev
sed -i '33s/.*/BLAS := open/' Makefile.config # Line 33: to use OpenBLAS
# Note that if one day the Makefile.config changes and these line numbers change, we're screwed
# Maybe it would be best to simply append those changes at the end of Makefile.config
echo "export OPENBLAS_NUM_THREADS=($NUMBER_OF_CORES)" >> ~/.bash_profile
mkdir build
cd build
cmake ..
cd ..
make all -j$NUMBER_OF_CORES # 4 is the number of parallel threads for compilation: typically equal to number of physical cores
make pycaffe -j$NUMBER_OF_CORES
make test
make runtest
#make matcaffe
make distribute
# Bonus for other work with pycaffe
sudo pip install pydot
sudo apt-get install -y graphviz
sudo pip install scikit-learn
# At the end, you need to run "source ~/.bash_profile" manually or start a new shell to be able to do 'python import caffe',
# because one cannot source in a bash script. (http://stackoverflow.com/questions/16011245/source-files-in-a-bash-script)
I have placed this script on GitHub: https://github.com/Franck-Dernoncourt/caffe_demos/tree/master/caffe_installation .
This is to just extend Franck's answer where he used sed to modify the config file. If you are having problems with that, here is another way to get the same thing done.
The difference is that instead of changing the config file you directly change the camke flag cmake -DCPU_ONLY=1 -DBLAS=open ..
$sudo apt update && sudo apt-get install -y libopenblas-dev
$git clone -b 1.0 --depth 1 https://github.com/BVLC/caffe.git . && \
pip install --upgrade pip && \
cd python && pip install -r requirements.txt && cd .. && \
mkdir build && cd build && \
cmake -DCPU_ONLY=1 -DBLAS=open .. && \
make -j"$(nproc)"
While building caffe, you have to add the -fopenmp to the CXXFLAGS and LINKFLAGS to support OPENMP. If you have a flag named OPENMP in the Makefil.config, you can simply set that to 1. You can use either OPENBLAS or Intel MKL BLAS library. While building the OPENBLAS you need to set USE_OPENMP=1 flag so that it supports OPENMP. After building caffe, please export the number of threads you want to use during runtime by setting up OMP_NUM_THREADS=n where n is the number of threads you want. Here is a good discussion related to multi-threading in Caffe: https://github.com/BVLC/caffe/pull/439

Can't install node.js on Linux server

I followed some instructions to install node.js on a Linux server and ran in to the following blocks. I started out by doing sudo apt-get install python-software-properties and that worked fine. Then, I did sudo add-apt-repository ppa:chris-lea/node.js. But, wait - there is no command add-apt-repository. OK, so I looked it up and it told me to do apt-get install software-properties-common and that would have been fine, except it gave me this error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package software-properties-common
Well, what can I do to get node.js on my server? Obviously, none of this works and it's Debian, in case you were wondering. I really need help on this. Basically, how can I install software-properties-common if it does not exist? It just won't show up.
For a Debian install of the latest node.js, you should follow these instructions, not requiring you to add the PPA:
sudo apt-get install python g++ make checkinstall
mkdir ~/src && cd $_
wget -N http://nodejs.org/dist/node-latest.tar.gz
tar xzvf node-latest.tar.gz && cd node-v*
./configure
checkinstall #(remove the "v" in front of the version number in the dialog)
sudo dpkg -i node_*
UPDATE: I wrote this a long time ago. Since then, I find using nvm a much less painful way to get node onto machines. As per link, steps are basically reduced to:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
nvm install node

Resources