License of articles in this site
本網站的文章內容由Zong-han, Xie製作,以創用CC 姓名標示-非商業性-相同方式分享 4.0 國際 授權條款釋出。
My environment and hardware capability refer to this article except I’ve reinstalled my cuda SDK back to cuda-7.0.
Therefore, I build 0.6.0 with GPU enabled on an environment with ubuntu 14.04, cuda-7.0 and Python 3.5.
My Java installation is Oracle JDK8 using HotSpot virtual machine.
TensorFlow needs a cuda deep neural network library called “cudnn",TensorFlow 0.6.0 version requires cudnn 6.5 V2, I had it installed in my cuda-7.0 directory.
The hardware I used is ASUS N550jv, the NVIDIA device in it is Geforce GT 750M. The CUDA capability of this device is listed as following.
Device 0: "GeForce GT 750M" CUDA Driver Version / Runtime Version 7.5 / 7.5 CUDA Capability Major/Minor version number: 3.0 Total amount of global memory: 2048 MBytes (2147352576 bytes) ( 2) Multiprocessors, (192) CUDA Cores/MP: 384 CUDA Cores GPU Max Clock rate: 1085 MHz (1.09 GHz) Memory Clock rate: 900 Mhz Memory Bus Width: 128-bit L2 Cache Size: 262144 bytes Maximum Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096) Maximum Layered 1D Texture Size, (num) layers 1D=(16384), 2048 layers Maximum Layered 2D Texture Size, (num) layers 2D=(16384, 16384), 2048 layers Total amount of constant memory: 65536 bytes Total amount of shared memory per block: 49152 bytes Total number of registers available per block: 65536 Warp size: 32 Maximum number of threads per multiprocessor: 2048 Maximum number of threads per block: 1024 Max dimension size of a thread block (x,y,z): (1024, 1024, 64) Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535) Maximum memory pitch: 2147483647 bytes Texture alignment: 512 bytes Concurrent copy and kernel execution: Yes with 1 copy engine(s) Run time limit on kernels: No Integrated GPU sharing Host Memory: No Support host page-locked memory mapping: Yes Alignment requirement for Surfaces: Yes Device has ECC support: Disabled Device supports Unified Addressing (UVA): Yes Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0 Compute Mode: < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
The repo of the CUDA toolkit I installed was acquired from the official web page and I used the package from “deb(network)" link.
After the package was acquired, type following commands in the terminal.
雖然C語言是沒有array這種function參數的,但是我還是想試一下如果把function參數設成多維陣列會怎樣。
#include <stdio.h> #include <stdlib.h> void foo(char a[][5]){ printf("%u\n", sizeof(a)); printf("%p\n", &a[0]); printf("%p\n", &a[1]); printf("%p\n", &a[2]); } void foo2(char a[][5][3]){ printf("%u\n", sizeof(a)); printf("%p\n", &a[0]); printf("%p\n", &a[1]); printf("%p\n", &a[2]); printf("%p\n", &a[1][0]); printf("%p\n", &a[1][1]); } int main(int argc, const char *argv[]) { char a[2][5]; foo(a); char b[2][5][3]; foo2(b); return 0; }
故意用char,因為char只佔一個byte,然後array長度選3, 5這種數,如果sizeof印出來是4很可能就是pointer型態。
在我的Raspberry Pi2 上用 raspbian付的 gcc 4.6編譯。
編譯下 gcc -Wall -std=c99 a.c,沒有warnings。
輸出結果:
4
0x7ee8b6f4
0x7ee8b6f9
0x7ee8b6fe
4
0x7ee8b6d4
0x7ee8b6e3
0x7ee8b6f2
0x7ee8b6e3
0x7ee8b6e6
由foo()印出來的結果知道,a型態是char (*)[5],是一個指向5個char的指標,每一次陣列取值會跳5個char。
由foo2()印出來的結果知道,a型態是char (*)[5][3],是一個指向5個char的指標,每一次陣列取值會跳15個char。而a[1][0]是一個指向3個char的指標,每一次陣列取值會跳3個char。
#include <iostream> #include <vector> #include <tuple> #include <complex> using namespace std; int main() { auto a = make_tuple(2, "xxx", 5.0, vector<double>(1,2.0), complex<double>(3.3,3.4)); cout << get<4>(a) <<endl; cout << get<3>(a)[1] <<endl; cout << get<1>(a) <<endl; return 0; }
References:http://www.cplusplus.com/reference/tuple/
確定一下blitz::blitz::TinyVector、blitz::TinyMatrix與blitz::Array的傳遞方式。
#include <iostream> #include <blitz/array.h> using namespace std; template<typename T> void foo(T mat){ mat(1)=3.0; } int main() { blitz::TinyVector<double, 3>vec; vec(2) = 5.123; blitz::TinyMatrix<double, 2,2> mat; blitz::Array<double,2> mat2; mat2.resize(2,2); mat(0,0) = 1; mat2(0,0) = 1; foo(vec); cout << "check TinyVector" << endl; std::cout << vec << std::endl; foo<blitz::TinyVector<double, 3>& >(vec); std::cout << vec << std::endl; cout << "check matrix" << endl; foo(mat); //TinyMatrix copy data foo(mat2); //Aray copy reference std::cout << mat <<std::endl; std::cout << mat2 <<std::endl; foo<blitz::TinyMatrix<double, 2,2>& >(mat); std::cout << mat <<std::endl; //passing reference with blitz::TinyMatrix<double, 2,2> return 0; }
由上面code測試可以知道,只有Array會copy reference,其他兩個是copy data。
此外,如果對於一個Matrix使用類似mat(1)去改值,則只會改到(1,1)這個element。
參考:
為了在台南的創業聚會BJ4分享如何閱讀一本書,我花了一個禮拜硬是把這一本書啃下去。
在聚會上報告的摘要投影片在這裡。
這一本書是一本經典,從1972出版第二版之後就沒有再改版過。
中文版由現任大塊文化董事長 郝明義先生與都會女作家朱依女士翻譯。
書名雖然是如何閱讀一本書,但是主要內容集中在如何閱讀有論述內容的理論或實用型讀物。
其他類書籍像是想像文學、哲學、科學甚或社會科學作品則是分別以專章討論。
本書是關於閱讀的藝術,是為了主動閱讀的人所寫的。
所謂主動閱讀指的是以增強理解力(理解書本內容至與作者相同level)為目標而閱讀。
作者以四個問題(摘自原書)來貫穿本書,這四個問題被作者認為是理解一本書所需要的集中心力去回答的四個問題。
閱讀依次分為四個層次(摘自原書):
檢視閱讀除了利用序、目錄、索引、參考文獻和找幾頁選讀來看看這本書大約要傳達哪些主題與可能有哪些內容之外(這叫做略讀),也有所謂粗讀。粗讀就是把書一直讀下去,不要回頭。粗讀會讓讀者大約只有理解近50%或可能更少的內容,但是卻可以讓讀者決定是否要進花更多時間進入分析閱讀,或者是不是要購買一本書。
根據書中的說法,在1972年作者寫作這本書的時空背景下他認為大約只有1%~0.01%的書值得進入分析閱讀的領域。其他的書粗淺的讀一下就好了。
一旦進入分析閱讀,就要精準的抓出書本的主旨、大綱與綱要架構以及有談論到的論述及主題。透過對於每一部分用詞的理解到關鍵據再到對於一整個論述的完整理解來了解大綱架構下各部份內容。然後,假設讀者已經完全理解了這一本書,就要能評論(誠實的)這一本書。這樣也是一種自省的方式,沒有看懂的地方就在回去看,直到看懂為止。
這一本書我大致上掃過一次(大約就是略讀)。光是略讀我所得到的知識就可以讓你今後讀任何書籍時更有方向感而不是蠢蠢的從第一行讀到最後一行。
參考:
在Tainan.py的演講pdf檔案。
演講稿與用來展示的python code都在github上。
https://github.com/xingularity/signal_python_lecture
在One-dimensional FDTD simulation with conductive materials當中,我使用了Ohm’s law來處理導電介質。這邊將介紹由色散關係的觀點來處理導電介質的處理方法 ,並由此開始討論一些case來簡介FDTD如何處理導電介質。 閱讀全文
參考:http://longbao738.blogspot.tw/2013/10/ubuntu-line.html
我之前試了很久,結果都在啟動LINE之後登入時就崩潰,完全沒有辦法使用。
參考了上面的文章才知道我需要裝vcrun2008這個東西。
實際上上面文章的winetrick指令是會自動去微軟網站抓 Microsoft Visual C++ 2008 SP1 Redistributable Package (x86),下來安裝。
只要多裝了這個就可以"蠻"正常的使用。
我使用的Wine是1.6.1。
以下是截圖: