Thursday 29 August 2019

how to add user or change password in ubuntu

to add user:
sudo adduser <name>
(then enter password for <name>)

to change the user right
sudo usermod -aG sudo <name>

to list all sudoers / root users
getent group sudo

to change <name> password
sudo passwd <name>

Training Neural Nets on Larger Batches: Practical Tips for 1-GPU, Multi-GPU & Distributed setups

[original source: https://medium.com/huggingface/training-larger-batches-practical-tips-on-1-gpu-multi-gpu-distributed-setups-ec88c3e51255]


Wednesday 28 August 2019

how to set PATH, LD_LIBRARY_PATH, PYTHONPATH

#export PYTHONPATH=/home/ninja/workspace/caffe/python
export PYTHONPATH=/home/ninja/workspace/caffe3/python

#export PATH=/home/ninja/anaconda3/condabin:/home/ninja/bin:/home/ninja/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ninja/anaconda/bin:/usr/local/include/opencv2:/usr/local/cuda-10.0/bin
export PATH=/home/ninja/bin:/home/ninja/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/include/opencv2:/usr/local/cuda-10.0/bin
#PATH=$PATH:$HOME/anaconda/bin:/usr/local/cuda/bin:/usr/local/include/opencv2
#PATH=$PATH:$HOME/anaconda/bin:/usr/local/cuda/bin # 10.0
#PATH=$PATH:$HOME/anaconda/bin:/usr/local/cuda-9.0/bin
#PATH=$PATH:$HOME/anaconda/bin:/usr/local/cuda-8.0/bin

export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu/:/usr/local/cuda-10.0/lib:/home/ninja/anaconda3/envs/demo/lib
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/ninja/.conda/envs/keras3/lib:/usr/local/lib

hostname/ip, username and password (passphrase)

1. set the ssh password of remote ip address using the following commands:-
 $  ssh-keygen (no passphase)
 $  ssh-copy-id user@192.168.1.123
 $  ssh-copy-id user@192.168.1.234
 $  ssh-add

2. set the default hostname as following:-
$ sudo gedit /etc/hosts
(edit the file with <ip address> <corresponding hostname>)
192.168.1.136    anyhostname

3. set the default username of each hostname/ip
$ sudo gedit ~/.ssh/config
(edit the file with <hostname> <username>)
anyhostname anyusername

This way, you can even skip the "anyusername@" and do just "ssh anyhostname"

4. to debug
$ ssh -vv user@host

how to list out current tcp process and its id

lsof -i tcp

Tuesday 27 August 2019

how to safely remove the pendrive from ubuntu system

udisksctl unmount --block-device /dev/sdd1

we can use "df -h" to check the current value for pendrive (/dev/sdd1)

RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED, allow_unreachable=True) # allow_unreachable flag

torch.manual_seed(16)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"

how to replace the text in vim

# general 
:%s,foo/bar/baz,foo/bar/boz,g
 
# special characters
:%s,data\[0\],data,g 
  
:%s/\/Users\/tom\/documents\/pdfs\//<new text>/g

Monday 26 August 2019

how to change the current folder permission, eg. create folder

sudo chmod -R ugo+rw ./*

 

===

sudo chmod 777 ./folder, everyone can access the folder

sudo chmod 700 ./folder, only login user can access the folder, guest cannot access other user folder, restrict to logged user only

how to install pinyin under ubuntu

sudo apt-get install ibus-pinyin ibus-libpinyin pinyin-database

Wednesday 21 August 2019

undefined reference to symbol ‘_ZN2cv6String10deallocateEv

使用qt编译Caffe时出现如下错误:
undefined reference to symbol ‘_ZN2cv6String10deallocateEv‘
error adding symbols: DSO missing from command line
 
原因是因为出现了opencv 高低版本的冲突,TX2 本身已经安装了opencv3.4,而安装caffe时又执行了:
apt-get install libopencv-dev
 
从而出现了opencv版本冲突问题,解决办法是执行:
sudo apt-get autoremove libopencv-dev

Tuesday 20 August 2019

To compress avi into mp4, x264 (web-cased format) using ffmpeg

ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a aac -b:a 192k -ac 2 out.mp4

Sunday 18 August 2019

The imported target “Qt5::Gui” references the file “/usr/lib/x86_64-linux-gnu/libEGL.so” but this file does not exist

sudo rm /usr/lib/x86_64-linux-gnu/libEGL.so; sudo ln /usr/lib/x86_64-linux-gnu/libEGL.so.1 /usr/lib/x86_64-linux-gnu/libEGL.so

grfmt_exr.hpp:52:31: fatal error: ImfChromaticities.h: No such file or directory

sudo apt-get install libopenexr-dev

No rule to make target ;usr/lib/x86_64-linux-gnu/libGL.so

sudo rm usr/lib/x86_64-linux-gnu/libGL.so

sudo ln -s  /usr/lib/libGL.so.1  /usr/lib/x86_64-linux-gnu/libGL.so

Tuesday 13 August 2019

to run tensorflow without session

from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession
config = ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)

Wednesday 7 August 2019

/usr/bin/x86_64-linux-gnu-ld: cannot find -lboost_python3

$ cd /usr/lib/x86_64-linux-gnu$ sudo ln -s libboost_python-py35.so libboost_python3.so

Thursday 1 August 2019

tmux - ubuntu multiple terminal sessions

(image source: https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/)

openpose: how to install

1. how to build openpose

cmake -DOpenCV_INCLUDE_DIRS=/usr/local/include \
  -DOpenCV_LIBS_DIR=/usr/local/lib \
  -DCaffe_INCLUDE_DIRS=/home/"${USER}"/workspace/caffe3/distribute/include \
  -DCaffe_LIBS=/home/"${USER}"/workspace/caffe3/build/lib/libcaffe.so -DBUILD_CAFFE=OFF ..


cmake -Dpython_version=3 -DBUILD_PYTHON=1 -DCMAKE_INSTALL_PREFIX=/home/ninja/workspace/openpose/build/install ..

make all -j32

sudo make install

export PYTHONPATH=/home/ninja/workspace/openpose/build/install/python

2. how to run testing

./build/examples/openpose/openpose.bin --video examples/media/video.avi

CUDA_VISIBLE_DEVICES=0 ./build/examples/openpose/openpose.bin --net_resolution "160x80" --video examples/media/video.avi


3. how to use python library

ninja@pp-pc:~/workspace/openpose$ python build/examples/tutorial_api_python/01_body_from_image.py

(an output image will be shown)


4. how to use docker (failed)

docker run -it --rm --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0 cwaffles/openpose-python

apt-get install xauth


docker run -it --rm --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0 openpose:docker

modules/python_bindings_generator/pyopencv_generated_include.h' failed

1. cd to workspace/opencv

2.  then type,
python ./modules/python/src2/gen2.py ./build/modules/python_bindings_generator ./build/modules/python_bindings_generator/headers.txt
 
3.after that, continue as usual cmake and make 

/usr/lib/x86_64-linux-gnu/libunwind.so.8: undefined reference to `lzma_index_end@XZ_5.0'

may be python version is wrong, try

cmake -Dpython_version=3 ..

how to mount the host folder into docker folder

 docker run -it --rm --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0 -v /home/ninja/tmp/:/openpose/tmp openpose:docker

-v host_folder:docker_folder

How to check the current cudnn?

dpkg -l | grep cudnn

ubuntu to find library dependencies

ldd /usr/local/lib/libopencv_core.so