2019年11月30日土曜日

寺田社長へ

色々とお疲れ様です。
やはりソフトとハードは理解出来る範囲でも手を動かすと楽しい趣味になります。
もちろん実用にもなります。
ブログ記事は読んでいていろんなインスピレーションも湧いて来ます。今回ブログを日記や日報として書き始めましたが、この様に書き始めると途中経過や後で見直した時にわかりやすくなるのでオススメです。

アッセンブラーよりc(c++)が一般的で小学生が作る時代です。ロジックなので子供も大人も関係ありません。むしろ記憶力が大変です。この年になると。。。

Z80もクローンがまだ売られていているようです。と言っても動かすまでが大変なので
オススメはarduinoと言うイタリアの組込です。基本はUNO
要はPICの後継者です。
PICはモデルによってアーキテクチャが違うので慣れが必要なのと生産中止や専用の書込み装置の購入やその書込み装置のアップデートやらが大変で今では少数派です。

arduino UNOは3000円でUSB書込み装置とシリアル通信を全てハードを一つにしています。ここが画期的でおそらく世界でこれを使う人は子供も含めて80%以上いると思います。ソフトもスケッチと呼ばれる専用のIDE総合開発環境ソフトもFREEでパソコンにダウンロード出来ます。学校の授業でも使っていると思いますし企業のちょっとしたテストや試作でも大活躍です。
なのでソフトの勉強はこれで始めるのが良いです。基本cなので恐らく幾らかは理解も出来ると思います。ネットで公開しているソフトをコピーして書込むと簡単に再現出来るものになっています。
お決まりのLチカです。1000msでhighとlowを無限ループで繰り返すだけですが、何度か最適なコードに書き直している様です。子供の教科書になる部分なので結構気を使って書いている様です。

当然ながら現在のW&Tのソフトはarduinoのスケッチです。世界中に配布可能です。

関連の書籍は豊富ですが沢山あり過ぎるのでネットで適当なブログがオススメ。
書籍でオススメはこれ
”Arduino計る、測る、量る”
https://shop.cqpub.co.jp/hanbai/books/42/42191.html

Arduino関数のカンニングペーパーはここが良いです。
公式ページの公式和訳
http://www.musashinodenpa.com/arduino/ref/

あとは興味を持って貰えそうなブログのオススメはこちら
http://radiopench.blog96.fc2.com
なぜおすすめかと言うと恐らく社長と同じ世代のひとで古くは無線もやっていたので測定器で検証するところはとても勉強になります。実際東京のメーカーズフェアでお会いしました。流石に元NECのエンジニアです。今は隠居で身近なおもちゃや百円ショップの機器を時間を掛けて検証しています。おもちゃ病院のボランティアもしているようです。
内容は当時の話を中心に興味あるのでは?この記事のコメント欄の下の書込みは当時の人の話で盛り上がっています。
http://radiopench.blog96.fc2.com/blog-entry-888.html
おもちゃの修理はこんな感じ。
今時のおもちゃはマイコン搭載して複雑な制御です。もちろん中国製です。その修理は回路アナログ回路がわからないとダメです。一般の人は通常は修理をしないで数千円出して新品を買い直しです。

あと先日のお話で会社のホームページの地図の更新で一方通行の表示に関しては解決されている様です。

なのでホームページの改修の際にAPIでグーグルマップのhttps://www.google.co.jp/maps/place/%E9%96%A2%E8%A5%BF%E9%9B%BB%E6%A9%9F%E5%B7%A5%E6%A5%AD%EF%BC%88%E6%A0%AA%EF%BC%89/@34.6736391,135.573609,19.72z/data=!4m5!3m4!1s0x0:0xfa47ed48d964390b!8m2!3d34.6736389!4d135.5737121?hl=ja
を叩いて表示を埋め込めば良いだけになります。
配工会のアプリはそれを会社単位でAPIを叩いてそこに会社情報を埋め込んだアプリになっていると思います。


2019年11月16日土曜日

年内の目標

1AIメンテくんの仕上げ
2大阪商工会議所のAIコンテストの応募
3FLIRイタリアのモバイルアプリチャレンジの応募
4関西電機アプリのアップルへの申請
5メンテナンスドローンの再構築
6関西電機工業BIZのホームページの仕上げ
7それぞれの英語動画の編集
8和洋女子大学の転倒検知の段取り
9ブレイクアウトボードの再設計
10サーマルカム基板の再設計
11仙台のメーカーフェアの申し込みのもしなくては…

優先順位を決めて進めますが時間が足りない…

そもそもの基本技術の習得の時間が取れないとこれ以上のグレードアップは出来ない。それが一番重要な問題。open CV, C, C++,python, Yolo以外のAIフレームワーク、微分可能レンダラー、線形代数、微分積分の復習もクオータニオンもじっくり勉強しないと今までの様にコピペでは誤魔化せない様になっています。

2019年11月9日土曜日

Thermal Cam3xについて

初めは単に赤外線の映像をワイアレスでiPhoneに映し出して録画する機能でした。
それだけでも大変でした。過去3年はひたすらチューニングでより安定する様に改良を続けてきました。
小野さんがディープラーニングとプログラムの広い見識と経験があったので少しずつこのサーマルカム(IoT)とAIを融合して来ました。
またハードウエアは日々進化して色々な機器を試して精査して現在は安定して業務に使うにはNVIDIAのJetsonを使いそれらの機能をiPhone11で実現できる様になりました。
これは今の技術と今までの長い経験で実現出来ました。
大学でも産総研で専門家が見ても誰が見ても凄いと凄いものになりました。ただその過程は可なり専門的なプロセスが必要です。簡単にコピーも作業も一連の作業を書き出しても出来ません。出来ます?じゃーどうぞここみて作ってください。
https://takesan.hatenablog.jp
英訳も終わりました。
これからFLIRのコンテストに応募します。

Mobile Thermal App Challenge

まさにFLIR製品を使ったアプリのコンテスト(iOSもしくはANDROIDs)
今完成したアプリはサーモグラフィーを使った画像認識を組み合わせたものとしては世界初です。AIの専門家からしたらアプリに後から学習モデルを追加できる事は可なり画期的です。
でもこのコンテストには選ばれる事はない事が分かりました。FLIR DEVELOPPER SDKを使う事がこのコンテストの必須条件です。今回のアプリはそれを使う事が出来ません。
なぜかというとFLIRのスマホと連携する製品と一緒に使う為の開発キットです。
スクラッチで一からFLIR LeptonやBOSONと連携して深層学習まで取り入れるには役不足です。
優勝しても5000ドルです。ただ今回はそれでも応募します。
何故かってコンテストの審査員がFLIRのソフト、ハード、マーケティングの役員だからです。直接個々の役員にプレゼンする機会はそうそうありません。
資料と動画はだいたい終わりました。12月までに提出予定です。
大阪商工会議所のAIアイデアコンテストも11月29日までに提出です。
このアプリ自体のアップルへの申請があります。

上手く行けば来年は世界が変わるかも。誰の?

2019年11月4日月曜日

ブレイクアウトボードまた失敗。。。

徐々に複雑な基板製作になって来ました。一見コピーですが全ての相当部品がわかる訳ではないので自分で探した部品とオリジナル部品の違いが致命的になります。
1回目はフットプリントを野良のデータを使ったのでフットプリントの間違えで向きが違って4万円近くがゴミになりました。真ん中のソケットは殆ど使われていないのでデータを一から作る事は専門家か専用ソフトを上手く使わないと難しい。

1回目(ソケットのフットプリントの間違え。野良のデータです恨みようがない。)

2回目はもっと複雑な問題。



入力のショットキーダイオードの電圧降下も問題もありましたが、そこを短絡して各部の電圧を測っても仕様書通りただ発振器がどうも問題。
手元にあるオシロスコープは20MHz迄なので今回の発振器は25MHzで測りようがない。。。
というより発振していない様子。

オリジナルと同じ配線にしたもののそもそも部品が違う?
クロックを作るといっても発信機は物凄い種類があります。

同じ様な部品を同じ回路で作りましたが、ここからが大変。発振をさせるには浮遊容量の計算と負荷抵抗をつけないといけないそうです。
これをつけたら発振する?不安で色々調べて嵌っています。
村田製作所やエプソンのページを調べると回路に合わせて余裕度を調べないといけません。
FLIR LEPTONの内部インピーダンスを求める事は不可能。

でもオリジナルの回路を見るとそれほど難しい回路ではない感じ。
で探すとそれらしい発振器を見つけました。

部品の多くは参考回路がありますが今回の発振器はそれが無く今回調べると計算して算出するタイプみたいです。
で今回発見した発振器は参考回路がありオリジナルの回路に近い感じです。でフットプリントを探していますが無さそう。。。
今回電圧が適正なのでこの発振器で25MHzを26番ピンに送ってセンサーを動かさないと先に進みませんが表面実装は手で半田出来ない。オーブンも用意すればやってやれない事はないですが、どちらにしてもギャンブルです。少なくとも私にとっては。
まだまだ調べないといけません。これで動くかの保証もないしこの為に25MHzのオシロスコープ買う訳にも行きません。
さあ困った。。。
とりあえず発振器だけ手で半田するか。。。

追伸:

DS1054Z  という50MHzオシロスコープを4万円購入。ゴニョゴニョして 100MHzの DS1104Zに変身。




最初の発振子はそもそも動いていない感じ





その後の発振子は発振はしているが電圧が低い=つまり発振していない?

2019年11月2日土曜日

操作ミスでUbuntu再インストール10月28日〜11月1日まで。。。

update 2022/8/24
wiwao@wiwao-desktop:~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89
wiwao@wiwao-desktop:~$ nvidia-smi
Fri Aug 26 08:42:52 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.33.01    Driver Version: 440.33.01    CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    On   | 00000000:01:00.0  On |                  N/A |
| 33%   35C    P8     9W / 200W |    272MiB /  8116MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0       976      G   /usr/lib/xorg/Xorg                            18MiB |
|    0      1043      G   /usr/bin/gnome-shell                          48MiB |
|    0      1933      G   /usr/lib/xorg/Xorg                            92MiB |
|    0      2067      G   /usr/bin/gnome-shell                          69MiB |
|    0      2526      G   ...691254562925,6318647564568795765,131072    39MiB |
+-----------------------------------------------------------------------------+
wiwao@wiwao-desktop:~$ cat /usr/local/cuda/version.txt
CUDA Version 10.2.89
wiwao@wiwao-desktop:~$  /usr/local/cuda/bin/nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89
wiwao@wiwao-desktop:~$ sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb
[sudo] password for wiwao: 
Selecting previously unselected package libcudnn7.
(Reading database ... 201176 files and directories currently installed.)
Preparing to unpack libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb ...
Unpacking libcudnn7 (7.6.5.32-1+cuda10.2) ...
Setting up libcudnn7 (7.6.5.32-1+cuda10.2) ...
Processing triggers for libc-bin (2.27-3ubuntu1.6) ...
wiwao@wiwao-desktop:~$ sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.2_amd64.deb
Selecting previously unselected package libcudnn7-dev.
(Reading database ... 201182 files and directories currently installed.)
Preparing to unpack libcudnn7-dev_7.6.5.32-1+cuda10.2_amd64.deb ...
Unpacking libcudnn7-dev (7.6.5.32-1+cuda10.2) ...
Setting up libcudnn7-dev (7.6.5.32-1+cuda10.2) ...
update-alternatives: using /usr/include/x86_64-linux-gnu/cudnn_v7.h to provide /usr/include/cudnn.h (libcudnn) in auto mode
wiwao@wiwao-desktop:~$ sudo dpkg -i libcudnn7-doc_7.6.5.32-1+cuda10.2_amd64.deb
Selecting previously unselected package libcudnn7-doc.
(Reading database ... 201188 files and directories currently installed.)
Preparing to unpack libcudnn7-doc_7.6.5.32-1+cuda10.2_amd64.deb ...
Unpacking libcudnn7-doc (7.6.5.32-1+cuda10.2) ...
Setting up libcudnn7-doc (7.6.5.32-1+cuda10.2) ...
wiwao@wiwao-desktop:~$ cp -r /usr/src/cudnn_samples_v7/ $HOME
wiwao@wiwao-desktop:~$ cd $HOME/cudnn_samples_v7/mnistCUDNN
wiwao@wiwao-desktop:~/cudnn_samples_v7/mnistCUDNN$ make clean && make
rm -rf *o
rm -rf mnistCUDNN
Linking agains cublasLt = true
CUDA VERSION: 10020
TARGET ARCH: x86_64
HOST_ARCH: x86_64
TARGET OS: linux
SMS: 30 35 50 53 60 61 62 70 72 75
/usr/local/cuda/bin/nvcc -ccbin g++ -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include  -m64    -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_62,code=sm_62 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_72,code=sm_72 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o fp16_dev.o -c fp16_dev.cu
g++ -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include   -o fp16_emu.o -c fp16_emu.cpp
g++ -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include   -o mnistCUDNN.o -c mnistCUDNN.cpp
/usr/local/cuda/bin/nvcc -ccbin g++   -m64      -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_62,code=sm_62 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_72,code=sm_72 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o mnistCUDNN fp16_dev.o fp16_emu.o mnistCUDNN.o -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include  -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib64 -lcublasLt -LFreeImage/lib/linux/x86_64 -LFreeImage/lib/linux -lcudart -lcublas -lcudnn -lfreeimage -lstdc++ -lm
wiwao@wiwao-desktop:~/cudnn_samples_v7/mnistCUDNN$ ./mnistCUDNN
cudnnGetVersion() : 7605 , CUDNN_VERSION from cudnn.h : 7605 (7.6.5)
Host compiler version : GCC 7.5.0
There are 1 CUDA capable devices on your machine :
device 0 : sms 20  Capabilities 6.1, SmClock 1771.5 Mhz, MemSize (Mb) 8116, MemClock 5005.0 Mhz, Ecc=0, boardGroupID=0
Using device 0

Testing single precision
Loading image data/one_28x28.pgm
Performing forward propagation ...
Testing cudnnGetConvolutionForwardAlgorithm ...
Fastest algorithm is Algo 1
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.017344 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.030688 time requiring 3464 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.035840 time requiring 57600 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.048704 time requiring 203008 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.063488 time requiring 207360 memory
Resulting weights from Softmax:
0.0000000 0.9999399 0.0000000 0.0000000 0.0000561 0.0000000 0.0000012 0.0000017 0.0000010 0.0000000 
Loading image data/three_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000000 0.0000000 0.9999288 0.0000000 0.0000711 0.0000000 0.0000000 0.0000000 0.0000000 
Loading image data/five_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000008 0.0000000 0.0000002 0.0000000 0.9999820 0.0000154 0.0000000 0.0000012 0.0000006 

Result of classification: 1 3 5

Test passed!

Testing half precision (math in single precision)
Loading image data/one_28x28.pgm
Performing forward propagation ...
Testing cudnnGetConvolutionForwardAlgorithm ...
Fastest algorithm is Algo 1
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.016352 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.024576 time requiring 3464 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.029696 time requiring 28800 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.045760 time requiring 203008 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.060416 time requiring 207360 memory
Resulting weights from Softmax:
0.0000001 1.0000000 0.0000001 0.0000000 0.0000563 0.0000001 0.0000012 0.0000017 0.0000010 0.0000001 
Loading image data/three_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000714 0.0000000 0.0000000 0.0000000 0.0000000 
Loading image data/five_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000008 0.0000000 0.0000002 0.0000000 1.0000000 0.0000154 0.0000000 0.0000012 0.0000006 

Result of classification: 1 3 5

Test passed!
wiwao@wiwao-desktop:~/cudnn_samples_v7/mnistCUDNN$ 


Yolo学習中に誤って電源を落としてしまったので、GPUのドライバーが壊れてしまったみたい。
いろいろ修正しましたが肝心の学習のコマンドエラーなのでアノテーションデータとその他のデータをコピーしてUbuntu再インストール。
Ubuntu16.04 LTSのイメージをUSBメモリーにコピーしてファイルを初期化して再インストールをしましたが去年の作業が忘却の彼方。。。それ程難しい操作ではなかった筈が何度もエラー。
OSイメージの書込が上手く行かず、起動ディスクの設定で間違えて半日潰れてしまいました。

次のこともあるのでメモします。
Ubuntu16.04 LTSのイメージは日本語版ではなく英語版の最新をUSBにISOファイルで保存。BOISメニューで起動をUSBメモリーに変更して起動してインストールの再に日本語の設定(メニュー画面が日本語になるとディレクトリ名の日本語になるので英語でインストールしてロケールで日本語に変えること。次のインストールの際に気をつける。)ファイル名が日本語だとターミナル画面で日本語入力出来ない等の不都合が致命的。

その後各種設定、GPUのドライバーCUDA、cuDNNのインストールとOpenCVのインストールまで数日掛かりそう。
あっ、SSHのインストールしないとドライバーインストール失敗すると画面が真っ黒になって表示出来ないのでsudo apt-get install sshは最初に必要。
wiwao@wiwao-desktop:~$ sudo apt-get install ssh
[sudo] password for wiwao:
Reading package lists... Done
Building dependency tree     
Reading state information... Done
ssh is already the newest version (1:7.2p2-4ubuntu2.8).
The following package was automatically installed and is no longer required:
  snapd-login-service
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
reboot
他の端末からsshの接続確認。
再インストール時のSSHのおまじない。
Last login: Thu Oct 31 09:27:41 on ttys000
wiwaoMacBookAir:~ wiwao$ ssh wiwao@192.168.0.235
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:9KN5NXNFZqeRERb1uTIbuZhwaDWAz3sSWUwmU+8IZdU.
Please contact your system administrator.
Add correct host key in /Users/wiwao/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/wiwao/.ssh/known_hosts:5
ECDSA host key for 192.168.0.235 has changed and you have requested strict checking.
Host key verification failed.
wiwaoMacBookAir:~ wiwao$ ssh-keygen -R 192.168.0.235
# Host 192.168.0.235 found: line 5
/Users/wiwao/.ssh/known_hosts updated.
Original contents retained as /Users/wiwao/.ssh/known_hosts.old
wiwaoMacBookAir:~ wiwao$ ssh wiwao@192.168.0.235
The authenticity of host '192.168.0.235 (192.168.0.235)' can't be established.
ECDSA key fingerprint is SHA256:9KN5NXNFZqeRERb1uTIbuZhwaDWAz3sSWUwmU+8IZdU.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.235' (ECDSA) to the list of known hosts.
wiwao@192.168.0.235's password: 
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 5.0.0-32-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

185 packages can be updated.
99 updates are security updates.

Your Hardware Enablement Stack (HWE) is supported until April 2023.
Last login: Thu Oct 31 09:32:45 2019 from fe80::46c:7ef9:d09a:c93f%enp0s31f6

wiwao@wiwao-desktop:~$ 
次GPUドライバーのインストール。

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-367
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev
reboot
で再起動
で$ nvidia-smi
wiwao@wiwao-desktop:~$ nvidia-smi
Wed Oct 30 11:16:50 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.130                Driver Version: 384.130                   |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    Off  | 00000000:01:00.0  On |                  N/A |
| 33%   46C    P0    40W / 200W |    181MiB /  8110MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1200      G   /usr/lib/xorg/Xorg                           138MiB |
|    0      2029      G   compiz                                        40MiB |

+-----------------------------------------------------------------------------+

これを最初に実行することで、画面解像度やloginできなくなった時、後から簡単に元に戻すことが可能(設定->ソフトウェアとアップグレード->追加のドライバーを開けると確認できます。別の端末からssh接続してsudo apt-get install nvidia-367 --reinstallを実行するだけ

sudo apt-get --purge remove nvidia-*
sudo dpkg -i cuda-repo-ubuntu1604-8-0-rc_8.0.27-1_amd64.deb 
sudo apt-get update
sudo apt-get install cuda
sudo apt-get remove --purge -y cuda-repo-ubuntu1604-8-0-rc
sudo dpkg -i cuda-misc-headers-8-0_8.0.27.1-1_amd64.deb
sudo cp cuda/lib64/* /usr/local/cuda/lib64/
sudo cp cuda/include/* /usr/local/cuda/include/
sudo apt-get install nvidia-370 --reinstall
sudo apt-get --purge remove nvidia-*
sudo dpkg -i cuda-repo-ubuntu1604_9.2.148-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

ここまでで良かったのですが、最新のシステムで問題無いとのことでUbuntu18にして再スタート。Ubuntu16のサポートはもうすぐ終わる為この際、最新にする。(ここから嵌る。)

wiwao@wiwao-desktop:~$ nvidia-smi
Wed Oct 30 15:33:39 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.129                Driver Version: 390.129                   |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    Off  | 00000000:01:00.0  On |                  N/A |
| 35%   45C    P8     7W / 200W |    226MiB /  8116MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1244      G   /usr/lib/xorg/Xorg                            18MiB |
|    0      1294      G   /usr/bin/gnome-shell                          49MiB |
|    0      1562      G   /usr/lib/xorg/Xorg                            86MiB |
|    0      1691      G   /usr/bin/gnome-shell                          69MiB |
+-----------------------------------------------------------------------------+
wiwao@wiwao-desktop:~$ 


ここから再スタート
cuda インストールですが、最新版がCUDA Toolkit 10.1 Update 2 Download
でdeb(network)はまたこのエラーが続く。
wiwao@wiwao-desktop:~$ sudo apt-get -y install cuda
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 cuda : Depends: cuda-10-1 (>= 10.1.243) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
wiwao@wiwao-desktop:~$ 
なのでdeb(local)で再度やり直し。
同じエラー
  1. Install aptitude
    sudo apt-get install aptitude
    
  2. Install main package
    sudo aptitude install cuda
cuda 10.1をインストール中
インストール出来た様なので
cd
 で最後に以下を追加書き込み。(時々小野さんスペル間違えて、抜き打ちテストする。。。)


export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}

export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

export LD_LIBRARY_PATH=/usr/local/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

export CUDA_HOME=/usr/local/cuda

reboot

でテスト
smokeParticles
sudo make -j8でコンパイル
これで./smokeParticles
OK

wiwao@wiwao-desktop:/usr/local/cuda-10.1/samples/5_Simulations/particles$ ./particles
CUDA Particles Simulation Starting...

NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.


grid: 64 x 64 x 64 = 262144 cells

particles: 16384
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  33
  Current serial number in output stream:  34


あまり急にトントンとインストールしてエラーが出ました。再起動で動くようになりました。フー。。。。

次にcuDNN
wiwao@wiwao-desktop:~$ ll
total 2156816
drwxr-xr-x 19 wiwao wiwao       4096 10月 31 12:07 ./
drwxr-xr-x  3 root  root        4096 10月 31 09:06 ../
-rw-------  1 wiwao wiwao       1972 10月 31 12:21 .bash_history
-rw-r--r--  1 wiwao wiwao        220 10月 31 09:06 .bash_logout
-rw-r--r--  1 wiwao wiwao       4028 10月 31 11:24 .bashrc
drwx------ 14 wiwao wiwao       4096 10月 31 12:07 .cache/
drwx------ 16 wiwao wiwao       4096 10月 31 12:19 .config/
-rw-rw-r--  1 wiwao wiwao       2936 10月 31 10:40 cuda-repo-ubuntu1804_10.1.105-1_amd64.deb
-rw-rw-r--  1 wiwao wiwao       2936 10月 31 10:37 cuda-repo-ubuntu1804_10.1.168-1_amd64.deb
-rw-r--r--  1 wiwao wiwao 1859785444  8月 10 06:17 cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb
drwxr-xr-x  2 wiwao wiwao       4096 10月 31 12:20 Desktop/
drwxr-xr-x  2 wiwao wiwao       4096 10月 31 09:19 Documents/
drwxr-xr-x  2 wiwao wiwao       4096 10月 31 12:07 Downloads/
-rw-r--r--  1 wiwao wiwao       8980 10月 31 09:06 examples.desktop
drwx------  3 wiwao wiwao       4096 10月 31 10:11 .gnome/
drwx------  3 wiwao wiwao       4096 10月 31 10:32 .gnupg/
-rw-------  1 wiwao wiwao       2076 10月 31 11:26 .ICEauthority
-rw-rw-r--  1 wiwao wiwao  182349464 10月 31 12:06 libcudnn7_7.6.4.38-1+cuda10.1_amd64.deb
-rw-rw-r--  1 wiwao wiwao  160754004 10月 31 12:07 libcudnn7-dev_7.6.4.38-1+cuda10.1_amd64.deb
-rw-rw-r--  1 wiwao wiwao    5553740 10月 31 12:07 libcudnn7-doc_7.6.4.38-1+cuda10.1_amd64.deb
drwx------  3 wiwao wiwao       4096 10月 31 09:16 .local/
drwx------  2 wiwao wiwao       4096 10月 31 11:29 .mozc/
drwxr-xr-x  2 wiwao wiwao       4096 10月 31 09:19 Music/
drwx------  4 wiwao wiwao       4096 10月 31 11:35 .nv/
-rw-r--r--  1 wiwao wiwao        351 10月 31 09:17 .pam_environment
drwxr-xr-x  2 wiwao wiwao       4096 10月 31 09:19 Pictures/
drwx------  3 wiwao wiwao       4096 10月 31 10:11 .pki/
-rw-r--r--  1 wiwao wiwao        807 10月 31 09:06 .profile
drwxr-xr-x  2 wiwao wiwao       4096 10月 31 09:19 Public/
drwx------  2 wiwao wiwao       4096 10月 31 09:58 .ssh/
-rw-r--r--  1 wiwao wiwao          0 10月 31 09:20 .sudo_as_admin_successful
drwxr-xr-x  2 wiwao wiwao       4096 10月 31 09:19 Templates/
drwxr-xr-x  2 wiwao wiwao       4096 10月 31 09:19 Videos/
-rw-rw-r--  1 wiwao wiwao        131 10月 31 09:17 .xinputrc
wiwao@wiwao-desktop:~$ sudo dpkg -i libcudnn7_7.6.4.38-1+cuda10.1_amd64.deb
Selecting previously unselected package libcudnn7.
(Reading database ... 189331 files and directories currently installed.)
Preparing to unpack libcudnn7_7.6.4.38-1+cuda10.1_amd64.deb ...
Unpacking libcudnn7 (7.6.4.38-1+cuda10.1) ...
Setting up libcudnn7 (7.6.4.38-1+cuda10.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
wiwao@wiwao-desktop:~$ sudo dpkg -i libcudnn7-dev_7.6.4.38–1+cuda10.1_amd64.deb
dpkg: error: cannot access archive 'libcudnn7-dev_7.6.4.38–1+cuda10.1_amd64.deb': No such file or directory
wiwao@wiwao-desktop:~$ sudo dpkg -i libcudnn7-dev_7.6.4.38-1+cuda10.1_amd64.deb
Selecting previously unselected package libcudnn7-dev.
(Reading database ... 189337 files and directories currently installed.)
Preparing to unpack libcudnn7-dev_7.6.4.38-1+cuda10.1_amd64.deb ...
Unpacking libcudnn7-dev (7.6.4.38-1+cuda10.1) ...
Setting up libcudnn7-dev (7.6.4.38-1+cuda10.1) ...
update-alternatives: using /usr/include/x86_64-linux-gnu/cudnn_v7.h to provide /usr/include/cudnn.h (libcudnn) in auto mode
wiwao@wiwao-desktop:~$ sudo dpkg -i libcudnn7-doc_7.6.4.38-1+cuda10.1_amd64.deb
Selecting previously unselected package libcudnn7-doc.
(Reading database ... 189343 files and directories currently installed.)
Preparing to unpack libcudnn7-doc_7.6.4.38-1+cuda10.1_amd64.deb ...
Unpacking libcudnn7-doc (7.6.4.38-1+cuda10.1) ...
Setting up libcudnn7-doc (7.6.4.38-1+cuda10.1) ...
wiwao@wiwao-desktop:~$ cp -r /usr/src/cudnn_samples_v7/ $HOME
wiwao@wiwao-desktop:~$ cd $HOME/cudnn_samples_v7/mnistCUDNN
wiwao@wiwao-desktop:~/cudnn_samples_v7/mnistCUDNN$ make clean && make
rm -rf *o
rm -rf mnistCUDNN
Linking agains cublasLt = true
CUDA VERSION: 10010
TARGET ARCH: x86_64
HOST_ARCH: x86_64
TARGET OS: linux
SMS: 30 35 50 53 60 61 62 70 72 75
/usr/local/cuda/bin/nvcc -ccbin g++ -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include  -m64    -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_62,code=sm_62 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_72,code=sm_72 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o fp16_dev.o -c fp16_dev.cu
g++ -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include   -o fp16_emu.o -c fp16_emu.cpp
g++ -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include   -o mnistCUDNN.o -c mnistCUDNN.cpp
/usr/local/cuda/bin/nvcc -ccbin g++   -m64      -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_62,code=sm_62 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_72,code=sm_72 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o mnistCUDNN fp16_dev.o fp16_emu.o mnistCUDNN.o -I/usr/local/cuda/include -I/usr/local/cuda/include -IFreeImage/include  -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib64 -lcublasLt -LFreeImage/lib/linux/x86_64 -LFreeImage/lib/linux -lcudart -lcublas -lcudnn -lfreeimage -lstdc++ -lm
wiwao@wiwao-desktop:~/cudnn_samples_v7/mnistCUDNN$ ./mnistCUDNN
cudnnGetVersion() : 7604 , CUDNN_VERSION from cudnn.h : 7604 (7.6.4)
Host compiler version : GCC 7.4.0
There are 1 CUDA capable devices on your machine :
device 0 : sms 20  Capabilities 6.1, SmClock 1771.5 Mhz, MemSize (Mb) 8116, MemClock 5005.0 Mhz, Ecc=0, boardGroupID=0
Using device 0

Testing single precision
Loading image data/one_28x28.pgm
Performing forward propagation ...
Testing cudnnGetConvolutionForwardAlgorithm ...
Fastest algorithm is Algo 1
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.023456 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.039680 time requiring 3464 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.046720 time requiring 57600 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.071680 time requiring 203008 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.075776 time requiring 2057744 memory
Resulting weights from Softmax:
0.0000000 0.9999399 0.0000000 0.0000000 0.0000561 0.0000000 0.0000012 0.0000017 0.0000010 0.0000000 
Loading image data/three_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000000 0.0000000 0.9999288 0.0000000 0.0000711 0.0000000 0.0000000 0.0000000 0.0000000 
Loading image data/five_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000008 0.0000000 0.0000002 0.0000000 0.9999820 0.0000154 0.0000000 0.0000012 0.0000006 

Result of classification: 1 3 5

Test passed!

Testing half precision (math in single precision)
Loading image data/one_28x28.pgm
Performing forward propagation ...
Testing cudnnGetConvolutionForwardAlgorithm ...
Fastest algorithm is Algo 1
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.023360 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.038880 time requiring 3464 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.047808 time requiring 28800 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.075392 time requiring 203008 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.075680 time requiring 2057744 memory
Resulting weights from Softmax:
0.0000001 1.0000000 0.0000001 0.0000000 0.0000563 0.0000001 0.0000012 0.0000017 0.0000010 0.0000001 
Loading image data/three_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000714 0.0000000 0.0000000 0.0000000 0.0000000 
Loading image data/five_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000008 0.0000000 0.0000002 0.0000000 1.0000000 0.0000154 0.0000000 0.0000012 0.0000006 

Result of classification: 1 3 5

Test passed!

wiwao@wiwao-desktop:~/cudnn_samples_v7/mnistCUDNN$

で成功

次にOpenCV下記を一括入力
sudo apt install gcc-6 g++-6 cmake build-essential git pkg-config ccache \
unzip ecm extra-cmake-modules fcitx-libs-dev libfcitx-qt5-1 \
mesa-utils libgtk2.0-dev libgtk-3-dev ffmpeg \
libavcodec-dev libavformat-dev libswscale-dev \
libjpeg-dev libpng-dev libtiff5-dev x264 libxvidcore-dev yasm \
libxine2-dev libv4l-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev \
libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev \
x264 v4l-utils ffmpeg libdc1394-22 libdc1394-22-dev libtiff5-dev \
qt5-default libeigen3-dev libeigen3-doc tesseract-ocr tesseract-ocr-jpn \
vtk6 tcl-vtk6 python-vtk6 libgflags-dev autoconf automake libtool \
autoconf-archive libleptonica-dev libtesseract-dev gphoto2 liblapacke-dev \
libgoogle-glog-dev libprotobuf-dev libprotoc-dev protobuf-compiler \
libgphoto2-dev libvtk6-dev libvtk6-qt-dev liblapack-dev libatlas-base-dev



git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd opencv
mkdir build
cd build


ビルド準備でこちらのcMakeをする。
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D ENABLE_FAST_MATH=ON \
-D CUDA_FAST_MATH=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_opencv_python3=ON \
-D WITH_CUBLAS=1 \
-D BUILD_EXAMPLES=ON ..
何故か-D WITH_CUDA=ON \
を外すと出来た。
--     Linker flags (Release):      -Wl,--gc-sections  
--     Linker flags (Debug):        -Wl,--gc-sections  
--     ccache:                      YES
--     Precompiled headers:         NO
--     Extra dependencies:          dl m pthread rt
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot quality reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab viz xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv java js matlab ovis python2 python3
--     Applications:                tests perf_tests examples apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI: 
--     GTK+:                        YES (ver 3.22.30)
--       GThread :                  YES (ver 2.56.4)
--       GtkGlExt:                  NO
--     VTK support:                 YES (ver 6.3.0)
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
--     WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x020e)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.34)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 2.3.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      YES (2.2.5)
--     FFMPEG:                      YES
--       avcodec:                   YES (57.107.100)
--       avformat:                  YES (57.83.100)
--       avutil:                    YES (55.78.100)
--       swscale:                   YES (4.8.100)
--       avresample:                NO
--     GStreamer:                   NO
--     v4l/v4l2:                    YES (linux/videodev2.h)
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Intel IPP:                   2019.0.0 Gold [2019.0.0]
--            at:                   /home/wiwao/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
--     Intel IPP IW:                sources (2019.0.0)
--               at:                /home/wiwao/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
--     Lapack:                      YES (/usr/lib/x86_64-linux-gnu/liblapack.so /usr/lib/x86_64-linux-gnu/libcblas.so /usr/lib/x86_64-linux-gnu/libatlas.so)
--     Eigen:                       YES (ver 3.3.4)
--     Custom HAL:                  NO
--     Protobuf:                    build (3.5.1)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/wiwao/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.6.8)
--     Libraries:                   NO
--     numpy:                       NO (Python3 wrappers can not be generated)
--     install path:                -
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:                          
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wiwao/opencv/build

-- General configuration for OpenCV 3.4.0 =====================================
--   Version control:               unknown
-- 
--   Extra modules:
--     Location (extra):            /home/wiwao/src/opencv_contrib/modules
--     Version control (extra):     unknown
-- 
--   Platform:
--     Timestamp:                   2019-11-05T07:24:27Z
--     Host:                        Linux 5.0.0-32-generic x86_64
--     CMake:                       3.10.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
-- 
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2
--       SSE4_1 (3 files):          + SSSE3 SSE4_1
--       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (2 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (9 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++11:                       YES
--     C++ Compiler:                /usr/bin/c++  (ver 7.4.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):
--     Linker flags (Debug):
--     ccache:                      YES
--     Precompiled headers:         NO
--     Extra dependencies:          dl m pthread rt cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda-10.1/lib64 -L/usr/lib/x86_64-linux-gnu
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dpm face features2d flann freetype fuzzy hdf highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python_bindings_generator reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab viz xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    js world
--     Disabled by dependency:      -
--     Unavailable:                 cnn_3dobj cvv dnn_modern java matlab ovis python2 python3
--     Applications:                tests perf_tests examples apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI: 
--     GTK+:                        YES (ver 3.22.30)
--       GThread :                  YES (ver 2.56.4)
--       GtkGlExt:                  NO
--     VTK support:                 YES (ver 6.3.0)
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
--     WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x020e)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.34)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
-- 
--   Video I/O:
--     DC1394:                      YES (ver 2.2.5)
--     FFMPEG:                      YES
--       avcodec:                   YES (ver 57.107.100)
--       avformat:                  YES (ver 57.83.100)
--       avutil:                    YES (ver 55.78.100)
--       swscale:                   YES (ver 4.8.100)
--       avresample:                NO
--     GStreamer:                   NO
--     libv4l/libv4l2:              NO
--     v4l/v4l2:                    linux/videodev2.h
--     gPhoto2:                     YES
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Intel IPP:                   2017.0.3 [2017.0.3]
--            at:                   /home/wiwao/src/opencv/build/3rdparty/ippicv/ippicv_lnx
--     Intel IPP IW:                sources (2017.0.3)
--               at:                /home/wiwao/src/opencv/build/3rdparty/ippicv/ippiw_lnx
--     Lapack:                      YES (/usr/lib/x86_64-linux-gnu/liblapack.so /usr/lib/x86_64-linux-gnu/libcblas.so /usr/lib/x86_64-linux-gnu/libatlas.so)
--     Eigen:                       YES (ver 3.3.4)
--     Custom HAL:                  NO
-- 
--   NVIDIA CUDA:                   YES (ver 10.1, CUFFT CUBLAS NVCUVID FAST_MATH)
--     NVIDIA GPU arch:             30 35 37 50 52 60 61 70
--     NVIDIA PTX archs:
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/wiwao/src/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.6.8)
--     Libraries:                   NO
--     numpy:                       NO (Python3 wrappers can not be generated)
--     packages path:               lib/python3.6/dist-packages
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Matlab:                        NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wiwao/src/opencv/build

結論はdarknetコンパイル時にopenCVが理由でエラー

ここからエラーが頻発するので調べるとopencv3.4.0ならdarknetが動くと言う記事があったので一から入れ直し
https://hatobus.hatenablog.jp/entry/2018/07/05/104114



sudo apt install cmake
$ wget https://github.com/opencv/opencv/archive/3.4.0.tar.gz
$ tar xvzf 3.4.0.tar.gz 
$ ln -s opencv-3.4.0 opencv
$ wget https://github.com/opencv/opencv_contrib/archive/3.4.0.tar.gz
$ mv 3.4.0.tar.gz.1 opencv_contrib-3.4.0.tar.gz
$ tar xvzf opencv_contrib-3.4.0.tar.gz 
$ ln -s opencv_contrib-3.4.0 opencv_contrib
$ cd opencv
$ mkdir build
$ cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D BUILD_opencv_cudacodec=OFF \
-D ENABLE_FAST_MATH=ON \
-D CUDA_FAST_MATH=ON \
-D WITH_CUBLAS=1 \
-D WITH_CUDA=ON ..
でmake -j16それから

sudo make install

sudo ldconfig

python
import cv2すど

cv2.cuda.getCudaEnabledDeviceCount()
でエラー。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

もし失敗してたら
cd ~/opencv/
rm -rf build

でbuildフォルダを消してからCmakeからやり直してください。
だって。。。

でも設定はこの通りでdarknetは通りました。


-- Found installed version of gflags: /usr/lib/x86_64-linux-gnu/cmake/gflags
-- Detected gflags version: 2.2.1
-- Checking SFM deps... TRUE
-- CERES support is disabled. Ceres Solver for reconstruction API is required.
--
-- General configuration for OpenCV 3.4.0 =====================================
--   Version control:               unknown
--
--   Extra modules:
--     Location (extra):            /home/wiwao/opencv_contrib/modules
--     Version control (extra):     unknown
--
--   Platform:
--     Timestamp:                   2019-11-11T06:42:17Z
--     Host:                        Linux 5.0.0-32-generic x86_64
--     CMake:                       3.10.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
--
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2
--       SSE4_1 (3 files):          + SSSE3 SSE4_1
--       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (2 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (9 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++11:                       YES
--     C++ Compiler:                /usr/bin/c++  (ver 7.4.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):
--     Linker flags (Debug):
--     ccache:                      YES
--     Precompiled headers:         NO
--     Extra dependencies:          dl m pthread rt cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda-10.1/lib64 -L/usr/lib/x86_64-linux-gnu
--     3rdparty dependencies:
--
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dpm face features2d flann freetype fuzzy hdf highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python_bindings_generator reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab viz xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    cudacodec js world
--     Disabled by dependency:      -
--     Unavailable:                 cnn_3dobj cvv dnn_modern java matlab ovis python2 python3
--     Applications:                tests perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         NO
--
--   GUI:
--     GTK+:                        YES (ver 3.22.30)
--       GThread :                  YES (ver 2.56.4)
--       GtkGlExt:                  NO
--     VTK support:                 YES (ver 6.3.0)
--
--   Media I/O:
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
--     WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x020e)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.34)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--
--   Video I/O:
--     DC1394:                      YES (ver 2.2.5)
--     FFMPEG:                      YES
--       avcodec:                   YES (ver 57.107.100)
--       avformat:                  YES (ver 57.83.100)
--       avutil:                    YES (ver 55.78.100)
--       swscale:                   YES (ver 4.8.100)
--       avresample:                NO
--     GStreamer:                   NO
--     libv4l/libv4l2:              NO
--     v4l/v4l2:                    linux/videodev2.h
--     gPhoto2:                     YES
--
--   Parallel framework:            pthreads
--
--   Trace:                         YES (with Intel ITT)
--
--   Other third-party libraries:
--     Intel IPP:                   2017.0.3 [2017.0.3]
--            at:                   /home/wiwao/opencv/build/3rdparty/ippicv/ippicv_lnx
--     Intel IPP IW:                sources (2017.0.3)
--               at:                /home/wiwao/opencv/build/3rdparty/ippicv/ippiw_lnx
--     Lapack:                      YES (/usr/lib/x86_64-linux-gnu/liblapack.so /usr/lib/x86_64-linux-gnu/libcblas.so /usr/lib/x86_64-linux-gnu/libatlas.so)
--     Eigen:                       YES (ver 3.3.4)
--     Custom HAL:                  NO
--
--   NVIDIA CUDA:                   YES (ver 10.1, CUFFT CUBLAS NVCUVID FAST_MATH)
--     NVIDIA GPU arch:             30 35 37 50 52 60 61 70
--     NVIDIA PTX archs:
--
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/wiwao/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
--
--   Python (for build):            /usr/bin/python2.7
--
--   Java:
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
--
--   Matlab:                        NO
--
--   Install to:                    /usr/local
-- -----------------------------------------------------------------

パイソンのエラーは出ますがdarknetが下記makefileで
エラーがない。
GPU=1
CUDNN=1
CUDNN_HALF=0
OPENCV=1
AVX=0
OPENMP=0
LIBSO=0
ZED_CAMERA=0

# set GPU=1 and CUDNN=1 to speedup on GPU
# set CUDNN_HALF=1 to further speedup 3 x times (Mixed-precision on Tensor Cores) GPU: Volta, Xavier, Turing and higher
# set AVX=1 and OPENMP=1 to speedup on CPU (if error occurs then set AVX=0)

DEBUG=0

ARCH= -gencode arch=compute_30,code=sm_30 \
      -gencode arch=compute_35,code=sm_35 \
      -gencode arch=compute_50,code=[sm_50,compute_50] \
      -gencode arch=compute_52,code=[sm_52,compute_52] \
 -gencode arch=compute_61,code=[sm_61,compute_61]

OS := $(shell uname)

# Tesla V100
# ARCH= -gencode arch=compute_70,code=[sm_70,compute_70]

# GeForce RTX 2080 Ti, RTX 2080, RTX 2070, Quadro RTX 8000, Quadro RTX 6000, Quadro RTX 5000, Tesla T4, XNOR Tensor Cores
# ARCH= -gencode arch=compute_75,code=[sm_75,compute_75]

# Jetson XAVIER
# ARCH= -gencode arch=compute_72,code=[sm_72,compute_72]

# GTX 1080, GTX 1070, GTX 1060, GTX 1050, GTX 1030, Titan Xp, Tesla P40, Tesla P4
 ARCH= -gencode arch=compute_61,code=sm_61 -gencode arch=compute_61,code=compute_61



2020/02/21
revised


  • Home
  • High Performance Computing
  • CUDA Toolkit
  • CUDA Toolkit 10.2 Download


  • darknetの設定の記録が無くなっていたので補足。

    git clone https://github.com/AlexeyAB/darknet
    cd darknet
    mkdir build-release
    cd build-release
    cmake ..
    make
    make install

    https://pjreddie.com/media/files/yolov3.weights
    cd darknet
    ここにyolov3.weightsを入れる。
    それからMakefileを下記に変更

    GPU=1
    CUDNN=1
    CUDNN_HALF=0
    OPENCV=1
    AVX=0
    OPENMP=0
    LIBSO=0
    ZED_CAMERA=0

    # set GPU=1 and CUDNN=1 to speedup on GPU
    # set CUDNN_HALF=1 to further speedup 3 x times (Mixed-precision on Tensor Cores) GPU: Volta, Xavier, Turing and higher
    # set AVX=1 and OPENMP=1 to speedup on CPU (if error occurs then set AVX=0)

    DEBUG=0

    ARCH= -gencode arch=compute_30,code=sm_30 \
    -gencode arch=compute_35,code=sm_35 \
    -gencode arch=compute_50,code=[sm_50,compute_50] \
    -gencode arch=compute_52,code=[sm_52,compute_52] \
    # -gencode arch=compute_61,code=[sm_61,compute_61]

    OS := $(shell uname)

    # Tesla V100
    # ARCH= -gencode arch=compute_70,code=[sm_70,compute_70]

    # GeForce RTX 2080 Ti, RTX 2080, RTX 2070, Quadro RTX 8000, Quadro RTX 6000, Quadro RTX 5000, Tesla T4, XNOR Tensor Cores
    # ARCH= -gencode arch=compute_75,code=[sm_75,compute_75]

    # Jetson XAVIER
    # ARCH= -gencode arch=compute_72,code=[sm_72,compute_72]

    # GTX 1080, GTX 1070, GTX 1060, GTX 1050, GTX 1030, Titan Xp, Tesla P40, Tesla P4
    ARCH= -gencode arch=compute_61,code=sm_61 -gencode arch=compute_61,code=compute_61

    それからmake -j8
    webカメラを付けて下記コマンドで問題無いか?


    ./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights -c 0