NVIDIA Jetson TK1学习与开发(三):图文详解Jetson TK1平台搭建

最后更新于:2022-04-01 16:04:03

## 图文详解Jetson TK1平台搭建 在[《NVIDIA Jetson TK1学习与开发(一)》](http://blog.csdn.net/frd2009041510/article/details/41901239)和[《NVIDIA Jetson TK1学习与开发(二)》](http://blog.csdn.net/frd2009041510/article/details/41912775)中已经对TK1的基本资源进行了简单介绍,并且推荐了一些很有用的网址供大家学习。本文将图文详解Jetson TK1平台的搭建。 ### 1、开箱第一步 开箱后进入唯一的目录下, ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616b26a33.jpg) 会看到installer.sh,在当前路径执行以下命令: ~~~ sudo ./installer ~~~ (注意:此命令只能执行一次) 重启, ~~~ sudo reboot ~~~ 重启后进入开机登陆界面,账号和密码均是:ubuntu ### 2、平台开发的选择 一般来说,对嵌入式的开发有两种选择,原生编译(native compilation)和交叉编译(cross-compilation)。 所谓原生编译,就是在目标板上直接运行自己的代码,以TK1为例,就是说在TK1目标板上编译代码;所谓交叉编译,这也是我们大多数采用的编译方法,简单来说就是在台式机上编译,然后挂载在目标板上运行的方式。 对于开发TK1,推荐使用原生编译。 ### 3、下载并安装CUDA包 下载安装包:[https://developer.nvidia.com/cuda-toolkit-60](https://developer.nvidia.com/cuda-toolkit-60) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616b4fe0a.jpg) (注意:下载的版本要与TK1的CUDA Driver版本一致,否则后面的samples无法执行。) 下载后如下图所示: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616b6ce82.jpg) 安装方法: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616b8d162.jpg) ~~~ sudo dpkg -i xxx.deb ~~~ ### 4、更新apt-get ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616bafe95.jpg) ~~~ sudo apt-get update ~~~ ### 5、安装samples和toolkit ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616bc3f56.jpg) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616bd3edc.jpg) ~~~ sudo apt-get install cuda-samples-6-0 sudo apt-get install cuda-toolkit-6-0 ~~~ ### 6、设置当前用户下可以访问GPU ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616be71c4.jpg) ~~~ sudo usermod -a -G video $USER ~~~ ### 7、修改环境变量 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616c05539.jpg) ~~~ cd vim .bashrc ~~~ 在最后一行加上: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616c19dfc.jpg) ~~~ export PATH=/usr/local/cuda-6.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-6.0/lib:$LD_LIBRARY_PATH ~~~ 最后不要忘记执行下面的命令: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616c2b57f.jpg) ~~~ source .bashrc ~~~ ### 8、查看编译环境是否安装成功 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616c3c2ce.jpg) ~~~ cd /usr/local/cuda nvcc -V ~~~ 从图中可以看到已经成功安装了CUDA6.0了。![大笑](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-01-19_569e21abc5518.gif) ### 9、编译与运行例程 查看当前目录中是否有samples: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616c549ad.jpg) ~~~ ll ~~~ (注意是字母l。) 复制samples: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616c711d0.jpg) ~~~ cuda-install-samples-6.0.sh /home/ubuntu/ ~~~ 然后, ~~~ cd ls ~~~ 可以看到NVIDIA_CUDA-6.0_Samples。 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616c82d99.jpg) 最后, ~~~ make ~~~ ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616c97bb1.jpg) make完成后,可以在...NVIDIA_CUDA-6.0_Samples/bin/armv7/linux/release/gnueabihf/下可以看到编译成功的可执行文件。 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616cb162f.jpg) ### 10、示例演示 在...NVIDIA_CUDA-6.0_Samples/bin/armv7/linux/release/gnueabihf/路径下完成已提供的例子即可。 以下提供两个例子,效果截图如下所示: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616cc9866.jpg) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-05-07_572d616cecf63.jpg) 至此,整个平台已经搭好,剩余的就是靠自己了。![吐舌头](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-22_56f0e98bbe0df.gif)
';