2019/3/12

pytorch notes..

ref:
~$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130


~$ python3 --version
Python 3.5.2
選好,就會出現...Run this command:
pip3 install https://download.pytorch.org/whl/cu100/torch-1.0.1.post2-cp35-cp35m-linux_x86_64.whl
pip3 install torchvision
!!不要follow instruction upgrade pip 到 19.0.3.會有 main 錯誤

然後裝 numpy 後就 OK
pip3 install numpy
測試..

開啟 python3.. 試試
from __future__ import print_function
import torch
x = torch.rand(5,3)
print(x)
會是
tensor([[0.6098, 0.0374, 0.9580],
        [0.9531, 0.2159, 0.9694],
        [0.5153, 0.7471, 0.1269],
        [0.0336, 0.2670, 0.2762],
        [0.8283, 0.4620, 0.9425]])
然後
torch.cuda.is_availebl()
True

2019/2/19

ubuntu 18.04 , change to MATE

apt install tasksel
tasksel install mate-desktop
裝完後。選 lightdm 登入
dpkg-reconfigure lightdm
選 lightdm 之後重開機就可以。

進入 mate 後,中文輸入要重新安裝。
這個在 Control Center -- Personal -- Language 中,先選 Traditional Chinese。(裝完顯示的是香港)
他會安裝中文字形 和輸入法 (iBus and fctix)。
然後Setting 頁面會有一個 iBus icon,在裡面可以加裝 酷音 輸入法。(剛add 完 traditional chinese 的話,要重開機才會出現Chinese)

之後,在 Status bar, 鍵盤icon 按又見,選 Preference,把 input method short-cut 改成 <Control> space
然後選 Space 是 "選字/Select"
這樣就可以了

2019/2/12

The following packages have unmet dependencies:
 libgl1-nvidia-glx : Depends: nvidia-alternative (= 384.130-1)
                     Depends: libnvidia-glcore (= 384.130-1) but 390.87-8~bpo9+1 is to be installed
                     Recommends: nvidia-kernel-dkms (= 384.130-1) or
                                 nvidia-kernel-384.130
E: Unable to correct problems, you have held broken packages.
Xorg.0.log:
The following packages have unmet dependencies:
 libgl1-nvidia-glx : Depends: nvidia-alternative (= 384.130-1)
                     Depends: libnvidia-glcore (= 384.130-1) but 390.87-8~bpo9+1 is to be installed
                     Recommends: nvidia-kernel-dkms (= 384.130-1) or
                                 nvidia-kernel-384.130
E: Unable to correct problems, you have held broken packages.
...
實際上 remove bumblebee, bumblebee-nvidia, primus 之後,load nvidia_drv.so 就 OK 了。
但是依然沒有畫面。

2019/1/16

xinput -- set each mouse's button mapping

有兩個mouse,一個左手用,一個右手,要怎麼設定呢?
ref: make mouse left handed-and-right-handed

就是使用 xinput 這個程式

debian default 沒有安裝,所以要用 apt-get install
jessie431:~$ xinput
⎡ Virtual core pointer                     id=2 [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer               id=4 [slave  pointer  (2)]
⎜   ↳ Kensington      Kensington Expert Mouse  id=10 [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad               id=13 [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                    id=14 [slave  pointer  (2)]
⎜   ↳ Logitech USB Optical Mouse               id=16 [slave  pointer  (2)]
⎣ Virtual core keyboard                    id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard              id=5 [slave  keyboard (3)]
    ↳ Power Button                             id=6 [slave  keyboard (3)]
    ↳ Video Bus                                id=7 [slave  keyboard (3)]
    ↳ Video Bus                                id=8 [slave  keyboard (3)]
    ↳ Power Button                             id=9 [slave  keyboard (3)]
    ↳ Integrated Camera                        id=11 [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard             id=12 [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                   id=15 [slave  keyboard (3)]

會列出所有 input device,和 id

然後用 set-button-map 來分別設定 device 的 button mapping (left, right handed)

可以用 get-button-map 看一下現在的設定。

舉例來說,Kensington 是left handed, Logitech 要是 right handed
先看一下..
jessie431:~$ xinput get-button-map 16
3 2 1 4 5 6 7 8 9 10 11 12 
設成 right handed:
jessie431:~$ xinput set-button-map 16 1 2 3 4 5 6 7 8 9 10 11 12
jessie431:~$ xinput get-button-map 16
1 2 3 4 5 6 7 8 9 10 11 12 
這樣 Logitech (id=16) 的 button mapping 就變更了,其他 device 的 mapping 沒變。

2019/1/14

在 build/modules/highgui/CMakeFiles/opencv_highgui.dir/src/ 下,找到:
window_gtk.cpp.o, window.cpp.o

參考 source : modules/highgui/src 下的檔案,有:
window_carbon, window_cocoa, window_gtk, window_QT, window_w32

猜是 configure 時,根據系統選了 window_gtk.cpp

所以是用GTK。

imshow --> cvShowImage --> cvImageWidget

然後,這一篇 竟然是 X Windows 的 Simple Sample。

2019/1/7

nuttx on stm32f4discovery

要 build nuttx 要用到 kconfig-frontends的 kconfig-conf,這個 debian 沒有 package,所以要 build from source.
buttx 的 repo 也有一份,可以 用那一份..
clone tools 下來,裡面就有 kconfig-frontends
看一下 INSTALL,有說明, default install path 是 /usr/local/bin,可以在 configure 時用 --prefix=PREFIX 來指定新的 install path
再參考 README.txt,裡面也有一個section 說明 kconfig-frontends. 配合..
cd tools/kconfig-frontends
./configure --disable-shared --enable-static --enable-mconf --disable-nconf --disable-gconf --disable-qconf 
            --disable-nconf --disable-utils --prefix=/home/charles-chang/nuttx-git/bin/
make 
make install
然後看看,kconfig-conf install 在 /home/charles-chang/nuttx-git/bin/bin 下。
寫好 exportpath.sh 把這個 加到 PATH 中。

然後參考這裡 說的..
cd nuttx
tools/configure.sh stm32f4discovery/usbnsh 
make menuconfig
修改一下 build-host 平台,是 Linux (default 是 Windows)
然後 make ,就完成了。

因為沒有 build 出 dfu,所以用 st-flash 來燒 *.bin,這會用到 SWD 那一端的 USB..
PC 接上 USB 之後...
st-flash write nuttx.bin 0x8000000
這樣就燒完了。

燒錄的 USB改插到 USB Power 上,對面的 micro-usb 接上 pc..
dmesg 可以看到 /dev/ttyACM0 出現。
screen /dev/ttyACM0 接上之後,等 10sec..按下 ENTER 三次..
就可以看到出現 nsh> 的 prompt
-- 奇怪我沒有看到任何 app 在裡面,也沒有 bin 目錄.

記得要看一下 configs/stm32f4discovery/README.txt

這一篇 有 build for sim (模擬器)。
build 完可以至直接在 console 下 run..
差異就是在 tools/configure.sh 的命令..