2017年6月28日 星期三

build caffe error

Q1: Can't find hdf5.h when build caffe

Ans:
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/ and
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/

Q2: caffe compilation error (on make all step) "[.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1

Ans:
sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_python-py35.so /usr/lib/x86_64-linux-gnu/libboost_python3.so


Q3: .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode

Ans:
# OPENCV_VERSION := 3
To use OpenCV 3.X with Caffe, you should uncomment this line. You can refer to the 197th line in Makefile for the reason.

Q4: Multi-GPU

Ans:
uncomment USE_NCCL := 1 in Makefile.config and install nccl first,
$ git clone https://github.com/NVIDIA/nccl.git
$ cd nccl
$ sudo make install -j8

Q5: runing caffe error ../build/tools/caffe: error while loading shared libraries: libnccl.so.1: cannot open shared object file: No such file or directory

Ans:
add libnccl.so.1 path to LD_LIBRARY_PATH
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64:/usr/local/cuda-8.0/extras/CUPTI/lib64:/usr/local/lib"

Q6: can't import caffe in python
make pycaffe
make distribute
export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH


referance:
https://github.com/NVIDIA/DIGITS/issues/156
https://github.com/BVLC/caffe/issues/4610
https://github.com/BVLC/caffe/issues/4621

2017年6月21日 星期三

ubuntu中文亂碼

install locales:
sudo apt-get update && sudo apt-get install locales

sudo locale-gen zh_TW zh_TW.UTF-8 zh_CN.UTF-8 en_US.UTF-8
export LANG="zh_TW.UTF-8"

顯示目前已安裝語系
$ locale -a
顯示語系設定
$ locale
產生語系檔案
 sudo locale-gen zh_TW zh_TW.UTF-8 zh_CN.UTF-8 en_US.UTF-8

選擇安裝語系
sudo dpkg-reconfigure locales

sudo update-locale LANG="zh_TW.UTF-8" LANGUAGE="zh_TW"

個人
vim ~/.bashrc
export LC_CTYPE=zh_TW.UTF-8 # 可以輸入UTF-8中文
export LC_MESSAGES=zh_TW.UTF-8 # 可以顯示UTF-8中文

系統全域設定
sudo vim /etc/default/locale
LC_CTYPE=zh_TW.UTF-8
LC_MESSAGES=zh_TW.UTF-8
or
sudo vim /etc/environment
LC_CTYPE=zh_TW.UTF-8
LC_MESSAGES=zh_TW.UTF-8



reference:
https://unix.stackexchange.com/questions/223533/cant-install-locales
http://www.davidpai.tw/ubuntu/2011/ubuntu-set-locale/

2017年6月19日 星期一

docker run jupyter notebook

docker run -ti -p 8888:8888 docker_image_name

jupyter notebook --ip '*' ---port 8888 --allow-root

error:
in client:
A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration.
in server:
404 GET /nbextensions/widgets/notebook/js/extension.js?v=20170619093750

公司proxy擋ipython notebook 執行

顯示圖片 IOPub data rate exceeded.
--NotebookApp.iopub_data_rate_limit=1.0e10

reference
https://stackoverflow.com/questions/43288550/iopub-data-rate-exceeded-when-viewing-image-in-jupyter-notebook

2017年6月14日 星期三

ipython can't reload module when run modified file

fileA.py
import fileB
...

fileB.py
print (0)

in IPYTHON
First time, when i run fileA.py, it print 0
then, i modify the fileB.py
print(1)

second time, run fileA.py, it also print 0

because the run magic function do not use deepreload

reference:
https://stackoverflow.com/questions/13150259/ipython-re-importing-modules-when-using-run
http://ipython.org/ipython-doc/dev/api/generated/IPython.lib.deepreload.html

2017年6月7日 星期三

ParlAI train an attentive LSTM example error

In ParlAI
Trains an attentive LSTM model on the SQuAD dataset with a batch size of 32 examples (pytorch and regex):
```bash
python examples/drqa/train.py -t squad -bs 32
```
with an error:
version `GOMP_4.0' not found 

solution:
rename or remove the libgomp.so.1 in pytorch package
force it to use libgomp.so.1 installed by the system

sudo mv /usr/local/lib/python3.5/dist-packages/torch/lib/libgomp.so.1 /usr/local/lib/python3.5/dist-packages/torch/lib/libgomp.so.1.back

reference:
https://github.com/hughperkins/pytorch/issues/28

2017年6月3日 星期六