英伟达jetson tx1开发套件配置tensorflow
英偉達(dá)jetson tx1開發(fā)套件配置tensorflow
本文為原創(chuàng)作品,未經(jīng)本人同意,禁止轉(zhuǎn)載,禁止用于商業(yè)用途!本人對(duì)博客擁有最終解釋權(quán)
歡迎關(guān)注我的博客:http://blog.csdn.net/hit2015spring和http://www.cnblogs.com/xujianqing/
?
Jetson tx1本身具有的內(nèi)存和存儲(chǔ)容量是比較小的,而且它是基于ARM架構(gòu)的cpu更是與intel的處理器架構(gòu)不一樣,所以很多網(wǎng)上的分享不適用于TX1的配置。這里從英偉達(dá)的jetson hacks上面的官方教程來(lái)配置tensorflow。
參考文章:Jetson hacks
http://www.jetsonhacks.com/2016/12/30/tensorflow-nvidia-jetson-tx1-development-kit/
http://www.jetsonhacks.com/2017/01/28/install-samsung-ssd-on-nvidia-jetson-tx1/
http://www.jetsonhacks.com/2016/12/21/jetson-tx1-swap-file-and-development-preparation/
這里分成三步執(zhí)行
配置外置SSD
這里用的是三星 EVO 250G的SSD,支持SATA接口,ssd插上去開機(jī)是不能用的,TX1是沒有識(shí)別的,需要的格式化為linux支持的文件系統(tǒng)ext4.一系列配置之后可以把ssd設(shè)置為外置的存儲(chǔ),然后再把文件系統(tǒng)拷貝到SSD中,設(shè)置為從SSD啟動(dòng)系統(tǒng)。和PC機(jī)從BIOS啟動(dòng)不一樣的是,TX1可以用好幾種方式啟動(dòng)它。只要配置exlinux.conf就OK了。仔細(xì)看視頻就可以配置好
?
?
?
?
新建:
name輸入名字jetsonssd-256
Ok完成。
這里新建分區(qū)的時(shí)候是要輸入盤的大小,輸入250G,這個(gè)三星的ssd不能全部新建。
配置swapfile
這一步配置交換空間,TX1的內(nèi)存只有4G,用來(lái)配置tensorflow是不夠用的,在配置tensorflow之前要給它加一個(gè)交換空間,這個(gè)空間的功能是當(dāng)物理內(nèi)存不夠時(shí),將某些內(nèi)存當(dāng)中所占的程序暫時(shí)移動(dòng)到swap當(dāng)中,讓物理內(nèi)存可以被需要的程序來(lái)使用。另外,如果你的主機(jī)支持電源管理模式,也就是說(shuō),你的linux主機(jī)系統(tǒng)可以進(jìn)入休眠狀態(tài)的話,娜美運(yùn)行當(dāng)中的程序狀態(tài)則會(huì)被記錄到swap當(dāng)中去,以作為喚醒主機(jī)狀態(tài)的依據(jù)。
命令行:
[directory location]:這里填寫你的ssd路徑地址
[size in gigabytes]:這里填寫你要設(shè)置的swap的大小,以G為單位。
-a:是默認(rèn)開機(jī)自啟動(dòng)swap,在/etc/fstab中自己設(shè)置
我設(shè)置了20G,默認(rèn)是8G,一般的swap設(shè)置為內(nèi)存的兩倍。
?
下面這段話是該文章里頭提到的一點(diǎn)問(wèn)題,這里我們用不到,但是可以幫助以后找問(wèn)題。
在SSD或其他閃存類型內(nèi)存上設(shè)置交換文件可能會(huì)導(dǎo)致設(shè)備磨損。大多數(shù)當(dāng)前閃存具有可以執(zhí)行的讀取和寫入的生存期數(shù)量,繁忙的交換文件可以消耗大量的那些。請(qǐng)注意,硬盤驅(qū)動(dòng)器也是如此。較新的SSD已經(jīng)建立了幫助分發(fā)"寫磨損"的機(jī)制。一如往常,備份您的驅(qū)動(dòng)器,并將其存儲(chǔ)。在視頻中,交換文件在計(jì)算機(jī)引導(dǎo)時(shí)自動(dòng)安裝。這是偉大的開發(fā),但之后,你可能要禁用該功能。為此:
$ sudo gedit / etc / fstab
并注釋掉執(zhí)行"swapon"的行。確保保存文件,重新啟動(dòng)并檢查以確保交換已關(guān)閉。
此外,你可能想要有一個(gè)更硬的核心關(guān)于你的交換區(qū)。您可以留出"交換分區(qū)",并使用它而不是交換文件。這種方法可能更快,因?yàn)榻粨Q區(qū)域連續(xù)放置。此路由類似于設(shè)置交換文件,但超出了本文的范圍。
運(yùn)行完后開始在disks里頭設(shè)置
按照?qǐng)D中正確選擇
然后重啟系統(tǒng)。
設(shè)置從SSD啟動(dòng)系統(tǒng):
開發(fā)板自帶的emmc存儲(chǔ)只有16G,第一步安裝系統(tǒng)后只有4.4G,本次搭建tensorflow環(huán)境需要很多存儲(chǔ),所以需要擴(kuò)展存儲(chǔ),但是不能就單單加個(gè)SSD就可以,這樣把文件放在SSD是不好用的,需要將系統(tǒng)運(yùn)行在SSD上才行,按視頻教程后半部分將系統(tǒng)文件復(fù)制到SSD中,修改啟動(dòng)配置文件,使之從SSD內(nèi)啟動(dòng):
修改配置文件
The last setup step is to modify the file extlinux.conf file on the eMMC. The system will boot from the internal eMMC, then the kernel will set the root directory to point to the SATA drive
$ cd /boot/extlinux $ sudo cp extlinux.conf extlinux.conf.original $ sudo gedit /boot/extlinux/extlinux.conf
這里主要修改幾個(gè)地方
?
?
?
其實(shí)整個(gè)文件如下:
TIMEOUT 30
DEFAULT satassd
MENU TITLE p2371-2180 eMMC boot options
LABEL satassd
MENU LABEL primary SATA SSD
LINUX /boot/Image
INITRD /boot/initrd
FDT /boot/tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb
APPEND fbcon=map:0 console=tty0 console=ttyS0,115200n8 androidboot.modem=none androidboot.serialno=P2180A00P00940c003fd androidboot.security=non-secure tegraid=21.1.2.0.0 ddr_die=2048M@2048M ddr_die=2048M@4096M section=256M memtype=0 vpr_resize usb_port_owner_info=0 lane_owner_info=0 emc_max_dvfs=0 touch_id=0@63 video=tegrafb no_console_suspend=1 debug_uartport=lsport,0 earlyprintk=uart8250-32bit,0x70006000 maxcpus=4 usbcore.old_scheme_first=1 lp0_vec=${lp0_vec} nvdumper_reserved=${nvdumper_reserved} core_edp_mv=1125 core_edp_ma=4000 gpt android.kerneltype=normal androidboot.touch_vendor_id=0 androidboot.touch_panel_id=63 androidboot.touch_feature=0 androidboot.bootreason=pmc:software_reset,pmic:0x0 net.ifnames=0root=/dev/sda1 rw rootwait
LABEL emmc
MENU LABEL Internal eMMC
LINUX /boot/Image
INITRD /boot/initrd
FDT /boot/tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb
APPEND fbcon=map:0 console=tty0 console=ttyS0,115200n8 androidboot.modem=none androidboot.serialno=P2180A00P00940c003fd androidboot.security=non-secure tegraid=21.1.2.0.0 ddr_die=2048M@2048M ddr_die=2048M@4096M section=256M memtype=0 vpr_resize usb_port_owner_info=0 lane_owner_info=0 emc_max_dvfs=0 touch_id=0@63 video=tegrafb no_console_suspend=1 debug_uartport=lsport,0 earlyprintk=uart8250-32bit,0x70006000 maxcpus=4 usbcore.old_scheme_first=1 lp0_vec=${lp0_vec} nvdumper_reserved=${nvdumper_reserved} core_edp_mv=1125 core_edp_ma=4000 gpt android.kerneltype=normal androidboot.touch_vendor_id=0 androidboot.touch_panel_id=63 androidboot.touch_feature=0 androidboot.bootreason=pmc:software_reset,pmic:0x0 net.ifnames=0 root=/dev/mmcblk0p1 rw rootwait
標(biāo)紅的地方是修改的
重啟ok
如果要從emmc啟動(dòng),則改一下這里的配置就OK了。Label那個(gè)位置該一下。
配置tensorflow
配置tensorflow真是一個(gè)巨坑,歸功于我們牛逼的墻,導(dǎo)致我翻墻失敗,下載安裝依賴項(xiàng)的時(shí)候數(shù)據(jù)包下載不完整,配置不成功,還找不到問(wèn)題的關(guān)鍵。
然后就開始在github里面看配置的源碼,一個(gè)一個(gè)找問(wèn)題。這里就給出他們的源碼,和解析!
其實(shí)這個(gè)配置就是一段命令行的配置:
上github把英偉達(dá)的配置demo下載下來(lái):
git clone https://github.com/jetsonhacks/installTensorFlowTX1 cd installTensorFlowTX1
配置動(dòng)態(tài)鏈接庫(kù)的路徑
./setLocalLib.sh下載一些安裝依賴項(xiàng),包括java protobuf等
./installPrerequisites.sh下載tensorflow源碼
兩個(gè)選擇 n,y
./buildTensorFlow.sh ./packageTensorFlow.sh這一步要超級(jí)權(quán)限
sudo pip install $HOME/tensorflow-0.11.0-py2-none-any.whl cd $HOME/tensorflow time python tensorflow/models/image/mnist/convolutional.py
這是github里面的文檔說(shuō)明:
最少要8g的內(nèi)存,然后存儲(chǔ)大小最少要5.5g的大小,所以告訴你要給它配置一個(gè)硬盤。當(dāng)然還要設(shè)置好庫(kù)路徑,這里面通過(guò)setlocallib.sh這個(gè)文件來(lái)設(shè)置。
這里需要編譯兩個(gè)版本的Protobuf,一個(gè)(v3.1.0)是用于grpc,一個(gè)v3.0.0-beta-2用于bazel,安在:$HOME/lib and $HOME/bin.
Grpc 0.15.0版本,補(bǔ)丁支持arm架構(gòu)
grpc-java v0.15.0 requires > v3.0.0-beta-3 of protobuf. A patch is applied for aarch64.
Bazel
Builds version 0.3.2. Includes patches for compiling under aarch64.
這個(gè)版本里頭的補(bǔ)丁支持arm64架構(gòu)
?
?
?
?
Before installing TensorFlow, a swap file should be created (minimum of 8GB recommended). The Jetson TX1 does not have enough physical memory to compile TensorFlow. Also, if TensorFlow is being compiled on the built-in 16GB flash drive, a standard JetPack installation may consume too much room on the drive to successfully build TensorFlow. Extraneous files will need to be removed. Eliminating the .deb files in the home directory appears to be enough to allow TensorFlow to build. Successful builds tend to have more than 5.5GB free. Also, for a successful build it is recommended to set local lib using the included script setLocalLib.sh, as grpc-java in particular seems to run into issues if it /usr/local/lib is not in the path.
Note: Most of this procedure was derived from the thread: https://github.com/tensorflow/tensorflow/issues/851
TensorFlow should be built in the following order:
installPrerequisites.sh
Installs Java and other dependencies needed. Also builds:
Protobuf
Two versions of protobuf are compiled. The first (v3.1.0) is needed to build grpc-java. This version ends up being installed in $HOME/lib and $HOME/bin. The second version (v3.0.0-beta-2) is used to build bazel
grpc-java
grpc-java v0.15.0 requires > v3.0.0-beta-3 of protobuf. A patch is applied for aarch64.
Bazel
Builds version 0.3.2. Includes patches for compiling under aarch64.
cloneTensorFlow.sh
Git clones r0.11 from the TensorFlow repository and patches the source code for aarch64
setTensorFlowEV.sh
Sets up the TensorFlow environment variables. This script will ask for the default python library path.
buildTensorFlow.sh
Builds TensorFlow.
packageTensorFlow.sh
Once TensorFlow has finished building, this script may be used to create a 'wheel' file, a package for installing with Python. The wheel file will be in the $HOME directory, tensorflow-0.11.0-py2-none-any.whl
Install wheel file
$ pip install $HOME/tensorflow-0.11.0-py2-none-any.whl
Test
Run a simple TensorFlow example for the initial sanity check:
$ cd $HOME/tensorflow
$ time python tensorflow/models/image/mnist/convolutional.py
Build Issues
For various reasons, the build may fail. The 'debug' folder contains a version of the buildTensorFlow.sh script which is more verbose in the way that it describes both what it is doing and errors it encounters. See the debug directory for more details.
Notes
As of this writing (Jan 15, 2017) the TensorFlow repository has an issue which does not allow incremental compilation to work correctly. This is due to an issue in the file:
tensorflow/third_party/gpus/cuda_configure.bzl
Where the rule:
cuda_configure = repository_rule( implementation = _cuda_autoconf_impl, local = True, )
forces Bazel to always rebuild the CUDA configuration, which in turn foobars the incremental build process. The cloneTensorFlow.sh script patches the file to remove the local = True statement. Additionally, buildTensorFlow.sh sets TensorFlow environment variables to reflect the CUDA structure of the Jetson TX1.
Since v0.11 was published, the location of the zlib library being used has moved. This is also taken into account by the cloneTensorFlow.sh script, which patches the library location.
?
遇到問(wèn)題
Unzipping /home/ubuntu/.gradle/wrapper/dists/gradle-2.13-bin/4xsgxlfjcxvrea7akf941nvc7/gradle-2.13-bin.zip to /home/ubuntu/.gradle/wrapper/dists/gradle-2.13-bin/4xsgxlfjcxvrea7akf941nvc7
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.zip.ZipFile.<init>(ZipFile.java:163)
at org.gradle.wrapper.Install.unzip(Install.java:214)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:74)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
?
?
解決方法:直接進(jìn)入
/home/ubuntu/.gradle/wrapper/dists/gradle-2.13-bin/4xsgxlfjcxvrea7akf941nvc7
這個(gè)路徑,把那個(gè)壓縮包去掉,然后自己去官網(wǎng)下一個(gè)gradle-2.13-bin.zip包,(網(wǎng)絡(luò)真坑爹),當(dāng)然是放在原來(lái)的路徑下嘍!
然后就OK!
另一個(gè)問(wèn)題:
?
說(shuō)git下載有問(wèn)題,RPC failed curl 56 GnuTLS recv error (-9)
簡(jiǎn)單粗暴,卸載git,再重新安裝
最后給一個(gè)很福利的東西 ? ?https://github.com/rwightman/tensorflow/commit/a1cde1d55f76a1d4eb806ba81d7c63fe72466e6d有好東西,一鍵安裝
?
總結(jié)
以上是生活随笔為你收集整理的英伟达jetson tx1开发套件配置tensorflow的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Java制作一个盒子程序_编写一个简单的
- 下一篇: Gcc编译链接及常用选项总结