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日 星期六

2017年5月22日 星期一

Install opencv3.2.0 and opencv_contrib3.2.0 with CUDA7.5

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran

download:

https://github.com/opencv/opencv/releases
https://github.com/opencv/opencv_contrib/releases

確保兩個版本一致都是3.2

cd ~/opencv-3.2.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_OPENGL=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules ..
make -j8
sudo make install
sudo ldconfig

======================================================================
install opencv from pip
sudo pip install opencv-python
sudo pip install opencv-contrib-python:
======================================================================
issus:

fata error: LAPACKE_H_PATH-NOTFOUND when building OpenCV 3.2
sudo apt-get install liblapacke-dev checkinstall

If use nvidia-docker to install opencv with cuda, the issue is following
linked by target "example_gpu_alpha_comp" in directory /home/image/opencv-3.2.0/samples/gpu
-- Configuring incomplete, errors occurred!

Don't forget add
-DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs
after cmake
refference:
https://github.com/opencv/opencv/issues/6577

If using python don't forget install numpy
pip install numpy

2015年3月22日 星期日

opencv with cuda error

when i test my opencv package in c file by using the command
$ gcc cvtest.c -o cvtest  `pkg-config opencv --cflags --libs`
There are with some error

/usr/bin/ld: cannot find -lcufft
/usr/bin/ld: cannot find -lnpps
/usr/bin/ld: cannot find -lnppi
/usr/bin/ld: cannot find -lnppc
/usr/bin/ld: cannot find -lcudart

According to this post in stackoverflow
http://stackoverflow.com/questions/24322466/makefile-opencv-stopped-working

i change the command with -L to my cuda lib path
$gcc -L /usr/local/cuda/lib64 cvtest.c -o cvtest  `pkg-config opencv --cflags --libs`

it's working

or put the cuda lib path in LIBRARY_PATH
export LIBRARY_PATH=/usr/local/cuda/lib64

2015年3月16日 星期一

WIN7 + UBUNTU Installtation

先裝win7後裝UBUNTU14.04 直接進入UBUNTU的解決方式

sudo update-grub

sudo gedit /etc/default/grub


將 GRUB_HIDDEN_TIMEOUT=0註解

#GRUB_HIDDEN_TIMEOUT=0

sudo update-grub

sudo reboot